![](/img/trans.png)
[英]How do I send DM to all users in list with discord.py with defined function
[英]How to DM all users in discord.py
我不知道如何设置一个命令来 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
我需要另一个代码来设置命令
您不想这样做,创建私人频道受到严格的速率限制,并且您的机器人可以很快被隔离。 您可以找到其他方式来联系服务器的用户,例如提及。
这是文档关于 ratelimits 的文章: https : //discord.com/developers/docs/topics/rate-limits#rate-limits
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.