#One specific cog won't load!?
1 messages · Page 1 of 1 (latest)
I didn't save it unfortunately
^
Hi
I have this error
this is my client
this is the error
when i try to load cogs
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.
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!!
im sure its @discord.has_permissions
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
inside your main file, when are you loading the cog?
also slash commands don't have the hidden attribute
which might be breaking it
Are you using 2.0?
i load them as the file runs, not really anywhere specific. just before doing the token
im aware, this is very lightly changed from before they were slash commands. but it worked on different cogs without changes
so before bot.run? and presumably not inside a function like on_ready
updated it today, so would think so?
yes
Ok well
You need to use this
When setting up your cog
Trying adding async in front of the def setup
can you tell if the cog manages to load at all?
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
you can view loaded cogs via bot.cogs
so the cog itself is failing
ye
load extension raises an error if a cog fails, so could you try catching and printing it?
how would i catch it?
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
no error
but it still didn't load..?
nope
what about py import traceback try: bot.load_extension(cog) except: traceback.print_exc()
nothing
odd...
very
just checking, can you print discord.__version__
Ooh, this is like a problem I'm having. Just gonna lurk and see if you come up with anything <_<
i'll see if it loads on my end
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
Hmm curious
something i probs should have tried hours ago
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.
I think they did some recent updates to the library
"Well, there's this feature I could be using, but damn, that's learning something too." lol
oh nice
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
##1502
Probably this
oh i see
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
ah yeah
so set store=False in load_extension
...rather unintuitive design change though
@craggy lichen @sacred mulch guy im having this exact problem. what was the cause and solution? (sry for ping)
Is it a slash command group not registering?
My issue was that a group wasn't registering, so I reverted to 2.0.0rc1
Do a full uninstall. Of 2.0.0 first
@robust granite wait wait wait how are you loading the cogs?
bro it worked
wtf
hmm
weird af
it was there in my original post
I agree there đź‘€
@robust granite and where does that code run when the bot loads
Does it load under on ready
come in that post ill explain there
this is the solution
yeah but that was raising an error that couldn’t describe the issue
and now im unable to reproduce the bug
🤷‍♂️