Skip to content

Commit

Permalink
safty around reload cogs.utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mralext20 committed Sep 7, 2017
1 parent ce53da7 commit 82c2e75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cogs/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ async def shell(self, ctx, *, cmd):
result = await run_subprocess(cmd)
await ctx.send(f'```{result}```')

@commands.command()
@commands.is_owner()
async def reloadutils(self,ctx):
try:
self.bot.unload_extension("cogs.utils")
self.bot.load_extension("cogs.utils")
except Exception as e:
await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}')
else:
await ctx.send('**`SUCCESS`**')


def setup(bot):
bot.add_cog(Exec(bot))
4 changes: 3 additions & 1 deletion cogs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Utils(Cog):
async def cog_reload(self, ctx, *, cog: str):
"""Command which Reloads a Module.
Remember to use dot path. e.g: cogs.owner"""

if cog == "cogs.utils":
ctx.send("im sorry, i cant reload myself for safety reasons.")
return
try:
self.bot.unload_extension(cog)
self.bot.load_extension(cog)
Expand Down

0 comments on commit 82c2e75

Please sign in to comment.