Skip to content

Commit

Permalink
Merge pull request #69 from raphckrman/fix/interaction
Browse files Browse the repository at this point in the history
fix(interaction): emoji support fix
  • Loading branch information
pakkographic authored Aug 24, 2024
2 parents 293dec5 + 2a0ab5b commit 7386c63
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/util/InteractionOptionWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class InteractionOptionWrapper {
}
private getMentionOptions<T = string | number | boolean>(name: string, type: ApplicationCommandOptionType): { name: string; value: T; } | undefined {
if (!this.#data.applicationCommand) return;

const optionIndex =
this.#data.applicationCommand.options?.findIndex(opt =>
opt.name === name
Expand Down Expand Up @@ -127,8 +126,12 @@ export class InteractionOptionWrapper {
)
|| type === ApplicationCommandOptionType.EMOTE
&& typeof this.values[optionIndex] !== "string"
&& (
typeof this.values[optionIndex] !== "number"
|| this.values[optionIndex] > 9999999
|| this.values[optionIndex] < 1000000
)
) return;

if (type === ApplicationCommandOptionType.INTEGER)
this.values[optionIndex] = Math.trunc(Number(this.values[optionIndex]));
if (type === ApplicationCommandOptionType.EMBEDDED_ATTACHMENT) {
Expand All @@ -138,7 +141,7 @@ export class InteractionOptionWrapper {
}
if (type === ApplicationCommandOptionType.BOOLEAN)
this.values[optionIndex] = Boolean(this.values[optionIndex]);
if (type === ApplicationCommandOptionType.EMOTE) {
if (type === ApplicationCommandOptionType.EMOTE && typeof this.values[optionIndex] !== "number") {
const emoteID = Number((this.values[optionIndex] as string)?.match(/<:\w+:(\d+)>/)?.[1]);
if (isNaN(emoteID)) return;
this.values[optionIndex] = Number(emoteID);
Expand Down

0 comments on commit 7386c63

Please sign in to comment.