Fix multidrop not handling https:// links correctly

This commit is contained in:
Ethan Lane 2025-05-21 15:28:25 +01:00
parent 62bcd6914c
commit 9d59eedf14
2 changed files with 23 additions and 8 deletions

View file

@ -98,11 +98,19 @@ export default class Multidrop extends ButtonEvent {
await interaction.deferUpdate();
try {
const files = [];
let 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));
const imageFileName = randomCard.card.path.split("/").pop()!;
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;
@ -112,7 +120,7 @@ export default class Multidrop extends ButtonEvent {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
files: files,
components: [ row ],
});
} catch (e) {

View file

@ -62,11 +62,18 @@ export default class Multidrop extends Command {
await interaction.deferReply();
try {
const files = [];
let 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));
const imageFileName = randomCard.card.path.split("/").pop()!;
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;
@ -76,7 +83,7 @@ export default class Multidrop extends Command {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
files: files,
components: [ row ],
});
} catch (e) {