【发布时间】: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