discord.py @bot.command() 没有运行 [英] discord.py @bot.command() not running

本文介绍了discord.py @bot.command() 没有运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!



from flask import Flask
from threading import Thread
import discord
from discord.ext import commands, tasks
from discord.utils import get
import requests
from Moderator.badwords import words
import time
import datetime
from Stats.uptime import data

help_command = commands.DefaultHelpCommand(
    no_category = 'Commands'

intents = discord.Intents().all()
bot = commands.Bot(command_prefix='!', description="Hey there, I'm Botty (for example)!", help_command=help_command, intents=intents)

async def hello(ctx):
  await ctx.send(ctx.author.mention + " hello!")

async def on_ready():

async def on_message(message):
    for word in words:
        if word in message.content.lower():
            await message.delete()
            await message.channel.send("Oops! Seems like " + message.author.mention + " was trying to send a message that was breaking the " + bot.get_channel(783064049859559434).mention + ". Luckily, I deleted it before it caused any more damage. Don't send any more messages like that!

If you think that I made an error, please report it in " + bot.get_channel(783074030265040916).mention + ", " + bot.get_channel(783074002255478848).mention + " or in " + bot.get_channel(783092164590174251).mention)

async def on_member_join(member):
  print(f"{member} joined the server")



Now, I can compile and run this code with no errors, and when a member joins or a user sends a message, all works perfectly fine. But when it comes to run commands, it does not even start. Is there something i'm missing?




覆盖默认提供的 on_message 会禁止运行任何额外的命令.要解决此问题,请在 on_message 末尾添加 bot.process_commands(message) 行.

Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message.

如果您覆盖 on_message,则需要使用 await bot.process_commands(message) 以便处理命令.尝试将其添加到您的 on_message 事件中.

If you override an on_message, you need to use await bot.process_commands(message) so that the commands are processed. Try adding that to your on_message event.

这篇关于discord.py @bot.command() 没有运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
发送“验证码”获取 | 15天全站免登陆