Give failsafe to api sending for drop
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
97dc81df9a
commit
476b9ad5f9
2 changed files with 35 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, CacheType, EmbedBuilder } from "discord.js";
|
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, CacheType, DiscordAPIError, EmbedBuilder } from "discord.js";
|
||||||
import { ButtonEvent } from "../type/buttonEvent";
|
import { ButtonEvent } from "../type/buttonEvent";
|
||||||
import CardDropHelper from "../helpers/CardDropHelper";
|
import CardDropHelper from "../helpers/CardDropHelper";
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
|
@ -41,11 +41,22 @@ export default class Reroll extends ButtonEvent {
|
||||||
.setLabel("Reroll")
|
.setLabel("Reroll")
|
||||||
.setStyle(ButtonStyle.Secondary));
|
.setStyle(ButtonStyle.Secondary));
|
||||||
|
|
||||||
await interaction.reply({
|
try {
|
||||||
embeds: [ embed ],
|
await interaction.editReply({
|
||||||
files: [ attachment ],
|
embeds: [ embed ],
|
||||||
components: [ row ],
|
files: [ attachment ],
|
||||||
});
|
components: [ row ],
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
|
||||||
|
|
||||||
|
if (e instanceof DiscordAPIError) {
|
||||||
|
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
|
||||||
|
} else {
|
||||||
|
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: UNKNOWN`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CoreClient.ClaimId = claimId;
|
CoreClient.ClaimId = claimId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, DiscordAPIError, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
import CardDropHelper from "../helpers/CardDropHelper";
|
import CardDropHelper from "../helpers/CardDropHelper";
|
||||||
import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
|
import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
|
||||||
|
@ -49,11 +49,23 @@ export default class Drop extends Command {
|
||||||
.setLabel("Reroll")
|
.setLabel("Reroll")
|
||||||
.setStyle(ButtonStyle.Secondary));
|
.setStyle(ButtonStyle.Secondary));
|
||||||
|
|
||||||
await interaction.editReply({
|
try {
|
||||||
embeds: [ embed ],
|
await interaction.editReply({
|
||||||
files: [ attachment ],
|
embeds: [ embed ],
|
||||||
components: [ row ],
|
files: [ attachment ],
|
||||||
});
|
components: [ row ],
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
|
||||||
|
|
||||||
|
if (e instanceof DiscordAPIError) {
|
||||||
|
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
|
||||||
|
} else {
|
||||||
|
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: UNKNOWN`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CoreClient.ClaimId = claimId;
|
CoreClient.ClaimId = claimId;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue