Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add reload cogs/unload/load #69

shndowbots started this conversation in Ideas
Sep 14, 2022 · 2 comments · 6 replies
Discussion options

Add reload, unload, and load cogs commands. This way, after making changes to a specific cog, you can just use /reload [cog_name] and it will reload, same for the other commands.

You must be logged in to vote

Replies: 2 comments 6 replies

Comment options

Fair point, not sure how well it handles hybrid/slash commands but worth a try 👍

You must be logged in to vote
6 replies
Comment options

 name="load",
 description="Load a cog",
 )
 @checks.is_owner()
 async def load(self, ctx, cog: str):
 try:
 self.bot.load_extension(f"cogs.normal.{cog}")
 except Exception as e:
 embed=discord.Embed(title="load", description=f"Could not load the `{cog}` cog.")
 await ctx.send(embed=embed)
 return
 embed=discord.Embed(title="Load", description=f"Successfully loaded the `{cog}` cog.")
 await ctx.send(embed=embed)
 @commands.hybrid_command(
 name="unload",
 description="Unloads a cog.",
 )
 @checks.is_owner()
 async def unload(self, ctx, cog: str):
 try:
 self.bot.unload_extension(f"cogs.normal.{cog}")
 except Exception as e:
 embed=discord.Embed(title="Unload", description=f"Could not unload the `{cog}` cog.")
 await ctx.send(embed=embed)
 return
 embed=discord.Embed(title="Unload", description=f"Successfully loaded the `{cog}` cog.")
 await ctx.send(embed=embed)
 @commands.hybrid_command(
 name="reload",
 description="Reloads a cog.",
 )
 @checks.is_owner()
 async def reload(self, ctx, cog: str):
 try:
 self.bot.unload_extension(f"cogs.normal.{cog}")
 self.cog.load_extension(f"cogs.normal.{cog}")
 except Exception as e:
 embed=discord.Embed(title="Reload", description=f"Could not reload the `{cog}` cog.")
 await ctx.send(embed=embed)
 return
 embed=discord.Embed(title="Reload", description=f"Successfully reloaded the `{cog}` cog.")
 await ctx.send(embed=embed)```
Comment options

Feel free to submit a pull request with the changes if you wish, let me know.

Otherwise I will add them myself in a few days.

Comment options

okay, also I forgot to await it which is my fault on this one, I'll go submit one

Comment options

Fixed and submitted.

Comment options

Also added the comments that you usually add in each command.

Comment options

This is now part of the version 5.2 of the template 🎉

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
enhancement New feature or request done The new feature or request has been implemented

AltStyle によって変換されたページ (->オリジナル) /