Tambahkan Peran Peran .Py
member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
Tyrannicodin16
member = message.author
var = discord.utils.get(message.guild.roles, name = "role name")
member.add_role(var)
@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')
@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}")
@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}")
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
@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!**')