1
0
mirror of https://gitlab.com/ddorn/tfjm-discord-bot.git synced 2024-12-26 05:42:21 +00:00

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

View File

@ -1,10 +1,9 @@
import asyncio
import code
from pprint import pprint
import discord
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 ptpython.repl import embed
@ -12,6 +11,7 @@ from src.constants import *
from src.core import CustomBot
COGS_SHORTCUTS = {
"c": "src.constants",
"d": "tirages",
"e": "errors",
"m": "misc",
@ -20,8 +20,6 @@ COGS_SHORTCUTS = {
"v": "dev",
}
KeyboardInterrupt
class DevCog(Cog, name="Dev tools"):
def __init__(self, bot: CustomBot):
@ -86,19 +84,18 @@ class DevCog(Cog, name="Dev tools"):
await ctx.send(":tada: The bot was reloaded !")
return
names = [name] if name else list(COGS_SHORTCUTS.values())
name = self.full_cog_name(name)
for name in names:
name = self.full_cog_name(name)
try:
self.bot.reload_extension(name)
except:
await ctx.send(f":grimacing: **{name}** n'a pas pu être rechargée.")
raise
else:
await ctx.send(f":tada: L'extension **{name}** a bien été rechargée.")
try:
self.bot.reload_extension(name)
except ExtensionNotLoaded:
await ctx.invoke(self.load_cmd, name)
return
except:
await ctx.send(f":grimacing: **{name}** n'a pas pu être rechargée.")
raise
else:
await ctx.send(f":tada: L'extension **{name}** a bien été rechargée.")
@command(name="load", aliases=["l"])
@has_role(Role.DEV)