[当有人提到它时,我如何使漫游器响应? discord.py

问题描述 投票:1回答:1

这是我尝试过的代码:

@client.event
async def on_message(message):
    if client.user.mention in message.content.split():
        await client.say("You can type `!vx help` for more info.")

但是它似乎不起作用。

discord.py discord.py-rewrite
1个回答
0
投票

使用命令修饰符时,您可以执行以下操作:

from discord.ext import commands # necessary for this task

client = commands.Bot(command_prefix=commands.when_mentioned_or("!"))

或使用on_message()事件,这是您可以检查提及的多种方法之一:

@client.event
async def on_message(message):
    if client.user.mentioned_in(message):
        await message.channel.send("You can type `!vx help` for more info")

参考:

© www.soinside.com 2019 - 2024. All rights reserved.