0
votes

hello i am making a bot that will give you role when you type in message but my code doesnt work it always gives this error

File "Rgiver.py", line 32, in on_message role = discord.utils.get(server.guild.roles, name="Admin") NameError: name 'server' is not defined

here is my code

async 

def on_message(message):
    member = message.author
    if member.bot:
        return
    if message.attachments:
        return
    print(message.content)
    print(str(message.author))


    if "role" in message.content:
        embed=discord.Embed(title="Giving role.", color=0x00ff40)
        await message.channel.send(message.channel, embed=embed)
        role = discord.utils.get(server.guild.roles, name="Admin")
        await client.add_roles(message.author, role)
1

1 Answers

1
votes

What is server.guild.roles, you probably mean message.guild.roles

Also, your add_roles usage is wrong, see the docs for add_roles, you probably mean message.author.add_roles(...)