0

this is a snippet of code from an antispam bot, I want the bot to detect if the user has already been unmuted and for some reason it does not detect that the user has the role "muted", it only detects the role @everyone. Does anyone know why?

async def unmute(ctx, member: discord.Member):
  mutedRole = discord.utils.get(ctx.guild.roles, name = "Muted")
  embedUnmuted = discord.Embed(title =":white_check_mark: Unmute", description = f"{member.mention} is not muted",color = discord.Color.green())

  print(member.roles)

  if mutedRole in member.roles:
    await member.remove_roles(mutedRole)
    await ctx.send(embed=embedUnmuted)
  else:
    print("The user was already unmuted")
Alkerg
  • 13
  • 5
  • Does this answer your question? [how do I check if a user has a specific role in discord](https://stackoverflow.com/questions/54845875/how-do-i-check-if-a-user-has-a-specific-role-in-discord) – FLAK-ZOSO Sep 11 '21 at 16:12
  • Unfortunately not – Alkerg Sep 11 '21 at 17:48

1 Answers1

0

Muted?


You can find if somebody is muted like this:

def is_muted(member: discord.Member):
    if not member.has_permissions(send_message=True)

If you need to search if somebody is muted only using the role, check this question.

FLAK-ZOSO
  • 3,873
  • 4
  • 8
  • 28