shortcut to reload constants + reload fallback to load

This commit is contained in:
ddorn 2020-05-04 16:18:09 +02:00
parent 7dd6ed2273
commit 184596870b
1 changed files with 13 additions and 16 deletions

View File

@ -1,10 +1,9 @@
import asyncio import asyncio
import code
from pprint import pprint from pprint import pprint
import discord import discord
from discord import TextChannel, PermissionOverwrite from discord import TextChannel, PermissionOverwrite
from discord.ext.commands import command, has_role, Bot, Cog from discord.ext.commands import command, has_role, Bot, Cog, ExtensionNotLoaded
from discord.utils import get from discord.utils import get
from ptpython.repl import embed from ptpython.repl import embed
@ -12,6 +11,7 @@ from src.constants import *
from src.core import CustomBot from src.core import CustomBot
COGS_SHORTCUTS = { COGS_SHORTCUTS = {
"c": "src.constants",
"d": "tirages", "d": "tirages",
"e": "errors", "e": "errors",
"m": "misc", "m": "misc",
@ -20,8 +20,6 @@ COGS_SHORTCUTS = {
"v": "dev", "v": "dev",
} }
KeyboardInterrupt
class DevCog(Cog, name="Dev tools"): class DevCog(Cog, name="Dev tools"):
def __init__(self, bot: CustomBot): def __init__(self, bot: CustomBot):
@ -86,14 +84,13 @@ class DevCog(Cog, name="Dev tools"):
await ctx.send(":tada: The bot was reloaded !") await ctx.send(":tada: The bot was reloaded !")
return return
names = [name] if name else list(COGS_SHORTCUTS.values())
for name in names:
name = self.full_cog_name(name) name = self.full_cog_name(name)
try: try:
self.bot.reload_extension(name) self.bot.reload_extension(name)
except ExtensionNotLoaded:
await ctx.invoke(self.load_cmd, name)
return
except: except:
await ctx.send(f":grimacing: **{name}** n'a pas pu être rechargée.") await ctx.send(f":grimacing: **{name}** n'a pas pu être rechargée.")
raise raise