|
2 | 2 |
|
3 | 3 | import inspect
|
4 | 4 | from contextlib import suppress
|
5 |
| -from typing import TYPE_CHECKING, Any, final |
| 5 | +from typing import TYPE_CHECKING, final |
6 | 6 |
|
7 | 7 | import discord as dc
|
8 | 8 | from discord.app_commands import Choice
|
@@ -35,17 +35,23 @@ async def existing_extension_autocomplete(
|
35 | 35 | key=lambda x: x.name,
|
36 | 36 | )[:25]
|
37 | 37 |
|
38 |
| - @commands.command(name="sync", description="Sync command tree.") |
39 |
| - async def sync(self, ctx: commands.Context[Any]) -> None: |
40 |
| - if not self.bot.is_ghostty_mod(ctx.author): |
| 38 | + @commands.Cog.listener() |
| 39 | + async def on_message(self, message: dc.Message) -> None: |
| 40 | + # Handle !sync command. This can't be a slash command because this command is |
| 41 | + # the one that actually adds the slash commands in the first place. |
| 42 | + if message.content.strip() != "!sync": |
| 43 | + return |
| 44 | + |
| 45 | + if not self.bot.is_ghostty_mod(message.author): |
41 | 46 | logger.debug(
|
42 |
| - "!sync called by {} who is not a mod", pretty_print_account(ctx.author) |
| 47 | + "!sync called by {} who is not a mod", |
| 48 | + pretty_print_account(message.author), |
43 | 49 | )
|
44 | 50 | return
|
45 | 51 |
|
46 | 52 | logger.info("syncing command tree")
|
47 | 53 | await self.bot.tree.sync()
|
48 |
| - await try_dm(ctx.author, "Command tree synced.") |
| 54 | + await try_dm(message.author, "Command tree synced.") |
49 | 55 |
|
50 | 56 | @dc.app_commands.command(name="status", description="View Ghostty Bot's status.")
|
51 | 57 | @dc.app_commands.guild_only()
|
|
0 commit comments