我如何让机器人阅读提及?

时间:2021-02-16 22:32:26

标签: discord.py

如果有人提到我,我该如何让机器人阅读?就像如果有人提到我,我希望机器人回复。我该怎么做?

@client.event
me = '<@user_id>'
async def on_message(message):
    member = message.author.id 
    if message.content == me:
        await message.channel.send('my master will be back shortly')
    else:
        return
    await client.process_commands(message)

1 个答案:

答案 0 :(得分:0)

您可以使用 discord.Message.mentions。它返回消息中提到的 discord.Member 列表。

@client.event
async def on_message(message):
    me = message.guild.get_member(<user id>)
    if me in message.mentions:
        await message.channel.send('my master will be back shortly')
    await client.process_commands(message)

参考