My discord bot is connected to my discord server and all the commands seem to run as intended. As I try to use the load or unload commands, it gives me an error saying "Command raised an exception: ExtensionNotFound: Extension 'cogs.commands' could not be loaded." I have no idea why it says that they aren't loaded yet the commands an events still run that are in the extensions. I have already tried rewriting what I had for the load and unload commands, I tried renaming the extensions to 'Events' and 'Commands'. I am only a beginner and I am thinking I wrote something wrong.Here are the load, unload, reload and setup commands.
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
print(f'{extension} successfully loaded')
# cog unloader command
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
print(f'{extension} successfully unloaded')
# cog reloader command, unload then load extenion
@client.command()
async def reload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
client.load_extension(f'cogs.{extension}')
print(f'{extension} successfully re-loaded')
# for loop to find cogs folder
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
Here is the other file containing the events and commands that I currently have written as the extension.
from discord.ext import commands
# --EVENTS--
class Events(commands.Cog):
def __init__(self, client):
self.client = client
# Bot online event
@commands.Cog.listener()
async def on_ready(self):
print('GuhBot v3 is online and ready! C:')
# Member joined Event
@commands.Cog.listener()
async def on_member_join(self, member):
print(f'{member} joined the server. C:')
# Member left Event
@commands.Cog.listener()
async def on_member_remove(self, member):
print(f'{member} left the server. :C')
# --MODERATION--
class Moderation(commands.Cog):
def __init__(self, client):
self.client = client
# clear command. default 5 messages, can be changed by user.
@commands.command()
async def clear(self, ctx, amount=5):
await ctx.channel.purge(limit=amount+1)
# Cog Setup
def setup(client):
client.add_cog(Events(client))
client.add_cog(Moderation(client))```