diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8fce603 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +data/ diff --git a/Dockerfile b/Dockerfile index 3d6ba34..76d8015 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ RUN pip install --no-cache-dir poetry && \ pip cache purge COPY . . -RUN rm -rf .venv ENV LANG=en_US.UTF-8 ENV LC_ALL=en_US.UTF-8 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 11a3706..0c2ec22 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -3,6 +3,14 @@ services: build: . container_name: lumi-core restart: always + develop: + watch: + - action: sync + path: . + target: /usr/src/app/ + ignore: + - .venv/ + - data/ env_file: - path: ./.env required: true diff --git a/locales/strings.en-US.json b/locales/strings.en-US.json index 2470c31..fdc0132 100644 --- a/locales/strings.en-US.json +++ b/locales/strings.en-US.json @@ -145,6 +145,7 @@ "daily_success_claim_description": "you claimed your reward of **${0}**!", "default_level_up_message": "**{0}** you have reached **Level {1}**.", "dev_clear_tree": "The application command tree has been cleared.", + "dev_stop_note": "Stopping the bot...\n-# Note: if Luminara is running with Docker Compose, this will restart the container.", "dev_sync_tree": "The application command tree has been synced.", "error_actionable_hierarchy_bot": "I don't have permission to perform this action on this user due to role hierarchy.", "error_actionable_hierarchy_user": "you don't have permission to perform this action on this user due to role hierarchy.", diff --git a/modules/admin/dev.py b/modules/admin/dev.py index 9591290..a7ddb0f 100644 --- a/modules/admin/dev.py +++ b/modules/admin/dev.py @@ -2,20 +2,24 @@ import discord from discord.ext import commands import lib.format +from lib.client import Luminara from lib.const import CONST class Dev(commands.Cog): - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Luminara): self.bot = bot self.sync.usage = lib.format.generate_usage(self.sync) self.clear.usage = lib.format.generate_usage(self.clear) + self.stop.usage = lib.format.generate_usage(self.stop) @commands.group(name="dev", description="Lumi developer commands") @commands.guild_only() @commands.is_owner() - async def dev(self, ctx: commands.Context[commands.Bot]) -> None: - pass + async def dev(self, ctx: commands.Context[Luminara]) -> None: + """ + Luminara developer commands + """ @dev.command( name="sync_tree", @@ -23,7 +27,7 @@ class Dev(commands.Cog): ) async def sync( self, - ctx: commands.Context[commands.Bot], + ctx: commands.Context[Luminara], guild: discord.Guild | None = None, ) -> None: """ @@ -49,7 +53,7 @@ class Dev(commands.Cog): ) async def clear( self, - ctx: commands.Context[commands.Bot], + ctx: commands.Context[Luminara], guild: discord.Guild | None = None, ) -> None: """ @@ -65,6 +69,27 @@ class Dev(commands.Cog): await ctx.send(content=CONST.STRINGS["dev_clear_tree"]) + @dev.command( + name="stop", + usage="dev stop", + ) + @commands.is_owner() + async def stop( + self, + ctx: commands.Context[Luminara], + ) -> None: + """ + Stops the bot. If Tux is running with Docker Compose, this will restart the container. -async def setup(bot: commands.Bot) -> None: + Parameters + ---------- + ctx : commands.Context + The context in which the command is being invoked. + """ + + await ctx.reply(CONST.STRINGS["dev_stop_note"]) + await self.bot.shutdown() + + +async def setup(bot: Luminara) -> None: await bot.add_cog(Dev(bot)) diff --git a/modules/misc/ping.py b/modules/misc/ping.py index 746830b..2f38296 100644 --- a/modules/misc/ping.py +++ b/modules/misc/ping.py @@ -13,7 +13,7 @@ class Ping(commands.Cog): @commands.hybrid_command(name="ping") async def ping(self, ctx: commands.Context[commands.Bot]) -> None: """ - Ping command. + Show Luminara's latency. Parameters ----------