Bot 启动正常,但命令不起作用

Bot launches fine, but the commands do not work

这可能是重复问题或新手 Python 错误,但我找不到合适的词来搜索我的答案。

我的机器人启动正常,它甚至在 on_ready 上运行打印功能!但是,当我尝试使用这些命令时,没有任何响应。在我添加 class GlobalBanningSystem(commands.Cog): 之前它工作正常,所以我不知道!

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ".")

class GlobalBanningSystem(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    @commands.has_role("966695793555804232") # Staff Role ID
    async def gban(self, ctx, member: discord.User):
        channel = self.bot.get_channel("966681817094697020") # Logs Channel ID
        auth = ctx.author

        await ctx.send("Ban Issue successfuly opened. Now, please type the ban reason!")
        reason = await self.bot.wait_for('message', timeout = 600)

        embed = discord.Embed(title = f"Global Banned {member.name}", colour = 0xFF0000)
        embed.add_field(name = "Reason:", value = reason.content, inline = False)
        embed.add_field(name = "User ID:", value = f"`{member.id}`",)
        embed.add_field(name = "Staff Member:", value = f"{auth.name}")
        embed.set_thumbnail(url = member.avatar_url)
        await ctx.send(embed = embed)
        await ctx.send(f"**{member.name}** has been globbaly banned!")
        for guild in self.bot.guilds:
            await guild.ban(member)


@client.event
async def on_ready():
    print("Global Banning System is online!")

@client.command()
async def ping(ctx):
    await ctx.send(f"Bot's Response Latency: {round(client.latency * 1000)}ms")

client.run("token:>")

我正在尝试禁止用户使用的禁止命令:

  1. 用户所在的所有服务器
  2. 机器人所在的所有服务器

您需要向您的机器人注册 cog:

client.add_cog(GlobalBanningSystem(client))