# Make sure you don't have a command called "commands" @client.command() @commands.is_owner() # Makes sure the person running the command is the owner async def restart(): for filename in os.listdir("./cogs"): # Change "cogs" to your folder name if filename.endswith(".py"): client.reload_extension(f"cogs.{filename[:-3]}") # Change "cogs" to your folder name
Here is what the above code is Doing:
1. It loops through all the files in the cogs folder
2. It checks if the file ends with .py
3. It reloads the extension