Add the amount of currency a user has to the drop command #288
4 changed files with 34 additions and 18 deletions
|
@ -76,7 +76,7 @@ export default class Claim extends ButtonEvent {
|
||||||
|
|
||||||
const imageFileName = card.card.path.split("/").pop()!;
|
const imageFileName = card.card.path.split("/").pop()!;
|
||||||
|
|
||||||
const embed = CardDropHelperMetadata.GenerateDropEmbed(card, inventory.Quantity, imageFileName, interaction.user.username);
|
const embed = CardDropHelperMetadata.GenerateDropEmbed(card, inventory.Quantity, imageFileName, interaction.user.username, user.Currency);
|
||||||
const row = CardDropHelperMetadata.GenerateDropButtons(card, claimId, interaction.user.id, true);
|
const row = CardDropHelperMetadata.GenerateDropButtons(card, claimId, interaction.user.id, true);
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default class Reroll extends ButtonEvent {
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.card.id);
|
||||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
const embed = CardDropHelperMetadata.GenerateDropEmbed(randomCard, quantityClaimed, imageFileName);
|
const embed = CardDropHelperMetadata.GenerateDropEmbed(randomCard, quantityClaimed, imageFileName, undefined, user.Currency);
|
||||||
|
|
||||||
const claimId = v4();
|
const claimId = v4();
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ export default class Drop extends Command {
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.card.id);
|
||||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
const embed = CardDropHelperMetadata.GenerateDropEmbed(randomCard, quantityClaimed, imageFileName);
|
const embed = CardDropHelperMetadata.GenerateDropEmbed(randomCard, quantityClaimed, imageFileName, undefined, user.Currency);
|
||||||
|
|
||||||
const claimId = v4();
|
const claimId = v4();
|
||||||
|
|
||||||
|
|
|
@ -77,25 +77,41 @@ export default class CardDropHelperMetadata {
|
||||||
return { card, series };
|
return { card, series };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GenerateDropEmbed(drop: DropResult, quantityClaimed: number, imageFileName: string, claimedBy?: string): EmbedBuilder {
|
public static GenerateDropEmbed(drop: DropResult, quantityClaimed: number, imageFileName: string, claimedBy?: string, currency?: number): EmbedBuilder {
|
||||||
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropEmbed", `Parameters: drop=${drop.card.id}, quantityClaimed=${quantityClaimed}, imageFileName=${imageFileName}`);
|
AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropEmbed", `Parameters: drop=${drop.card.id}, quantityClaimed=${quantityClaimed}, imageFileName=${imageFileName}`);
|
||||||
|
|
||||||
let description = "";
|
let description = drop.series.name;
|
||||||
description += `Series: ${drop.series.name}\n`;
|
|
||||||
description += `Claimed: ${quantityClaimed}\n`;
|
|
||||||
|
|
||||||
if (claimedBy != null) {
|
const embed = new EmbedBuilder()
|
||||||
description += `Claimed by: ${claimedBy}\n`;
|
|
||||||
} else {
|
|
||||||
description += "Claimed by: (UNCLAIMED)\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EmbedBuilder()
|
|
||||||
.setTitle(drop.card.name)
|
.setTitle(drop.card.name)
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.setFooter({ text: `${CardRarityToString(drop.card.type)} · ${drop.card.id}` })
|
.setFooter({ text: `${CardRarityToString(drop.card.type)} · ${drop.card.id}` })
|
||||||
.setColor(CardRarityToColour(drop.card.type))
|
.setColor(CardRarityToColour(drop.card.type))
|
||||||
.setImage(`attachment://${imageFileName}`);
|
.setImage(`attachment://${imageFileName}`)
|
||||||
|
.addFields([
|
||||||
|
{
|
||||||
|
name: "Claimed",
|
||||||
|
value: `${quantityClaimed}`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Claimed by",
|
||||||
|
value: claimedBy ?? "(UNCLAIMED)",
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (currency != null) {
|
||||||
|
embed.addFields([
|
||||||
|
{
|
||||||
|
name: "Currency",
|
||||||
|
value: `${currency}`,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return embed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GenerateDropButtons(drop: DropResult, claimId: string, userId: string, disabled: boolean = false): ActionRowBuilder<ButtonBuilder> {
|
public static GenerateDropButtons(drop: DropResult, claimId: string, userId: string, disabled: boolean = false): ActionRowBuilder<ButtonBuilder> {
|
||||||
|
|
Loading…
Reference in a new issue