如何让我的python discord bot检测到命令中提到的某个用户?
我试图让一个命令有一个异常,当bot本身被ping时,会发送一条不同的消息,而不是普通的消息。我似乎找不到一个对我有利的命令来处理discord.py,有什么建议吗如何让我的python discord bot检测到命令中提到的某个用户?,python,discord,bots,discord.py,Python,Discord,Bots,Discord.py,我试图让一个命令有一个异常,当bot本身被ping时,会发送一条不同的消息,而不是普通的消息。我似乎找不到一个对我有利的命令来处理discord.py,有什么建议吗 @bot.command() async def fight(ctx): if (insert the scanned mention == 'insert discord bot ping'): await ctx.send('message') await ctx.send('anothe
@bot.command()
async def fight(ctx):
if (insert the scanned mention == 'insert discord bot ping'):
await ctx.send('message')
await ctx.send('another message')```
您可以使用
ctx.message.indications
获得所有提到的用户的列表。如果您有该人的成员
/用户
实例,您可以执行(消息)中提到的成员,或者在您的情况下:
if client.user.mentioned_in(message):
# do something here
如果您没有成员
实例,您可以迭代ctx.message.indications
,并检查每个成员是否是您需要检查的成员
id = 12345678910 # The Discord id of the member you want to check
for user in ctx.message.mentions:
if user.id == id:
# do something here