-
Notifications
You must be signed in to change notification settings - Fork 356
Add reload cogs/unload/load #69
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 6 replies
-
Fair point, not sure how well it handles hybrid/slash commands but worth a try 👍
Beta Was this translation helpful? Give feedback.
All reactions
-
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)```
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
okay, also I forgot to await it which is my fault on this one, I'll go submit one
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
-
Fixed and submitted.
Beta Was this translation helpful? Give feedback.
All reactions
-
Also added the comments that you usually add in each command.
Beta Was this translation helpful? Give feedback.
All reactions
-
This is now part of the version 5.2 of the template 🎉
Beta Was this translation helpful? Give feedback.