Skip to content

Commit 5f965c0

Browse files
authored
Disable the command prefix (#386)
2 parents 5cfc15c + eb024e1 commit 5f965c0

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

app/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, config: Config, gh: GitHub[TokenAuthStrategy]) -> None:
4646
intents.members = True
4747
intents.message_content = True
4848
super().__init__(
49-
command_prefix=commands.when_mentioned_or("!"),
49+
command_prefix=[],
5050
intents=intents,
5151
allowed_mentions=dc.AllowedMentions(everyone=False, roles=False),
5252
)

app/components/developer.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import inspect
44
from contextlib import suppress
5-
from typing import TYPE_CHECKING, Any, final
5+
from typing import TYPE_CHECKING, final
66

77
import discord as dc
88
from discord.app_commands import Choice
@@ -35,17 +35,23 @@ async def existing_extension_autocomplete(
3535
key=lambda x: x.name,
3636
)[:25]
3737

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):
4146
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),
4349
)
4450
return
4551

4652
logger.info("syncing command tree")
4753
await self.bot.tree.sync()
48-
await try_dm(ctx.author, "Command tree synced.")
54+
await try_dm(message.author, "Command tree synced.")
4955

5056
@dc.app_commands.command(name="status", description="View Ghostty Bot's status.")
5157
@dc.app_commands.guild_only()

0 commit comments

Comments
 (0)