Probably late to this questions, but I will post it anyways
You should checkout how so called "Cogs" work in Discord.py. The bot from Rapptz (the guy who main-maintain Discord.py) has some good examples how to organize your bot into Cogs and how to load/unload/reload them (see cogs/admin.py
for that).
@commands.command(hidden=True)
@checks.is_owner()
async def load(self, *, module : str):
"""Loads a module."""
try:
self.bot.load_extension(module)
except Exception as e:
await self.bot.say('\N{PISTOL}')
await self.bot.say('{}: {}'.format(type(e).__name__, e))
else:
await self.bot.say('\N{OK HAND SIGN}')
@commands.command(hidden=True)
@checks.is_owner()
async def unload(self, *, module : str):
"""Unloads a module."""
try:
self.bot.unload_extension(module)
except Exception as e:
await self.bot.say('\N{PISTOL}')
await self.bot.say('{}: {}'.format(type(e).__name__, e))
else:
await self.bot.say('\N{OK HAND SIGN}')
@commands.command(name='reload', hidden=True)
@checks.is_owner()
async def _reload(self, *, module : str):
"""Reloads a module."""
try:
self.bot.unload_extension(module)
self.bot.load_extension(module)
except Exception as e:
await self.bot.say('\N{PISTOL}')
await self.bot.say('{}: {}'.format(type(e).__name__, e))
else:
await self.bot.say('\N{OK HAND SIGN}')
(Snippet from cogs/admin.py
)