Cogs don't work after discord.py 2.0 update

Question:

I’ve been coding with discord.py 1.7 and my bot and cogs worked but after the discord.py 2.0 update my cogs load in (I think) yet when I try to use any they don’t work at all. I have no clue what I’m doing wrong.

This is my Main:

from Utils import *

async def load():
    for cmd in os.listdir("./BotCommands"):
        if cmd.endswith(".py"):
            await client.load_extension(f'BotCommands.{cmd[:-3]}')

#client connect
async def main():
    async with client:
        await load()
        await client.start(config.token)

asyncio.run(main())

and this is one of my cogs:

from Utils import *

class Owner(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.command()
    @commands.is_owner()
    async def ping(self, msg):
        await msg.send("Only the owner can use this command!")

    @commands.command()
    @commands.is_owner()
    async def remove(self, msg, userId: int):
        db.find_one_and_delete({"UserID": userId})
        await msg.send(f"Removed <@{userId}> from the database!")

async def setup(client):
    await client.add_cog(Owner(client))

I looked up a tutorial on youtube and from what I saw his code was the same as mine (only difference was what the command did)

Asked By: Kirittsu

||

Answers:

I found the problem. I’m not sure why but changing my intens from default to all made my bot work again.

Answered By: Kirittsu
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.