Pois
Pois

Reputation: 17

'Message' object has no attribute 'user'

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.

Upvotes: 0

Views: 188

Answers (1)

Sujit
Sujit

Reputation: 1782

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.')

Upvotes: 2

Related Questions