My code:
@bot.command()
async def giverole(ctx, person):
guild = ctx.guild
role = discord.utils.get(ctx.guild.roles, name="role")
if discord.utils.get(ctx.guild.roles, name="role"):
await role.edit(position=10)
else:
await guild.create_role(name="role", color=discord.Color(0x000000))
await role.edit(position=10)
person = discord.utils.get(ctx.guild.members, name=person)
user = ctx.message.author
await user.add_roles(person, role)
This is supposed to be a command that gives a role to a user, but it doesn’t work. When the command %giverole is used, it returns an exception: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50013): Missing Permissions
I do not understand why this is happening, because I am using a testing server where I, the owner am using the command.
Is there a way I can fix this? Or, better yet, make the command ignore the permissions of the user altogether?