【发布时间】:2021-05-01 01:29:05
【问题描述】:
我的机器人中有一个名为“spam”的命令,这样当有人执行“.spam”时,它会发送一个嵌入警告,不要发送垃圾邮件。我已经能够让机器人在提及用户的同时发送嵌入。但是,当我执行“.spam @user1 @user2”时,它确实提到了两个用户,但也发送了两次嵌入,一次用于 user1,另一次用于 user2。
如何才能使仅发送 1 条消息,并提及用户数量? 任何帮助将不胜感激!谢谢。
这是我在垃圾邮件齿轮中的代码:
@commands.command()
async def spam(self, ctx, *members: discord.Member):
if members is None:
embed = discord.Embed(
title='',
description='Please do not spam the chat.',
colour=discord.Colour.blue()
)
embed.set_footer(text='')
embed.set_author(name='Mod says:',
icon_url='https://cdn.discordapp.com/avatars/745674627845587004/834f65d2747b1bb8806d12e3791c36bd.webp?size=1024')
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title='',
description='Please do not spam the chat.',
colour=discord.Colour.blue()
)
embed.set_footer(text='')
embed.set_author(name='Mod says:',
icon_url='https://cdn.discordapp.com/avatars/745674627845587004/834f65d2747b1bb8806d12e3791c36bd.webp?size=1024')
for member in members:
await ctx.send(member.mention, embed=embed)
【问题讨论】:
标签: python bots discord.py discord.py-rewrite