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(