小编Ace*_*ean的帖子

为什么on_message会停止命令的工作?

基本上,一切似乎都可以正常运行并启动,但是由于某些原因,我无法调用任何命令。我已经很轻松地环顾了一个小时,然后浏览示例/观看视频,但我终生无法找出问题所在。代码如下:

import discord
import asyncio
from discord.ext import commands

bot = commands.Bot(command_prefix = '-')
@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')

@bot.event
async def on_message(message):
    if message.content.startswith('-debug'):
        await message.channel.send('d')

@bot.command(pass_context=True)
async def ping(ctx):
    await ctx.channel.send('Pong!')

@bot.command(pass_context=True)
async def add(ctx, *, arg):
    await ctx.send(arg)
Run Code Online (Sandbox Code Playgroud)

我在on_message中拥有的调试输出实际上可以正常工作并做出响应,并且整个bot都可以运行,没有任何异常,但是它不会调用命令。

python python-3.x discord discord.py discord.py-rewrite

4
推荐指数
1
解决办法
2535
查看次数