Add dropnumber test command
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
28d745bf5c
commit
ab05b31474
6 changed files with 121 additions and 49 deletions
|
@ -1,8 +1,7 @@
|
|||
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, CacheType, DiscordAPIError, EmbedBuilder } from "discord.js";
|
||||
import { AttachmentBuilder, ButtonInteraction, DiscordAPIError } from "discord.js";
|
||||
import { ButtonEvent } from "../type/buttonEvent";
|
||||
import CardDropHelper from "../helpers/CardDropHelper";
|
||||
import { readFileSync } from "fs";
|
||||
import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
|
||||
import { v4 } from "uuid";
|
||||
import { CoreClient } from "../client/client";
|
||||
import Card from "../database/entities/card/Card";
|
||||
|
@ -36,30 +35,11 @@ export default class Reroll extends ButtonEvent {
|
|||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.CardNumber);
|
||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||
|
||||
let embedDescription = "";
|
||||
embedDescription += `Series: ${randomCard.Series.Name}\n`;
|
||||
embedDescription += `Claimed: ${quantityClaimed || 0}\n`;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(randomCard.Name)
|
||||
.setDescription(embedDescription)
|
||||
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
||||
.setColor(CardRarityToColour(randomCard.Rarity))
|
||||
.setImage(`attachment://${randomCard.FileName}`);
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>();
|
||||
const embed = CardDropHelper.GenerateDropEmbed(randomCard, quantityClaimed || 0);
|
||||
|
||||
const claimId = v4();
|
||||
|
||||
row.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`claim ${randomCard.CardNumber} ${claimId} ${interaction.user.id}`)
|
||||
.setLabel("Claim")
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`reroll`)
|
||||
.setLabel("Reroll")
|
||||
.setStyle(ButtonStyle.Secondary));
|
||||
const row = CardDropHelper.GenerateDropButtons(randomCard, claimId, interaction.user.id);
|
||||
|
||||
try {
|
||||
await interaction.editReply({
|
||||
|
@ -70,7 +50,6 @@ export default class Reroll extends ButtonEvent {
|
|||
} 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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue