【问题标题】:Why i can't detect if a user has the muted role? discord.py为什么我无法检测到用户是否具有静音角色?不和谐.py
【发布时间】:2021-11-07 16:12:11
【问题描述】:

这是来自反垃圾邮件机器人的代码 sn-p,我希望机器人检测用户是否已经取消静音,并且由于某种原因它没有检测到用户具有“静音”角色,它只检测@everyone 角色。有谁知道为什么?

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")

【问题讨论】:

标签: python discord discord.py bots


【解决方案1】:

静音?


你可以这样查看是否有人被静音:

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

如果您需要搜索某人是否仅使用该角色被静音,请检查this question

【讨论】:

    猜你喜欢
    • 2021-03-29
    • 2021-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    相关资源
    最近更新 更多