【问题标题】:How to DM all users in discord.py如何 DM discord.py 中的所有用户
【发布时间】:2021-11-03 04:43:08
【问题描述】:

我不知道如何设置一个命令来 DM 服务器中的所有用户。 我已经尝试过使用它:

@commands.command(aliases=["senddm", "alldm"])
async def all_dm(self, ctx, message):
    await ctx.send(f"DM everyone with `{message}` in `{ctx.guild.name}`? [y/n]")

    def check_data(message):
        return message.author == ctx.message.author

    while True:
        try:
            msg = await self.bot.wait_for('message', check=check_data, timeout=int(timeout))
            if msg.content == "y":
                await ctx.send(waitmsg)
                for user in list(ctx.guild.members):
                    try:
                        await user.send(nick=message)
                    except Exception:
                        pass
                await ctx.send(donemsg)
                return
            if msg.content == "n":
                await ctx.send(no_msg)
                return
        except asyncio.TimeoutError:
            await ctx.send(timeout_msg)
            return

我需要另一个代码来设置命令

【问题讨论】:

  • 我认为这违反了 Discord 的垃圾邮件服务条款。您可能应该只ping每个人。您不希望您的机器人受到速率限制。

标签: python discord discord.py


【解决方案1】:

您不想这样做,创建私人频道受到严格的速率限制,并且您的机器人可以很快被隔离。您可以找到其他方式来联系服务器用户,例如提及。

这是关于速率限制的文档文章:https://discord.com/developers/docs/topics/rate-limits#rate-limits

【讨论】:

    猜你喜欢
    • 2022-01-05
    • 1970-01-01
    • 2023-01-17
    • 2018-05-10
    • 2021-11-21
    • 2022-01-14
    • 1970-01-01
    • 2022-01-09
    • 2021-12-24
    相关资源
    最近更新 更多