如何在Nextcord python中创建一个已提及的事件



我想让我的Discord机器人告诉成员不要ping所有者。

我不太确定提到的是否是实际事件。如果有人能帮忙,那将是一个巨大的帮助。

以下是我目前正在使用的内容:

@bot.event
async def on_mentioned(ctx):
author = ctx.author.mention
await ctx.send(f'{author} please do not ping that member. They are either AFK or do not want to be pinged.')

您可以检查on_message中是否有提及。

@bot.event
async def on_message(message):
for mention in message.mentions:
# do something

message.mentions将是一个提到的用户列表,您可以检查它是否包含任何提到。

关于重写on_message的注意事项--如果您在不运行bot.process_commands((的情况下重写它,则bot将不会处理命令。您也可以使用侦听器。看见https://docs.nextcord.dev/en/latest/faq.html#why-在消息上是否使我的命令停止工作。

我不太确定提到的是否是实际事件

这就是文档的作用。您可以查看事件参考或搜索它。

最新更新