From d5b95c2f9cd390a7e8236d05b61d89568eadaeae Mon Sep 17 00:00:00 2001 From: EthanThatOneKid <31261035+EthanThatOneKid@users.noreply.github.com> Date: Sat, 3 Aug 2024 23:17:33 -0700 Subject: [PATCH] Update app.ts --- lib/api/discord/app.ts | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/api/discord/app.ts b/lib/api/discord/app.ts index 024f0a7..9402b34 100644 --- a/lib/api/discord/app.ts +++ b/lib/api/discord/app.ts @@ -96,17 +96,28 @@ export function makeDiscordAppHandler( }; } - const unregisterResponse = await leaderboardClient.unregister( - interaction.user!.id, - ); - return { - type: InteractionResponseType.ChannelMessageWithSource, - data: { - content: `Your Leetcode username was ${ - unregisterResponse.ok ? "unregistered" : "not unregistered" - }.`, - }, - }; + try { + const unregisterResponse = await leaderboardClient.unregister( + interaction.user!.id, + ); + + return { + type: InteractionResponseType.ChannelMessageWithSource, + data: { + content: `Your Leetcode username was ${ + unregisterResponse.ok ? "unregistered" : "not unregistered" + }.`, + }, + }; + } catch (error) { + return { + type: InteractionResponseType.ChannelMessageWithSource, + data: { + content: `Testing in prod: ${error.message}`, + flags: MessageFlags.Ephemeral, + }, + }; + } }, async sync(interaction) { const syncResponse = await leaderboardClient.sync(