Merge branch 'main' into develop

This commit is contained in:
Ethan Lane 2025-01-19 15:18:50 +00:00
commit 7213703f66
10 changed files with 73 additions and 57 deletions

View file

@ -58,10 +58,17 @@ export default class Drop extends Command {
await interaction.deferReply();
try {
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;
@ -74,7 +81,7 @@ export default class Drop extends Command {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
files: files,
components: [ row ],
});

View file

@ -43,20 +43,20 @@ export default class Dropnumber extends Command {
const series = CoreClient.Cards
.find(x => x.cards.includes(card))!;
let image: Buffer;
const imageFileName = card.path.split("/").pop()!;
const files = [];
let imageFileName = "";
try {
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
} catch {
await interaction.reply(`Unable to fetch image for card ${card.id}`);
return;
if (!(card.path.startsWith("http://") || card.path.startsWith("https://"))) {
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
imageFileName = card.path.split("/").pop()!;
const attachment = new AttachmentBuilder(image, { name: imageFileName });
files.push(attachment);
}
await interaction.deferReply();
const attachment = new AttachmentBuilder(image, { name: imageFileName });
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
const quantityClaimed = inventory ? inventory.Quantity : 0;
@ -69,7 +69,7 @@ export default class Dropnumber extends Command {
try {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
files: files,
components: [ row ],
});
} catch (e) {

View file

@ -46,20 +46,18 @@ export default class Droprarity extends Command {
return;
}
let image: Buffer;
const imageFileName = card.card.path.split("/").pop()!;
const files = [];
let imageFileName = "";
try {
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
} catch {
await interaction.reply(`Unable to fetch image for card ${card.card.id}`);
return;
if (!(card.card.path.startsWith("http://") || card.card.path.startsWith("https://"))) {
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
imageFileName = card.card.path.split("/").pop()!;
const attachment = new AttachmentBuilder(image, { name: imageFileName });
files.push(attachment);
}
await interaction.deferReply();
const attachment = new AttachmentBuilder(image, { name: imageFileName });
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.card.id);
const quantityClaimed = inventory ? inventory.Quantity : 0;
@ -72,7 +70,7 @@ export default class Droprarity extends Command {
try {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
files: files,
components: [ row ],
});
} catch (e) {

View file

@ -34,7 +34,7 @@ export default class View extends Command {
await interaction.editReply({
embeds: [ searchResult.embed ],
components: [ searchResult.row ],
files: [ searchResult.attachment ],
files: searchResult.attachments,
});
}
}