25

基本的に、すべて正常に動作して起動しているように見えますが、何らかの理由でコマンドを呼び出すことができません。私は今、簡単に1時間見回し、例を見たりビデオを見たりしてきましたが、何が間違っているのか一生わかりません。以下のコード:

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)

on_message にあるデバッグ出力は実際に機能して応答し、ボット全体が例外なく実行されますが、コマンドは呼び出されません。

4

2 に答える 2

-4

問題が の定義に起因することが確認された場合、ボットと同じプレフィックスを持っているように見えるため、on_message実際にはコマンドとして実装できます。debug

@bot.command()
async def debug(ctx):
    await ctx.send("d")
于 2021-07-15T14:50:23.717 に答える