问题
Well, I'm doing a Direct Message function to DM a specific user, but I've been searching the way to do it so I can message everyone on a server, and I don't get it. I'm using discord.py 0.16.9 for reference. Here is my current code:
@client.command(pass_context = True)
async def dm(ctx, member : discord.Member = None, *, message):
if not ctx.message.author.server_permissions.administrator:
return
if not member:
return await client.say(ctx.message.author.mention + "Specify a user to DM!")
if member = "@everyone":
member =
else:
await client.send_message(member, message)
回答1:
As already stated in a comment, it really isn't a good idea to dm everyone, but if you must, you can iterate over all members of a server and message them individually. In your example:
if member == "@everyone":
for server_member in ctx.message.server.members:
await client.send_message(server_member, message)
来源:https://stackoverflow.com/questions/45785727/how-to-dm-everyone-with-a-bot-discord-py