考虑以下不和谐的机器人:
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
?