图像链接我正在尝试制作一些东西,如果机器人被ping到,它会显示一条类似";对于命令列表,键入.help";我的代码有效,除了它还说当机器人被回复时。
这是我的代码-使用不和谐.py 1.7.3
@client.event
async def on_message(message):
if client.user.mentioned_in(message) and message.mention_everyone is False:
await message.channel.send("For a list of commands, type `.help`")
await client.process_commands(message)
您正在寻找client.user.mention
。如果您想知道消息中的某个地方是否提到了机器人程序,也可以检查if client.user.mention in message.content
,而不是检查是否提到了整个消息。
@client.event
async def on_message(message):
if client.user.mention == message.content and message.mention_everyone is False:
await message.channel.send("For a list of commands, type `.help`")
await client.process_commands(message)
参考:
- 抽象方法提及