Compare commits
No commits in common. "feature/CD-457" and "main" have entirely different histories.
feature/CD
...
main
3 changed files with 4 additions and 34 deletions
|
@ -68,7 +68,7 @@ export default class Claim extends ButtonEvent {
|
||||||
const imageFileName = card.card.path.split("/").pop()!;
|
const imageFileName = card.card.path.split("/").pop()!;
|
||||||
|
|
||||||
const embed = DropEmbedHelper.GenerateDropEmbed(card, inventory.Quantity, imageFileName, interaction.user.username, user.Currency);
|
const embed = DropEmbedHelper.GenerateDropEmbed(card, inventory.Quantity, imageFileName, interaction.user.username, user.Currency);
|
||||||
const row = DropEmbedHelper.GenerateDropButtons(card, claimId, interaction.user.id, true, false);
|
const row = DropEmbedHelper.GenerateDropButtons(card, claimId, interaction.user.id, true);
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
|
|
|
@ -12,18 +12,9 @@ import CardConstants from "../constants/CardConstants";
|
||||||
import GetCardsHelper from "../helpers/DropHelpers/GetCardsHelper";
|
import GetCardsHelper from "../helpers/DropHelpers/GetCardsHelper";
|
||||||
import DropEmbedHelper from "../helpers/DropHelpers/DropEmbedHelper";
|
import DropEmbedHelper from "../helpers/DropHelpers/DropEmbedHelper";
|
||||||
import {DropResult} from "../contracts/SeriesMetadata";
|
import {DropResult} from "../contracts/SeriesMetadata";
|
||||||
import {GetSacrificeAmount} from "../constants/CardRarity";
|
|
||||||
|
|
||||||
export default class Reroll extends ButtonEvent {
|
export default class Reroll extends ButtonEvent {
|
||||||
public override async execute(interaction: ButtonInteraction) {
|
public override async execute(interaction: ButtonInteraction) {
|
||||||
const cardId = interaction.customId.split(" ")[1];
|
|
||||||
const doSacrifice = interaction.customId.split(" ")[2] == "true";
|
|
||||||
|
|
||||||
if (!cardId) {
|
|
||||||
AppLogger.LogError("Button/Reroll", "cardId is undefined");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CoreClient.AllowDrops) {
|
if (!CoreClient.AllowDrops) {
|
||||||
await interaction.reply("Bot is currently syncing, please wait until its done.");
|
await interaction.reply("Bot is currently syncing, please wait until its done.");
|
||||||
return;
|
return;
|
||||||
|
@ -45,26 +36,6 @@ export default class Reroll extends ButtonEvent {
|
||||||
AppLogger.LogInfo("Button/Reroll", `New user (${interaction.user.id}) saved to the database`);
|
AppLogger.LogInfo("Button/Reroll", `New user (${interaction.user.id}) saved to the database`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sacrifice current card
|
|
||||||
if (doSacrifice) {
|
|
||||||
const cardData = GetCardsHelper.GetCardByCardNumber(cardId);
|
|
||||||
|
|
||||||
if (!cardData) {
|
|
||||||
await interaction.reply("Unable to find card in the database.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const oldRow = DropEmbedHelper.GenerateDropButtons(cardData, "", interaction.user.id, true, false);
|
|
||||||
|
|
||||||
interaction.message.edit({
|
|
||||||
components: [ oldRow ],
|
|
||||||
});
|
|
||||||
|
|
||||||
const sacrificeAmount = GetSacrificeAmount(cardData.card.type);
|
|
||||||
user.AddCurrency(sacrificeAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate new card
|
|
||||||
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
if (!user.RemoveCurrency(CardConstants.ClaimCost)) {
|
||||||
await interaction.reply(`Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
await interaction.reply(`Not enough currency! You need ${CardConstants.ClaimCost} currency, you have ${user.Currency}!`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -66,7 +66,7 @@ export default class DropEmbedHelper {
|
||||||
return embed;
|
return embed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GenerateDropButtons(drop: DropResult, claimId: string, userId: string, disabled: boolean = false, doSacrifice: boolean = true): ActionRowBuilder<ButtonBuilder> {
|
public static GenerateDropButtons(drop: DropResult, claimId: string, userId: string, disabled: boolean = false): ActionRowBuilder<ButtonBuilder> {
|
||||||
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropButtons", `Parameters: drop=${drop.card.id}, claimId=${claimId}, userId=${userId}`);
|
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropButtons", `Parameters: drop=${drop.card.id}, claimId=${claimId}, userId=${userId}`);
|
||||||
|
|
||||||
return new ActionRowBuilder<ButtonBuilder>()
|
return new ActionRowBuilder<ButtonBuilder>()
|
||||||
|
@ -79,10 +79,9 @@ export default class DropEmbedHelper {
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`sacrifice give ${userId} ${drop.card.id} 1`)
|
.setCustomId(`sacrifice give ${userId} ${drop.card.id} 1`)
|
||||||
.setLabel(`Sacrifice`)
|
.setLabel(`Sacrifice`)
|
||||||
.setStyle(ButtonStyle.Danger)
|
.setStyle(ButtonStyle.Danger),
|
||||||
.setDisabled(disabled),
|
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
.setCustomId(`reroll ${drop.card.id} ${doSacrifice}`)
|
.setCustomId("reroll")
|
||||||
.setEmoji("🔁")
|
.setEmoji("🔁")
|
||||||
.setStyle(ButtonStyle.Primary),);
|
.setStyle(ButtonStyle.Primary),);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue