import os
import disnake
from disnake.ext import commands
bot = commands.Bot(command_prefix=".", help_command=None , intents=disnake.Intents.all())
@bot.command()
@commands.is_owner()
async def load(ctx, extension):
bot.load_extension(f"cogs.{extension}")
await ctx.send("Cogs id loaded...")
@bot.command()
@commands.is_owner()
async def unload(ctx, extension):
bot.unload_extension(f"cogs.{extension}")
await ctx.send("Cogs id inloaded...")
@bot.command()
@commands.is_owner()
async def reload(ctx, extension):
bot.unload_extension(f"cogs.{extension}")
bot.load_extension(f"cogs.{extension}")
await ctx.send("Cogs id reloaded...")
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}")
bot.run("")
I’m making a bot for my discord server and I’m using the disnake library, trying to make cogs and the part of the code that is responsible for entering the folder and uploading files is not responding
To fix this you could make a function where you put your code inside and then call the function on startup:
I haven't tested this but it should work for you.