Skip to content

Commit

Permalink
Fix: serialization crash (#989)
Browse files Browse the repository at this point in the history
* fix: serialization crash

* chore: replace deprecated builder

* fix: select staying despite error
  • Loading branch information
geisterfurz007 authored Jun 12, 2023
1 parent c629771 commit 74899a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ declare namespace NodeJS {
YTF_API_AUTH_TOKEN: string;
}
}

interface BigInt {
toJSON: () => string;
}
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ bot.on(

//! ================= /EVENT HANDLERS ===================

BigInt.prototype.toJSON = function () {
return this.toString();
};

process.on("uncaughtException", (error, origin) => {
Sentry.captureException(error, { level: "fatal" });
});
Expand Down
14 changes: 8 additions & 6 deletions src/programs/birthday-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ChatInputCommandInteraction,
ComponentType,
GuildMemberRoleManager,
SelectMenuBuilder,
StringSelectMenuBuilder,
SelectMenuInteraction,
} from "discord.js";
import { CountryRoleFinder } from "../common/country-role-finder";
Expand Down Expand Up @@ -86,9 +86,11 @@ class BirthdayManager implements CommandHandler<DiscordEvent.SLASH_COMMAND> {
try {
timezoneSelection = await getUserTimezoneSelection(interaction);
} catch (err) {
await interaction.editReply(
"Hmm, something went wrong. Please contact my engineers if this seems unreasonable. :nerd:"
);
await interaction.editReply({
content:
"Hmm, something went wrong. Please contact my engineers if this seems unreasonable. :nerd:",
components: [],
});
return;
}

Expand Down Expand Up @@ -162,13 +164,13 @@ async function getUserTimezoneSelection(

return { value: tz, label: tz, description: currentTimeString };
});
const textSelect = new SelectMenuBuilder({
const textSelect = new StringSelectMenuBuilder({
placeholder: "Pick your timezone",
customId: timezoneSelectId,
options,
});

const components = new ActionRowBuilder<SelectMenuBuilder>({
const components = new ActionRowBuilder<StringSelectMenuBuilder>({
components: [textSelect],
});
const response = await interaction.reply({
Expand Down

0 comments on commit 74899a4

Please sign in to comment.