#One cog gets loaded, but one doesn't

1 messages · Page 1 of 1 (latest)

tacit hound
#

jo you know what was wrong, i named my folder "commands" in which i hold my COGS for commands, this is insane and it doesnt even give you any warning or whatever

mossy cave
#

Commands from 1 cog aren't loading. The setup function there doesnt get executed for some reason

#

i have 2 cogs (ignore the helpers folder)

#

this is the owner cog's setup func

#

this is the partnerships cog's setup func

#

this is how i load cogs in the bot.py file

#

but when i run the bot, this happens

#

i was expecting "Partners cog loaded" to be printed

#

but it doesnt

mossy cave
#

and the commands from there dont work too

#

neither does it appear in the help cmd

#

all help is appreciated as i cant test the commands ive written due to this 🥲

vale apex
#

Uuuuuh

#

Hmmmmmm

#

@mossy cave send ur code for that cog?

mossy cave
#

they had similar issue

vale apex
#

Hmmmmm

#

Okay good luck

#

Ok

mossy cave
vale apex
#

Hmmmm

#

Okay

#

So

mossy cave
#

this is the thing if you are curious

class PartnerAssistant(commands.Bot):
    def __init__(self):
        super().__init__(command_prefix="!!", intents=intents)
        self.db_connected = asyncio.Event()
        self.db_conn.start()
        
        try:
            for filename in os.listdir("./Cogs"):
                if filename.endswith(".py"):
                    self.load_extension(f"Cogs.{filename[:-3]}")
                    print(f"-----------{filename[:-3]} Loaded-----------")

            self.load_extension("jishaku")
            print("Jishaku Initialised")
        except:
            raise

    @tasks.loop(count=1)
    async def db_conn(self):
        await Tortoise.init(
            db_url="sqlite://./database.db",
            # db_url=os.getenv("DATABASE_URL"),
            modules={"models": ["Helpers.dbmodels"]},
        )
        await Tortoise.generate_schemas()
        self.db_connected.set()

    async def close(self):
        await Tortoise.close_connections()
        await super().close()
        print("Closed")


bot = PartnerAssistant()
vale apex
#
class bot(commands.Bot):
def init():
   super().init()
mossy cave
vale apex
#

Hmmmm

#

Mmmmmm kay

#

I understand

#

I had that bug too

#

But was simple to fix XD

#

Thou interesting way to laod it

#

Load it*

mossy cave
#

yea its good if you have multiple cogs

vale apex
#

Doesn't it try to load

#

All the py files thou?

mossy cave
#

it only adds the .py files in the Cogs folder

#
            for filename in os.listdir("./Cogs"):
                if filename.endswith(".py"):
vale apex
#

Yes so then what do u do about classed modules or things

mossy cave
#

wot? 👀

vale apex
#

Dataclasses

#

That handle database actions?

mossy cave
#

those are in a different folder

vale apex
#

Aaah but how do u do that

#

Mind telling me?

mossy cave
#

i import them like this

vale apex
#

Yes

#

Oh hmmmm

#

So its like a namespace when u run main.py

#

As in c#? And c++?

mossy cave
#

not familiar with c# and c++ tbh 💀

vale apex
#

😅 👍

mossy cave
#

😅

vale apex
#

I am not that familiar with python

#

Python is just a hobby

mossy cave
#

you will learn the more you try out stuff

mossy cave
vale apex
#

I am use to the other languages like
C# C++ Js

#

Etc

mossy cave
#

ic

vale apex
#

But thanks for letting me know

#

Btw

mossy cave
#

Np!

vale apex
#

To fix that bug if it later persist when you update

#

Just strip the cog to scratch and rebuild it

#

It worked for me

mossy cave
#

Oh hmm

vale apex
#

Yeah no idea why

#

But it happened to the music system i was writing up

mossy cave
#

weird but will try

vale apex
#

And the whole cog just didn't wanna load

#

Same with my admin

#

I think i have the logs somewhere

mossy cave
#

something similar might be happening here

vale apex
#

All i did to fix it was strip it down and rebuild from rock bottom

mossy cave
#

hmm

#

k will try

vale apex
#

After i stripped the system 😅

#

Thou i am still rebuilding

#

Life of a developer never ends

#

Mind if i add you as a friend?@mossy cave

mossy cave
mossy cave
tacit hound
#

Did you fix it now? I have the same problem. I tried so seperate my bots commands into cogs and one is working, the other isn’t @mossy cave

mossy cave
#

but when i switched back to 2.0 stable, i didnt get the issue again

#

i had some minor changes in the code, but im not sure what made the issue disappear

#

maybe an inconsistent bug or smth

tacit hound
#

I know what results my got to not get loaded and it‘s that I’m importing other python files into my cog but somehow it doesn’t work, I need to find out how to import other py files into another py file, cause just importing it doesn’t work

vale apex
#

👀