Problem is, if i try to use message.author.id, it will say
"Cannot find reference 'author' in 'message.py'
Basically what i want to do in the code bellow is: a command that only certain id's have access to and that they can use to give their role away to someone.
Thanks for any help!
@client.command(pass_context=True)
@commands.has(939236844137226290)
async def asteroid(ctx, user: discord.Member):
if message.author.id == 939236844137226290:
role = ctx.guild.get_role(939236844137226290)
await user.add_roles(role)
await ctx.send(f"{user.name} has received {role} from {ctx.author.name}!")
else:
await ctx.send("Only asteroidblues has permission to give the role away")
The problem is probably that you imported discord.Message
but you have to use message.author.id
when message
is a variable containing a discord.Message
instance, which you don't have in this case. But what you do have is ctx
, the context, from which you can access the author id by using ctx.author.id
.