这是我尝试过的代码:
@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.")
但是它似乎不起作用。
使用命令修饰符时,您可以执行以下操作:
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")
参考:
commands.when_mentioned_or()
commands.when_mentioned_or()