Create base command

This commit is contained in:
Ethan Lane 2024-10-05 19:32:01 +01:00 committed by VylpesTester
parent 7e1dd51e0f
commit 837a1cd187
3 changed files with 20 additions and 5 deletions

View file

@ -16,7 +16,7 @@ export default class Multidrop extends Command {
super();
this.CommandBuilder = new SlashCommandBuilder()
.setName("mutlidrop")
.setName("multidrop")
.setDescription("Drop 11 cards for the price of 10!");
}
@ -70,6 +70,18 @@ export default class Multidrop extends Command {
const quantityClaimed = inventory ? inventory.Quantity : 0;
const embed = CardDropHelperMetadata.GenerateMultidropEmbed(randomCard, quantityClaimed, imageFileName, cardsRemaining, undefined, user.Currency);
const row = CardDropHelperMetadata.GenerateMultidropButtons(randomCard, cardsRemaining, interaction.user.id);
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
components: [ row ],
});
} catch (e) {
AppLogger.LogError("Commands/Multidrop", `Error sending next drop for card ${randomCard.card.id}: ${e}`);
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. (${randomCard.card.id})`);
}
}
}

View file

@ -1,5 +1,5 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
import { CardRarity, CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
import { CardRarity, CardRarityToColour, CardRarityToString, GetSacrificeAmount } from "../constants/CardRarity";
import CardRarityChances from "../constants/CardRarityChances";
import { DropResult } from "../contracts/SeriesMetadata";
import { CoreClient } from "../client/client";
@ -158,16 +158,17 @@ export default class CardDropHelperMetadata {
return dropEmbed;
}
public static GenerateMultidropButtons(drop: DropResult, cardsRemaining: number, disabled = false): ActionRowBuilder<ButtonBuilder> {
public static GenerateMultidropButtons(drop: DropResult, cardsRemaining: number, userId: string, disabled = false): ActionRowBuilder<ButtonBuilder> {
return new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId(`multidrop keep ${drop.card.id} ${cardsRemaining}`)
.setCustomId(`multidrop keep ${drop.card.id} ${cardsRemaining} ${userId}`)
.setLabel("Keep")
.setStyle(ButtonStyle.Primary)
.setDisabled(disabled),
new ButtonBuilder()
.setCustomId(`multidrop sacrifice ${drop.card.id} ${cardsRemaining}`)
.setCustomId(`multidrop sacrifice ${drop.card.id} ${cardsRemaining} ${userId}`)
.setLabel(`Sacrifice (+${GetSacrificeAmount(drop.card.type)} 🪙)`)
.setStyle(ButtonStyle.Secondary));
}
}

View file

@ -11,6 +11,7 @@ import Gdrivesync from "./commands/gdrivesync";
import Give from "./commands/give";
import Id from "./commands/id";
import Inventory from "./commands/inventory";
import Multidrop from "./commands/multidrop";
import Resync from "./commands/resync";
import Sacrifice from "./commands/sacrifice";
import Series from "./commands/series";
@ -46,6 +47,7 @@ export default class Registry {
CoreClient.RegisterCommand("give", new Give());
CoreClient.RegisterCommand("id", new Id());
CoreClient.RegisterCommand("inventory", new Inventory());
CoreClient.RegisterCommand("multidrop", new Multidrop());
CoreClient.RegisterCommand("resync", new Resync());
CoreClient.RegisterCommand("sacrifice", new Sacrifice());
CoreClient.RegisterCommand("series", new Series());