diff --git a/gateway/platforms/discord.py b/gateway/platforms/discord.py index 51ef0a868..a80790ed5 100644 --- a/gateway/platforms/discord.py +++ b/gateway/platforms/discord.py @@ -1696,6 +1696,10 @@ class DiscordAdapter(BasePlatformAdapter): async def slash_update(interaction: discord.Interaction): await self._run_simple_slash(interaction, "/update", "Update initiated~") + @tree.command(name="restart", description="Gracefully restart the Hermes gateway") + async def slash_restart(interaction: discord.Interaction): + await self._run_simple_slash(interaction, "/restart", "Restart requested~") + @tree.command(name="approve", description="Approve a pending dangerous command") @discord.app_commands.describe(scope="Optional: 'all', 'session', 'always', 'all session', 'all always'") async def slash_approve(interaction: discord.Interaction, scope: str = ""): diff --git a/tests/gateway/test_discord_slash_commands.py b/tests/gateway/test_discord_slash_commands.py index b7967c69a..c1c3c1df1 100644 --- a/tests/gateway/test_discord_slash_commands.py +++ b/tests/gateway/test_discord_slash_commands.py @@ -117,6 +117,23 @@ async def test_registers_native_thread_slash_command(adapter): adapter._handle_thread_create_slash.assert_awaited_once_with(interaction, "Planning", "", 1440) +@pytest.mark.asyncio +async def test_registers_native_restart_slash_command(adapter): + adapter._run_simple_slash = AsyncMock() + adapter._register_slash_commands() + + assert "restart" in adapter._client.tree.commands + + interaction = SimpleNamespace() + await adapter._client.tree.commands["restart"](interaction) + + adapter._run_simple_slash.assert_awaited_once_with( + interaction, + "/restart", + "Restart requested~", + ) + + # ------------------------------------------------------------------ # _handle_thread_create_slash — success, session dispatch, failure # ------------------------------------------------------------------