Skip to content

Commit

Permalink
feat: replying to a confession
Browse files Browse the repository at this point in the history
  • Loading branch information
howardt12345 committed Nov 22, 2023
1 parent 9559e30 commit 7d880e7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
22 changes: 20 additions & 2 deletions commands/confessions/confession.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def register_commands(
name="create",
description="Make an anonymous confession",
)
async def confess(interaction: discord.Interaction, confession: str):
@app_commands.describe(reply_to="The confession id to reply to")
async def confess(interaction: discord.Interaction, confession: str, reply_to: str = None):
"""Write an anonymous confession.
Args:
Expand All @@ -75,7 +76,24 @@ async def confess(interaction: discord.Interaction, confession: str):
confession_id = shortuuid.uuid()
embed = discord.Embed(title="Confession", description=confession)
embed.set_footer(text=f"confession id: {confession_id}{' (not logged, unable to report)' if not confession_logging_enabled else ''}")
confession_message = await confession_channel.send(embed=embed)

reply_to_message = None

if reply_to:
event_log_data = await logging.fetch_event_log(interaction.guild_id, reply_to, 'Confession')
if not event_log_data:
await interaction.response.send_message(
"That confession does not exist.", ephemeral=True
)
return

reply_to_confession = event_log_data[0]
reply_to_id = reply_to_confession["message_id"]
reply_to_message = await confession_channel.fetch_message(reply_to_id)
embed.add_field(name="Replying to", value=f"[Confession {reply_to}](https://discord.com/channels/{interaction.guild_id}/{confession_channel.id}/{reply_to_id})")


confession_message = await confession_channel.send(embed=embed, reference=reply_to_message)
confession_url = confession_message.jump_url

user_id = interaction.user.id
Expand Down
11 changes: 8 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ async def on_ready():
# when someone sends any message
@client.event
async def on_message(message: discord.Message):
message_reacts_enabled = client.guilds_dict[message.guild.id][
"message_reacts_enabled"
]
message_reacts_enabled = True
try:
message_reacts_enabled = client.guilds_dict[message.guild.id][
"message_reacts_enabled"
]
except:
# default true
pass

# don't respond to bot's own posts or if message reacts are disabled
if message.author == client.user or not message_reacts_enabled:
Expand Down

0 comments on commit 7d880e7

Please sign in to comment.