Discord.py | add role to someone

后端 未结 4 1664
别跟我提以往
别跟我提以往 2021-01-07 01:44

I have trouble with making an "add role" command in discord.py. I don\'t know what is wrong; it just doesn\'t work.

@client.command()
@commands.has_         


        
4条回答
  •  一个人的身影
    2021-01-07 02:18

    roleVer = 'BOT' #role to add
    user = ctx.message.author #user
    role = roleVer # change the name from roleVer to role
    
    await ctx.send("""Attempting to Verify {}""".format(user))
    try:
        await user.add_roles(discord.utils.get(user.guild.roles, name=role)) #add the role
    except Exception as e:
        await ctx.send('There was an error running this command ' + str(e)) #if error
    else:
        await ctx.send("""Verified: {}""".format(user)) # no errors, say verified
    

提交回复
热议问题