【发布时间】:2022-01-11 05:46:12
【问题描述】:
所以我有这个代码。它应该向服务器中的每个人发送消息。它不会 DM 所有人,而只会尝试 DM 运行在代码上的机器人,因为这是不可能的,所以它失败了。
@client.command()
async def adm(ctx, *, message):
await ctx.message.delete()
for user in ctx.guild.members:
try:
await user.send(message)
print(f"Sent {user.name} a DM.")
except:
print(f"Couldn't DM {user.name}.")
print("Sent all the server a DM.")
【问题讨论】:
-
您需要启用会员意图。
-
我该怎么做?
标签: python discord discord.py