Compare commits
No commits in common. "cb5dfad1c43328b383bbfc53ef5416b488f64d9e" and "2963850de8a436af4b5bc78031ab1d18f43c7e22" have entirely different histories.
cb5dfad1c4
...
2963850de8
5 changed files with 6 additions and 99 deletions
|
@ -58,7 +58,7 @@ export default class Claim extends ButtonEvent {
|
||||||
if (!inventory) {
|
if (!inventory) {
|
||||||
inventory = new Inventory(userId, cardNumber, 1);
|
inventory = new Inventory(userId, cardNumber, 1);
|
||||||
} else {
|
} else {
|
||||||
inventory.AddQuantity(1);
|
inventory.SetQuantity(inventory.Quantity + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
await inventory.Save(Inventory, inventory);
|
await inventory.Save(Inventory, inventory);
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
import { ButtonInteraction, EmbedBuilder } from "discord.js";
|
|
||||||
import { ButtonEvent } from "../type/buttonEvent";
|
|
||||||
import AppLogger from "../client/appLogger";
|
|
||||||
import { CoreClient } from "../client/client";
|
|
||||||
import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata";
|
|
||||||
import Inventory from "../database/entities/app/Inventory";
|
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
|
||||||
import { readFileSync } from "fs";
|
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
export default class Multidrop extends ButtonEvent {
|
|
||||||
public override async execute(interaction: ButtonInteraction) {
|
|
||||||
const action = interaction.customId.split(" ")[1];
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case "keep":
|
|
||||||
await this.Keep(interaction);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
await interaction.reply("Invalid action");
|
|
||||||
AppLogger.LogError("Button/Multidrop", `Invalid action, ${action}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Keep(interaction: ButtonInteraction) {
|
|
||||||
const cardNumber = interaction.customId.split(" ")[2];
|
|
||||||
let cardsRemaining = Number(interaction.customId.split(" ")[3]) || 0;
|
|
||||||
const userId = interaction.customId.split(" ")[4];
|
|
||||||
|
|
||||||
if (interaction.user.id != userId) {
|
|
||||||
await interaction.reply("You're not the user this drop was made for!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const card = CardDropHelperMetadata.GetCardByCardNumber(cardNumber);
|
|
||||||
|
|
||||||
if (!card) {
|
|
||||||
await interaction.reply("Unable to find card.");
|
|
||||||
AppLogger.LogWarn("Button/Multidrop/Keep", `Card not found, ${cardNumber}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cardsRemaining < 0) {
|
|
||||||
await interaction.reply("Your multidrop has ran out! Please buy a new one!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Claim
|
|
||||||
let inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, cardNumber);
|
|
||||||
|
|
||||||
if (!inventory) {
|
|
||||||
inventory = new Inventory(interaction.user.id, cardNumber, 1);
|
|
||||||
} else {
|
|
||||||
inventory.AddQuantity(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
await inventory.Save(Inventory, inventory);
|
|
||||||
|
|
||||||
// Pack has ran out
|
|
||||||
if (cardsRemaining == 0) {
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setDescription("Your multidrop has ran out! Please buy a new one!")
|
|
||||||
.setColor(EmbedColours.Ok);
|
|
||||||
|
|
||||||
await interaction.update({ embeds: [ embed ]});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop next card
|
|
||||||
cardsRemaining -= 1;
|
|
||||||
|
|
||||||
await interaction.deferUpdate();
|
|
||||||
|
|
||||||
try {
|
|
||||||
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", ))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ export default class Multidrop extends Command {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.CommandBuilder = new SlashCommandBuilder()
|
this.CommandBuilder = new SlashCommandBuilder()
|
||||||
.setName("multidrop")
|
.setName("mutlidrop")
|
||||||
.setDescription("Drop 11 cards for the price of 10!");
|
.setDescription("Drop 11 cards for the price of 10!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,18 +70,6 @@ export default class Multidrop extends Command {
|
||||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
const embed = CardDropHelperMetadata.GenerateMultidropEmbed(randomCard, quantityClaimed, imageFileName, cardsRemaining, undefined, user.Currency);
|
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})`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
|
||||||
import { CardRarity, CardRarityToColour, CardRarityToString, GetSacrificeAmount } from "../constants/CardRarity";
|
import { CardRarity, CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
|
||||||
import CardRarityChances from "../constants/CardRarityChances";
|
import CardRarityChances from "../constants/CardRarityChances";
|
||||||
import { DropResult } from "../contracts/SeriesMetadata";
|
import { DropResult } from "../contracts/SeriesMetadata";
|
||||||
import { CoreClient } from "../client/client";
|
import { CoreClient } from "../client/client";
|
||||||
|
@ -158,17 +158,16 @@ export default class CardDropHelperMetadata {
|
||||||
return dropEmbed;
|
return dropEmbed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GenerateMultidropButtons(drop: DropResult, cardsRemaining: number, userId: string, disabled = false): ActionRowBuilder<ButtonBuilder> {
|
public static GenerateMultidropButtons(drop: DropResult, cardsRemaining: number, disabled = false): ActionRowBuilder<ButtonBuilder> {
|
||||||
return new ActionRowBuilder<ButtonBuilder>()
|
return new ActionRowBuilder<ButtonBuilder>()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`multidrop keep ${drop.card.id} ${cardsRemaining} ${userId}`)
|
.setCustomId(`multidrop keep ${drop.card.id} ${cardsRemaining}`)
|
||||||
.setLabel("Keep")
|
.setLabel("Keep")
|
||||||
.setStyle(ButtonStyle.Primary)
|
.setStyle(ButtonStyle.Primary)
|
||||||
.setDisabled(disabled),
|
.setDisabled(disabled),
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`multidrop sacrifice ${drop.card.id} ${cardsRemaining} ${userId}`)
|
.setCustomId(`multidrop sacrifice ${drop.card.id} ${cardsRemaining}`)
|
||||||
.setLabel(`Sacrifice (+${GetSacrificeAmount(drop.card.type)} 🪙)`)
|
|
||||||
.setStyle(ButtonStyle.Secondary));
|
.setStyle(ButtonStyle.Secondary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import Gdrivesync from "./commands/gdrivesync";
|
||||||
import Give from "./commands/give";
|
import Give from "./commands/give";
|
||||||
import Id from "./commands/id";
|
import Id from "./commands/id";
|
||||||
import Inventory from "./commands/inventory";
|
import Inventory from "./commands/inventory";
|
||||||
import Multidrop from "./commands/multidrop";
|
|
||||||
import Resync from "./commands/resync";
|
import Resync from "./commands/resync";
|
||||||
import Sacrifice from "./commands/sacrifice";
|
import Sacrifice from "./commands/sacrifice";
|
||||||
import Series from "./commands/series";
|
import Series from "./commands/series";
|
||||||
|
@ -47,7 +46,6 @@ export default class Registry {
|
||||||
CoreClient.RegisterCommand("give", new Give());
|
CoreClient.RegisterCommand("give", new Give());
|
||||||
CoreClient.RegisterCommand("id", new Id());
|
CoreClient.RegisterCommand("id", new Id());
|
||||||
CoreClient.RegisterCommand("inventory", new Inventory());
|
CoreClient.RegisterCommand("inventory", new Inventory());
|
||||||
CoreClient.RegisterCommand("multidrop", new Multidrop());
|
|
||||||
CoreClient.RegisterCommand("resync", new Resync());
|
CoreClient.RegisterCommand("resync", new Resync());
|
||||||
CoreClient.RegisterCommand("sacrifice", new Sacrifice());
|
CoreClient.RegisterCommand("sacrifice", new Sacrifice());
|
||||||
CoreClient.RegisterCommand("series", new Series());
|
CoreClient.RegisterCommand("series", new Series());
|
||||||
|
|
Loading…
Reference in a new issue