如果discord bot包含on_message(),则@ client.command不会运行

时间:2018-07-27 21:50:31

标签: python python-3.x discord discord.py

考虑以下不和谐的机器人:

import asyncio
from discord.ext.commands import Bot

client = Bot(command_prefix='!')

@client.command(pass_context=True)
async def ping():
    await client.say('pong')

with open('token.txt') as t:
     token = t.readlines()
client.run(token[0])

如果用户键入!ping,则漫游器会回复pong。但是,如果包含以下代码:

@client.event
async def on_message():
    pass

然后,函数on_message中的唯一代码运行,并且对!ping无响应。脚本如何同时包含on_message()@client.command

0 个答案:

没有答案