feat(commands:update|Admin): add update command

This commit is contained in:
Romain J 2021-05-16 17:40:42 +02:00
parent fd0600b75d
commit 82b8fb9814
2 changed files with 22 additions and 8 deletions

View file

@ -1,11 +1,10 @@
import logging import logging
from discord.ext import commands from discord.ext import commands
from jishaku.models import copy_context_with
from tuxbot.core.utils import checks from tuxbot.core.utils import checks
from tuxbot.core.bot import Tux from tuxbot.core.bot import Tux
from tuxbot.core.config import set_for_key
from tuxbot.core.config import Config
from tuxbot.core.i18n import ( from tuxbot.core.i18n import (
Translator, Translator,
) )
@ -22,11 +21,6 @@ class Admin(commands.Cog):
def __init__(self, bot: Tux): def __init__(self, bot: Tux):
self.bot = bot self.bot = bot
async def _save_lang(self, ctx: ContextPlus, lang: str):
set_for_key(
self.bot.config.Servers, ctx.guild.id, Config.Server, locale=lang
)
# ========================================================================= # =========================================================================
# ========================================================================= # =========================================================================
@ -41,3 +35,23 @@ class Admin(commands.Cog):
async def _restart(self, ctx: ContextPlus): async def _restart(self, ctx: ContextPlus):
await ctx.send("*restart...*") await ctx.send("*restart...*")
await self.bot.shutdown(restart=True) await self.bot.shutdown(restart=True)
@command_extra(name="update", deletable=False)
@checks.is_owner()
async def _update(self, ctx: ContextPlus):
sh = "jsk sh"
git = f"{sh} git pull"
update = f"{sh} make update"
git_command_ctx = await copy_context_with(
ctx, content=ctx.prefix + git
)
update_command_ctx = await copy_context_with(
ctx, content=ctx.prefix + update
)
await git_command_ctx.command.invoke(git_command_ctx)
await update_command_ctx.command.invoke(update_command_ctx)
await self._restart(ctx)

File diff suppressed because one or more lines are too long