I'm currently trying to make a discord bot with the ability to .mute a user. I have created this script so far that allows people with a "staff" role to run the command, and gives the tagged user a "Muted" role. It also creates one if it doesn't exist already. The problem is the code below does not work. It doesn't say anything in the console but if you have the staff role and you run the command nothing happens.
@commands.has_role("staff")
async def mute(ctx, member: discord.Member=None):
guild = ctx.guild
if (not guild.has_role(name="Muted")):
perms = discord.Permissions(send_messages=False, speak=False)
await guild.create_role(name="Muted", permissions=perms)
role = discord.utils.get(ctx.guild.roles, name="Muted")
await member.add_roles(role)
print("???? "+member+" was muted.")
if (not member):
await ctx.send("Please specify a member to mute")
return
@mute.error
async def mute_error(ctx, error):
if isinstance(error, commands.CheckFailure):
await ctx.send("You don't have the 'staff' role")