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



这可能是一个重复的问题或一个新手Python错误,但我就是找不到正确的术语来搜索我的答案。

我的bot启动得很好,它甚至在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:>")

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

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

您需要向bot注册cog:

client.add_cog(GlobalBanningSystem(client))

最新更新