如何通过 discord.py 来 dm discord 中的所有版主,而不仅仅是一个版主?

How to dm all moderators in discord by discord.py, not only one?

我有这个代码:

async def report(ctx, member: discord.Member,  *, arg):
    role = ctx.guild.get_role(9999999999999) # Imagine that 9999999999999 is moderator role id
    members = ctx.guild.members
    await ctx.channel.send('Your complaint was sent to moderators!', delete_after=10)
    for i in role.members:
        await i.send(f'{ctx.author.mention} sent a complaint on {member.mention} with reason:\n**{arg}**')
        await ctx.message.delete()

问题是,当我写$report @user reason时,只有一个版主在私人消息中收到此报告,而不是所有版主。服务器上有 3 个版主,由于某种原因只有一个在 DM 中收到消息,而不是所有 3 个版主。 如何解决这个问题?非常感谢您的帮助。

await ctx.message.delete() 放在 for 循环之外。如果一条消息已被删除,而您试图再次删除它,则会引发错误。