Answers for "discord bot add role to user python"

1

add self role with discord bot python

@async def on_message(message):
     if message.content == "give me admin"
           role = discord.utils.get(server.roles, name="Admin")
           await client.add_roles(message.author.id, role)
Posted by: Guest on September-07-2020
3

discord.py how to give a user a role

# If ctx is not defined and you are handling a message, use this code
ctx = await bot.get_context(message)

# This is the code needed to give a user a role
member = ctx.message.author # Member object that you want to add the role to
role = discord.utils.get(lambda role: role.name == "Role Name", ctx.guild.roles) # The role object
await member.add_roles(role) # Adds the role to the member
Posted by: Guest on June-24-2021
1

add role discord .py

member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
Posted by: Guest on February-29-2020
0

adding roles discord py

# If you need this in a bot command
@bot.command()
async def online(ctx):
    role = discord.utils.get(bot.get_guild(ctx.guild.id).roles, id ="Role ID")
    await member.add_roles(role)
Posted by: Guest on June-24-2021
0

adding roles discord py

# If you need this in a bot command
@discord.ext.commands.command()
async def online(ctx):
    role = discord.utils.get(bot.get_guild(ctx.guild.id).roles, id ="Role ID")
    await member.add_roles(role)
Posted by: Guest on June-24-2021

Code answers related to "discord bot add role to user python"

Python Answers by Framework

Browse Popular Code Answers by Language