Added error checking to view the errors on loading, unloading modules
This commit is contained in:
parent
0ca881d7cd
commit
d45b3d4ff2
44
cogs/mod.py
44
cogs/mod.py
|
@ -26,32 +26,44 @@ class Mod:
|
||||||
@checks.isAdmin()
|
@checks.isAdmin()
|
||||||
async def load(self, *, module : str):
|
async def load(self, *, module : str):
|
||||||
"""Loads a module"""
|
"""Loads a module"""
|
||||||
if not len(module) > 0:
|
try:
|
||||||
await self.bot.say("Please provide a module!")
|
if not len(module) > 0:
|
||||||
return
|
await self.bot.say("Please provide a module!")
|
||||||
self.bot.load_extension(module)
|
return
|
||||||
await self.bot.say("I have just loaded the {} module".format(module))
|
self.bot.load_extension(module)
|
||||||
|
await self.bot.say("I have just loaded the {} module".format(module))
|
||||||
|
except Exception as e:
|
||||||
|
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
|
||||||
|
await bot.say(fmt.format(type(e).__name__, e))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@checks.isAdmin()
|
@checks.isAdmin()
|
||||||
async def unload(self, *, module : str):
|
async def unload(self, *, module : str):
|
||||||
"""Unloads a module"""
|
"""Unloads a module"""
|
||||||
if not len(module) > 0:
|
try:
|
||||||
await self.bot.say("Please provide a module!")
|
if not len(module) > 0:
|
||||||
return
|
await self.bot.say("Please provide a module!")
|
||||||
self.bot.unload_extension(module)
|
return
|
||||||
await self.bot.say("I have just unloaded the {} module".format(module))
|
self.bot.unload_extension(module)
|
||||||
|
await self.bot.say("I have just unloaded the {} module".format(module))
|
||||||
|
except Exception as e:
|
||||||
|
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
|
||||||
|
await bot.say(fmt.format(type(e).__name__, e))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@checks.isAdmin()
|
@checks.isAdmin()
|
||||||
async def reload(self, *, module : str):
|
async def reload(self, *, module : str):
|
||||||
"""Reloads a module"""
|
"""Reloads a module"""
|
||||||
if not len(module) > 0:
|
try:
|
||||||
await self.bot.say("Please provide a module!")
|
if not len(module) > 0:
|
||||||
return
|
await self.bot.say("Please provide a module!")
|
||||||
self.bot.unload_extension(module)
|
return
|
||||||
self.bot.load_extension(module)
|
self.bot.unload_extension(module)
|
||||||
await self.bot.say("I have just reloaded the {} module".format(module))
|
self.bot.load_extension(module)
|
||||||
|
await self.bot.say("I have just reloaded the {} module".format(module))
|
||||||
|
except Exception as e:
|
||||||
|
fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```'
|
||||||
|
await bot.say(fmt.format(type(e).__name__, e))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
Loading…
Reference in a new issue