mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
Merge pull request #84 from tekulvw/reload-fix
reload fix for name import issues
This commit is contained in:
commit
5ef59335f2
9
red.py
9
red.py
@ -12,6 +12,7 @@ import time
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import importlib
|
||||||
|
|
||||||
#
|
#
|
||||||
# Red, a Discord bot by Twentysix, based on discord.py and its command extension
|
# Red, a Discord bot by Twentysix, based on discord.py and its command extension
|
||||||
@ -91,7 +92,9 @@ async def load(*, module : str):
|
|||||||
return
|
return
|
||||||
set_cog(module, True)
|
set_cog(module, True)
|
||||||
try:
|
try:
|
||||||
bot.load_extension(module)
|
mod_obj = importlib.import_module(module)
|
||||||
|
importlib.reload(mod_obj)
|
||||||
|
bot.load_extension(mod_obj.__name__)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await bot.say('{}: {}'.format(type(e).__name__, e))
|
await bot.say('{}: {}'.format(type(e).__name__, e))
|
||||||
else:
|
else:
|
||||||
@ -130,7 +133,9 @@ async def _reload(*, module : str):
|
|||||||
set_cog(module, True)
|
set_cog(module, True)
|
||||||
try:
|
try:
|
||||||
bot.unload_extension(module)
|
bot.unload_extension(module)
|
||||||
bot.load_extension(module)
|
mod_obj = importlib.import_module(module)
|
||||||
|
importlib.reload(mod_obj)
|
||||||
|
bot.load_extension(mod_obj.__name__)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await bot.say('\U0001f52b')
|
await bot.say('\U0001f52b')
|
||||||
await bot.say('{}: {}'.format(type(e).__name__, e))
|
await bot.say('{}: {}'.format(type(e).__name__, e))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user