我尝试使用.ping进行了简单的discord.py设置,但是在当前情况下,实际发送的“ .ping”导致该机器人未发送任何内容。这里有我想念的东西吗?
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix = ".")
@bot.event
async def on_ready():
print("Everything's all ready to go~")
@bot.event
async def on_message(message):
author = message.author
content = message.content
print(content)
@bot.event
async def on_message_delete(message):
author = message.author
channel = message.channel
await bot.send_message(channel, message.content)
@bot.command()
async def ping():
await bot.say('Pong!')
bot.run('Token')
答案 0 :(得分:0)
确保await bot.process_commands(message)
事件中有on_message
个地方。
为什么 on_message 使我的命令停止工作?
覆盖提供的默认on_message禁止运行任何其他命令。要解决此问题,请在
bot.process_commands(message)
的末尾添加on_message
行。例如:@bot.event async def on_message(message): # do some extra stuff here await bot.process_commands(message)