我想创建一个将消息发送给特定用户或所有用户的命令。 我尝试制作此字符串,但不起作用:
@client.command()
@commands.has_permissions(administrator=True)
async def invia(ctx, member: discord.member=None,* ,message):
if member == "@everyone":
for server_member in ctx.message.server.members:
await client.send_message(server_member, message)
else:
await member.send(message)
我一直在到处寻找,尽管这些问题过时了或者对我想做的事情没有用。
答案 0 :(得分:0)
您可以将dm发送给所提及的用户,例如:!dm @mentioneduser test message
@client.command()
async def dm(ctx, member: discord.User, *, content):
await member.send(content)
向服务器中的每个人发送DM。
@client.command()
async def dmall(ctx, *, message):
for member in ctx.guild.members:
try:
await member.send(message)
print(f"DM sent to {member.name}")
except:
print('Could not DM user, closed DMs.')