#on ready won't print things

1 messages · Page 1 of 1 (latest)

mossy hemlock
#

I am honestly confused, this worked as intended in all tests.
when the bot is online it does correctly check if the bot is ready too.
However it doesn't produce any output in real world usage and i have no idea why.
Here is the file:

from main import Boot
from discord.ext import commands


class Ready(commands.Cog):
    def __init__(self, boot: Boot):
        self.boot = boot
        self.has_run = False

    @commands.Cog.listener()
    async def on_ready(self):
        """defines what the bot does once cache is loaded"""
        if self.has_run:
            return

        print(f'Logged on as {self.boot.user}!')

        member_counter = 0
        real_guild_ids = []
        delete_guilds = []

        stored_guild_ids = await self.boot.db.call_all_server_ids()

        for guild in self.boot.guilds:
            real_guild_ids.append((guild.id,))
            member_counter += guild.member_count

        for guild_ID in stored_guild_ids:
            if guild_ID not in real_guild_ids:
                delete_guilds.append(guild_ID[0])

        await self.boot.db.delete_many_servers(delete_guilds)

        print(f"\nBooty monitors the activity of {member_counter} Discord members \n"
              f"and is used on {len(self.boot.guilds)} Discord servers!")

        self.has_run = True


def setup(boot: Boot):
    boot.add_cog(Ready(boot))

PS: "boot" or "Boot" is my bot class, cause it's avatar is a boot and its name is booty. It kicks people. just think of it as "bot"

mossy hemlock
#
    extensions = ("cogs.slash_test",
                  "cogs.on_ready", "cogs.on_cooldown",
                  "cogs.on_message",  "cogs.on_reaction", "cogs.on_voice",
                  "cogs.on_member_join", "cogs.on_member_leave",
                  "cogs.on_guild_join", "cogs.on_guild_leave",
                  "cogs.slash_help", "cogs.slash_poweroff",
                  "cogs.slash_whitelist",
                  "cogs.slash_diagnose", "cogs.slash_updatedb",
                  "cogs.slash_kick", "cogs.slash_kick_status")

    for extension in extensions:
        booty.load_extension(extension)
rigid ginkgo
#

And does this extension is load after that ?

#

(You can check the bot.extensions or add an on_cog_load or something like that in the class of your cog to test

mossy hemlock
#

the other one is on_ready.py in the folder Cogs

mossy hemlock
#

same was true for the diagnostic parts (=bot.extensions).
They did not show up in Terminal when printed, but when returned through

await ctx.respond( ... 
sleek escarp
#

Can you show your imports at the files?

#

And the pip list pls

rigid ginkgo
#

(you can just unload everything and only load the on_ready, then one more etc etc to troublshoot this

mossy hemlock
sleek escarp
#

What do you use for APIs?

rigid ginkgo
#

cos this is a lot lmao

sleek escarp
#

Do you use something like time at your bot

mossy hemlock
#

.env is a sensible choice when you have more than one project in the same system.

mossy hemlock
sleek escarp
#

And for request to APIs?

mossy hemlock
#

what imports were you asking to see, zervy?

sleek escarp
#

aiohttp or requests

mossy hemlock
rigid ginkgo
#

again i think just load 1 cog and check etc will be faster since this in on ur on_ready, so it should take less than 20 try

sleek escarp
mossy hemlock
#

I have an idea what the culprit might be. didn't think about it earlier..

rigid ginkgo
mossy hemlock
#

.. when I was installing the mysql server i had to run as root for a while. to set up permissions for the user acc that runs main.py for the bot.

sleek escarp
#

Wat is culprit?

mossy hemlock
#

while i was root i also did install packages... it was pretty late and this was a few weeks back.

#

you know.. how you are warned not to "pip anything" as sudo or root

#

i may have messed something up on the system by doing so unintentionally

sleek escarp
#

Uh

mossy hemlock
#

guess the only way to find out is to set up a new virtual machine with the same specs and packages the proper way, transfering the current database and all bot files over and test it.

#

fixing such things is a headache IF that's the cause.

#

it's possible.

#

would also explain why there isnt any obvious flaw in code but weird behavior

sleek escarp
#

I remember why I never do stuff directly as root

mossy hemlock
#

for the mysql server i had to

#

it wouldnt allow to set up other users to have access without it.

#

I just got distracted and forgot I was still root when I continued working on the server 😅

#

and everything seemed normal so i forgot about it.