0

I am trying to use this in my code:

if ctx.user.server_permissions.administator:

However, I am being presented with the error:

'Message' object has no attribute 'user'

I have also tried ctx.author.server_permissions.administrator but neither seems to work.

1

1 Answer 1

2

You can use this:

ctx.author.guild_permissions.administrator

So,

if ctx.author.guild_permissions.administrator:
    await ctx.send('You are an administrator!')
else:
    await ctx.send('Sorry, you are not an administrator.')

You can also use this:

ctx.message.author.guild_permissions.administrator

So,

if ctx.message.author.guild_permissions.administrator:
    await ctx.send('You are an administrator!')
else:
    await ctx.send('Sorry, you are not an administrator.')
2
  • Hi, when using this in my code it gives me a similar error saying, Message' object has no attribute 'message'
    – Pois
    Dec 23, 2020 at 13:53
  • @Pois, I've updated my answer. Try using it without message then. I've tested both and they work properly. Check if you have passed ctx as an argument. Also check if you are using the latest version of discord.py.
    – Sujit
    Dec 23, 2020 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.