From 5870a74a6b6fdb9e3d059d6d132a221bd69a5d75 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Mon, 13 May 2024 17:54:00 +0100 Subject: Check length of nomination reason before attempting to send to site API This ensures we will not attempt to send a reason that is longer than the REASON_MAX_CHARS value, which can quickly be reached through the addition of message links in context. --- bot/exts/recruitment/talentpool/_cog.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bot/exts/recruitment/talentpool/_cog.py b/bot/exts/recruitment/talentpool/_cog.py index ad232df8c..5b9958d52 100644 --- a/bot/exts/recruitment/talentpool/_cog.py +++ b/bot/exts/recruitment/talentpool/_cog.py @@ -432,6 +432,13 @@ class TalentPool(Cog, name="Talentpool"): reason += f"\n\n{message.jump_url}" + if len(reason) > REASON_MAX_CHARS: + await interaction.response.send_message( + ":x: Cannot add additional context due to nomination reason character limit.", + ephemeral=True + ) + return + await self.api.edit_nomination_entry( nomination.id, actor_id=interaction.user.id, -- cgit v1.2.3