I'm trying to make a command where it loads a certain cog I created in a "cogs" folder
I've looked through the docs & interwebs (as usual) but nothing worked for me, I might've been doing it wrong or something maybe?
The code is pretty simple but should still work
import discord
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions
import os
client = commands.Bot(command_prefix=commands.when_mentioned_or('.'))
@client.event
async def on_ready():
print ("Bot is online!")
for filename in os.listdir(f"./cogs"):
if filename.endswith(f".py"):
client.load_extension(f"cogs.{filename[:-3]}")
@client.command()
@has_permissions(administrator=True)
async def unloadchat(ctx, extension):
client.unload_extension("cogs.chat")
await ctx.send('Unloaded the "chat" module :thumbsup: ')
client.run('TOKEN')
This isn't the whole bot of course but it's what I'm trying to do, & yes I added in the token, just not making it public
on_ready? Try adding a print inside the loop that prints all the filenames, to make sure you're in the right directory. Try sticking a print insetupincogs.chatto make sure it's being called. - Patrick Haughforis the start of a loop. - Patrick Haugh