member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
from discord.ext import commands
from discord.utils import get
bot = commands.Bot(command_prefix='!')
@bot.command(pass_context=True)
@commands.has_role("Admin") # This must be exactly the name of the appropriate role
async def addrole(ctx):
member = ctx.message.author
role = get(member.server.roles, name="Test")
await bot.add_roles(member, role)
@client.command(aliases=['make_role'])
@commands.has_permissions(manage_roles=True) # Check if the user executing the command can manage roles
async def create_role(ctx, *, name):
guild = ctx.guild
await guild.create_role(name=name)
await ctx.send(f'Role `{name}` has been created')
guild = ctx.guild
await guild.create_role(name="role name")
#To mention a role you need the role ID
#Exaple
#you can use ~bot~ or ~client~ it dont matter
@bot.command
async def exaple_test(ctx):
await ctx.send(f"Role: <@&_your_role_id_here_)>")