add role discord .py
member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
add role discord .py
member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
create a role with discord.py
@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')
reaction role discord.py
@client.command('role')
@commands.has_permissions(administrator=True) #permissions
async def role(ctx, user : discord.Member, *, role : discord.Role):
if role.position > ctx.author.top_role.position: #if the role is above users top role it sends error
return await ctx.send('**:x: | That role is above your top role!**')
if role in user.roles:
await user.remove_roles(role) #removes the role if user already has
await ctx.send(f"Removed {role} from {user.mention}")
else:
await user.add_roles(role) #adds role if not already has it
await ctx.send(f"Added {role} to {user.mention}")
reaction role discord.py
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
reaction role discord.py
@role.error
async def role_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('**:x: | You do not have permission to use this command!**')
reaction role discord.py
@bot.command(pass_context=True)
async def giverole(ctx, user: discord.Member, role: discord.Role):
await user.add_roles(role)
await ctx.send(f"hey {ctx.author.name}, {user.name} has been giving a role called: {role.name}")
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us