Add guards to the drop and reroll commands in case the card fetcher fails (#449)
All checks were successful
Test / build (push) Successful in 44s
All checks were successful
Test / build (push) Successful in 44s
#446 Reviewed-on: #449 Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
parent
ecc879cf13
commit
ead53ba062
4 changed files with 40 additions and 9 deletions
|
@ -12,6 +12,7 @@ import CardConstants from "../constants/CardConstants";
|
|||
import ErrorMessages from "../constants/ErrorMessages";
|
||||
import GetCardsHelper from "../helpers/DropHelpers/GetCardsHelper";
|
||||
import DropEmbedHelper from "../helpers/DropHelpers/DropEmbedHelper";
|
||||
import {DropResult} from "../contracts/SeriesMetadata";
|
||||
|
||||
export default class Drop extends Command {
|
||||
constructor() {
|
||||
|
@ -48,9 +49,16 @@ export default class Drop extends Command {
|
|||
return;
|
||||
}
|
||||
|
||||
await user.Save(User, user);
|
||||
let randomCard: DropResult | undefined;
|
||||
|
||||
try {
|
||||
randomCard = await GetCardsHelper.FetchCard(interaction.user.id);
|
||||
} catch (e) {
|
||||
AppLogger.CatchError("Commands/Drop", e);
|
||||
|
||||
await interaction.reply(ErrorMessages.UnableToFetchCard);
|
||||
}
|
||||
|
||||
const randomCard = await GetCardsHelper.FetchCard(interaction.user.id);
|
||||
|
||||
if (!randomCard) {
|
||||
AppLogger.LogWarn("Commands/Drop", ErrorMessages.UnableToFetchCard);
|
||||
|
@ -82,6 +90,9 @@ export default class Drop extends Command {
|
|||
|
||||
const row = DropEmbedHelper.GenerateDropButtons(randomCard, claimId, interaction.user.id);
|
||||
|
||||
await user.Save(User, user);
|
||||
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [ embed ],
|
||||
files: files,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue