我所有的@ client.events都起作用,但我的@ client.command却不起作用,但是如果只是命令和on_ready事件,则@ client.command可以起作用

时间:2020-01-24 22:04:16

标签: python discord discord.py

这是我的代码。它仍处于早期开发中。另外,我对开发机器人还很陌生。

import discord
from discord.ext import commands

client = discord.Client()
bot_prefix: str = ">"
client = commands.Bot(command_prefix=bot_prefix)


@client.event
async def on_ready():
    print('Miska Rise')

这是我现在要举行的活动:

@client.event
async def on_message(message):
    if message.author == client.user:
        return None

    if message.content.startswith('woof') or message.content.startswith('Woof'):
        await message.channel.send('Bork!')

这是命令:

@client.command()
async def ping(ctx):
    await ctx.send('Pong!')

1 个答案:

答案 0 :(得分:0)

如果您覆盖on_message,则需要在其中调用Bot.process_commands,以便仍然处理命令。

请参见Why does on_message make my commands stop working? section of the FAQ in the documentation