Bot launches fine but the commands do not work

Advertisements

Well, this is probably a duplicate question or a noobie python error, but i just cant find the right terms to search for my answer. my bot launches fine, and it even runs the print function on on_ready! however, when I try using the commands there are no responses. it worked fine before i added the class GlobalBanningSystem(commands.Cog): so i dont know!

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:>") 

What I was trying to do there, was a ban command that would ban the user from

  1. all the servers that the user is in
  2. all the servers that the bot is in

>Solution :

You need to register the cog with your bot:

client.add_cog(GlobalBanningSystem(client))

Leave a Reply Cancel reply