#One specific cog won't load!?

1 messages · Page 1 of 1 (latest)

robust granite
robust granite
broken mantle
#

Hi

#

I have this error

#

this is my client

#

this is the error

#

when i try to load cogs

cedar rapids
# broken mantle Hi

Hello, please create your own thread for your issue. Read the seconds part of #help-rules for somewhat of a guide on how to do this.

craggy lichen
#

i made some bots ages ago on discord.py, and decided to change everything over to pycord recently. ran into a lot of problems, but got through them all. Except, for some reason, 1 of my cogs doesnt seem to load? or maybe the commands are hiding or something idk? i have a cog that houses all the admin-y stuff, and also houses the on_ready command. when i started converting, the on_ready command worked fine, then after touching slash commands (i think), the on_ready command stopped working, and i cant seem to use my purge command (which worked before being a slash command), it just doesnt show up. i checked if the on_ready worked if i coppied it to another cog, and it worked fine, so its a weird issue with the cog and no amount of googling seems to be helping me

#

before asking, here is the full code for the cog

import discord
from discord.ext import commands
import time


class Admin(commands.Cog, description="Module Of Commands Related To Moderation And Administration"):

    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        #change_status.start
        await self.bot.change_presence(status=discord.Status.online, activity=discord.Game("d!help For Help"))
        print('We have Connected To Server as {0.user}'.format(self.bot))

    @commands.Cog.listener()
    async def on_disconnect(self):
        print("We Have Disconnected From The Server")

    @commands.slash_command(description="Only I Can Use It So Buzz Off Nosey", hidden=True)
    @commands.is_owner()
    async def shutdown(self):
        await self.bot.change_presence(status=discord.Status.idle, activity=discord.Game("Down For Maintenance"))
        time.sleep(0.5)
        await self.bot.logout()

    @commands.slash_command(description="Mentions The User Multiple Times Bases On A Number Input")
    @commands.has_permissions(administrator=True)
    @commands.cooldown(1, 20, commands.BucketType.user)
    async def mention(self, ctx, member: discord.Member, amount=3):
        for x in range(amount):
            await ctx.respond(f"{member.mention} Get Your Ass Out Here Right Now!!")

    @commands.slash_command(description="Get Rid Of Dem Pesky Messages")
    @commands.has_permissions(administrator=True)
    async def purge(self, ctx, num):
        num = int(num)
        await ctx.channel.purge(limit=num)
        msg = await ctx.respond(f"Cleared {num} Messages")
        await msg.delete()

    @commands.slash_command(hidden=True)
    async def setspeed(self, ctx, seconds):
        await ctx.channel.edit(slowmode_delay=seconds)
        await ctx.message.delete()


def setup(bot):
    bot.add_cog(Admin(bot))
#

i also had the idea while posting this to see if my commands (mainly purge) worked if i moved them to other cogs, and they work just fine. im so confused!!

ruby apex
#

im sure its @discord.has_permissions

craggy lichen
#

like i said, worked without any changes when i moved it to a different cog. its just inside this admin cog

#

im fully aware there is stuff around permissions and hidden and stuff with slash commands, but that isnt the problem atm

static ether
#

also slash commands don't have the hidden attribute

#

which might be breaking it

craggy lichen
craggy lichen
static ether
#

so before bot.run? and presumably not inside a function like on_ready

craggy lichen
elder sedge
#

You need to use this

#

When setting up your cog

#

Trying adding async in front of the def setup

static ether
#

? cogs don't use an async setup

#

in pycord anyway

#

that's a dpy addition

elder sedge
#

Oh shoot I forgot

#

My bad lol

static ether
#

allgood

#

hmmmm

static ether
craggy lichen
#

i ran a print statement alongside it, and it found every file and said it loaded it without errors, so i dont really know?

#

i guess i can try run a print statement in the setup

static ether
#

you can view loaded cogs via bot.cogs

craggy lichen
#

kk

#

nope, loading them all but admin

static ether
#

so the cog itself is failing

craggy lichen
#

ye

static ether
#

load extension raises an error if a cog fails, so could you try catching and printing it?

craggy lichen
#

how would i catch it?

static ether
#

just wrap it in a try-except, something like py try: bot.load_extension(cog) except Exception as e: print(e) # or traceback.print_exc() if imported

craggy lichen
#

no error

static ether
#

but it still didn't load..?

craggy lichen
#

nope

static ether
#

what about py import traceback try: bot.load_extension(cog) except: traceback.print_exc()

craggy lichen
#

nothing

static ether
#

odd...

craggy lichen
#

very

static ether
#

just checking, can you print discord.__version__

craggy lichen
#

tried loading it manually, still nothing

sacred mulch
#

Ooh, this is like a problem I'm having. Just gonna lurk and see if you come up with anything <_<

static ether
#

i'll see if it loads on my end

craggy lichen
#

welp @sacred mulch i found a fix for me

#

i commented out the commands with hidden=true, and it has loaded. so it was an error causing it not to load the cog, just didnt give any error when prompted

sacred mulch
#

Hmm curious

craggy lichen
#

something i probs should have tried hours ago

sacred mulch
#

I did a bit more testing and it looks like mine is tied to the Slash Command Group I have set up

#

Might just post my own thread and see if anyone has thoughts.

craggy lichen
#

i couldnt get slash command groups working in my cogs

#

but i dont really care xd

sacred mulch
#

I think they did some recent updates to the library

sacred mulch
#

Big mood

craggy lichen
#

well, thanks @static ether for all the help.

#

you are a big smart

sacred mulch
#

"Well, there's this feature I could be using, but damn, that's learning something too." lol

static ether
#

oh nice

craggy lichen
#

idk who develops pycord, but maybe looking into why that didnt cause any errors to see might be useful?

#

if i got an error saying "slash command doesnt have an attribute hidden" it would have taken 2 seconds to fix xd

static ether
#

hmmm

#

to be honest, no matter what i do that cog file isn't loading for me either

proven flame
#

##1502
Probably this

simple raptorBOT
static ether
#

oh i see

craggy lichen
#

i will say, there was a second cog that wasnt loading either, but it just decided to load properly without me touching it and hasnt played up since. so that was weird

static ether
#

ah yeah

#

so set store=False in load_extension

#

...rather unintuitive design change though

robust granite
#

@craggy lichen @sacred mulch guy im having this exact problem. what was the cause and solution? (sry for ping)

sacred mulch
robust granite
#

i do have slash cmd groups in there

#

2 of them to be precise

sacred mulch
#

My issue was that a group wasn't registering, so I reverted to 2.0.0rc1

robust granite
#

oh

#

let me try

sacred mulch
#

Do a full uninstall. Of 2.0.0 first

surreal kettle
#

@robust granite wait wait wait how are you loading the cogs?

robust granite
#

wtf

#

hmm

#

weird af

robust granite
surreal kettle
#

I agree there đź‘€

#

@robust granite and where does that code run when the bot loads

#

Does it load under on ready

robust granite
static ether
robust granite
#

and now im unable to reproduce the bug

#

🤷‍♂️