Implement ability to add images in the drop via an external url
All checks were successful
Test / build (push) Successful in 19s

This commit is contained in:
Ethan Lane 2025-01-19 15:07:40 +00:00
parent d9d0243c3c
commit b8623398a6
6 changed files with 59 additions and 43 deletions

View file

@ -51,10 +51,17 @@ export default class Reroll extends ButtonEvent {
try {
AppLogger.LogVerbose("Button/Reroll", `Sending next drop: ${randomCard.card.id} (${randomCard.card.name})`);
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", randomCard.card.path));
const imageFileName = randomCard.card.path.split("/").pop()!;
const files = [];
let imageFileName = "";
const attachment = new AttachmentBuilder(image, { name: imageFileName });
if (!(randomCard.card.path.startsWith("http://") || randomCard.card.path.startsWith("https://"))) {
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", randomCard.card.path));
imageFileName = randomCard.card.path.split("/").pop()!;
const attachment = new AttachmentBuilder(image, { name: imageFileName });
files.push(attachment);
}
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.card.id);
const quantityClaimed = inventory ? inventory.Quantity : 0;
@ -67,7 +74,7 @@ export default class Reroll extends ButtonEvent {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
files: files,
components: [ row ],
});