【问题标题】:discord.py bot can't dm multiple users with a rolediscord.py bot 不能 dm 具有角色的多个用户
【发布时间】:2022-01-09 05:00:25
【问题描述】:

@client.command()
async def eventsoon(ctx):
  role = discord.utils.get(ctx.message.guild.roles, name='Golden God')
  for member in ctx.message.guild.members:
    if role in member.roles:
      await member.send("ur mom")

我希望机器人 dm 具有金神的角色的用户,它不起作用并且没有错误

【问题讨论】:

    标签: discord discord.py dm


    【解决方案1】:

    我测试了您的代码,这可能是因为您没有启用 Privileged Gateway 意图,并且您的机器人无法获取所有成员。在 Discord 开发者网站的 Bot 部分启用Server Members Intent

    然后,将它们添加到您的代码中。示例:

    intents = discord.Intents.default()
    intents.members = True
    
    client = commands.Bot(command_prefix="!", intents=intents)
    

    【讨论】:

      猜你喜欢
      • 2022-01-05
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 2020-08-20
      • 2019-08-22
      • 2020-09-02
      • 2021-05-15
      • 1970-01-01
      相关资源
      最近更新 更多