Skip to content

Commit

Permalink
Update app.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Aug 4, 2024
1 parent 994bce2 commit 4b2cb71
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions lib/api/discord/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: `Error: ${error.message}`,
flags: MessageFlags.Ephemeral,
},
};
}
},
async sync(interaction) {
const syncResponse = await leaderboardClient.sync(
Expand Down

0 comments on commit 4b2cb71

Please sign in to comment.