Skip to content

Commit

Permalink
fix: 🚸 enforce DM usage for message commands
Browse files Browse the repository at this point in the history
  • Loading branch information
TheManchineel committed Dec 2, 2024
1 parent 1e426df commit 5c70150
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion super_secret_santa/bot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import discord

bot = discord.Bot()
bot: discord.Bot = discord.Bot()
17 changes: 17 additions & 0 deletions super_secret_santa/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,19 @@ async def delete(ctx: ApplicationContext):
@santa_command_group.command()
async def message(ctx: ApplicationContext, message: str):
"""Send a message to your giftee, whom you must get a gift for (NOT your Secret Santa)"""
if ctx.guild is not None:
await ctx.respond(
f"This command can only be used in a DM! Send your command in a message to {bot.user.mention}",
ephemeral=True,
delete_after=constants.DELETE_AFTER_DELAY,
)
return

await ctx.defer(ephemeral=True)
# we need to find out all started campaigns the Member is part of, where `giftee` is not NULL
async with get_connection() as conn:
cur = conn.cursor()

await cur.execute(
"""
SELECT m.guild_id, g.user_id, c.name
Expand Down Expand Up @@ -158,6 +167,14 @@ async def message(ctx: ApplicationContext, message: str):
@santa_command_group.command()
async def messagex(ctx: ApplicationContext, number: int, message: str):
"""Send a message to your giftee, whom you must get a gift for (NOT your Secret Santa)"""
if ctx.guild is not None:
await ctx.respond(
f"This command can only be used in a DM! Send your command in a message to {bot.user.mention}",
ephemeral=True,
delete_after=constants.DELETE_AFTER_DELAY,
)
return

await ctx.defer(ephemeral=True)
# we need to find out all started campaigns the Member is part of, where `giftee` is not NULL
async with get_connection() as conn:
Expand Down

0 comments on commit 5c70150

Please sign in to comment.