Compare commits
No commits in common. "ce0bc15c029d9b37138a60cae4b2fe9db9f4e719" and "d9d0243c3c3e31e465434ff9663c8f6dd739b47e" have entirely different histories.
ce0bc15c02
...
d9d0243c3c
8 changed files with 45 additions and 61 deletions
|
@ -7,7 +7,7 @@
|
|||
# any secret values.
|
||||
|
||||
BOT_TOKEN=
|
||||
BOT_VER=0.8.3
|
||||
BOT_VER=0.8.2
|
||||
BOT_AUTHOR=Vylpes
|
||||
BOT_OWNERID=147392775707426816
|
||||
BOT_CLIENTID=682942374040961060
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "card-drop",
|
||||
"version": "0.8.3",
|
||||
"version": "0.8.2",
|
||||
"main": "./dist/bot.js",
|
||||
"typings": "./dist",
|
||||
"scripts": {
|
||||
|
|
|
@ -51,18 +51,11 @@ export default class Reroll extends ButtonEvent {
|
|||
try {
|
||||
AppLogger.LogVerbose("Button/Reroll", `Sending next drop: ${randomCard.card.id} (${randomCard.card.name})`);
|
||||
|
||||
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));
|
||||
imageFileName = randomCard.card.path.split("/").pop()!;
|
||||
const 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 +67,7 @@ export default class Reroll extends ButtonEvent {
|
|||
|
||||
await interaction.editReply({
|
||||
embeds: [ embed ],
|
||||
files: files,
|
||||
files: [ attachment ],
|
||||
components: [ row ],
|
||||
});
|
||||
|
||||
|
|
|
@ -59,18 +59,11 @@ export default class Drop 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));
|
||||
imageFileName = randomCard.card.path.split("/").pop()!;
|
||||
const 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;
|
||||
|
||||
|
@ -82,7 +75,7 @@ export default class Drop extends Command {
|
|||
|
||||
await interaction.editReply({
|
||||
embeds: [ embed ],
|
||||
files: files,
|
||||
files: [ attachment ],
|
||||
components: [ row ],
|
||||
});
|
||||
|
||||
|
|
|
@ -43,20 +43,20 @@ export default class Dropnumber extends Command {
|
|||
const series = CoreClient.Cards
|
||||
.find(x => x.cards.includes(card))!;
|
||||
|
||||
const files = [];
|
||||
let imageFileName = "";
|
||||
let image: Buffer;
|
||||
const imageFileName = card.path.split("/").pop()!;
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
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: files,
|
||||
files: [ attachment ],
|
||||
components: [ row ],
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
|
@ -46,18 +46,20 @@ export default class Droprarity extends Command {
|
|||
return;
|
||||
}
|
||||
|
||||
const files = [];
|
||||
let imageFileName = "";
|
||||
let image: Buffer;
|
||||
const imageFileName = card.card.path.split("/").pop()!;
|
||||
|
||||
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()!;
|
||||
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;
|
||||
}
|
||||
|
||||
await interaction.deferReply();
|
||||
|
||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||
|
||||
files.push(attachment);
|
||||
}
|
||||
|
||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.card.id);
|
||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||
|
||||
|
@ -70,7 +72,7 @@ export default class Droprarity extends Command {
|
|||
try {
|
||||
await interaction.editReply({
|
||||
embeds: [ embed ],
|
||||
files: files,
|
||||
files: [ attachment ],
|
||||
components: [ row ],
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
|
@ -43,20 +43,22 @@ export default class View extends Command {
|
|||
const series = CoreClient.Cards
|
||||
.find(x => x.cards.includes(card))!;
|
||||
|
||||
const files = [];
|
||||
let imageFileName = "";
|
||||
let image: Buffer;
|
||||
const imageFileName = card.path.split("/").pop()!;
|
||||
|
||||
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()!;
|
||||
try {
|
||||
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
||||
} catch {
|
||||
AppLogger.LogError("Commands/View", `Unable to fetch image for card ${card.id}.`);
|
||||
|
||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||
|
||||
files.push(attachment);
|
||||
await interaction.reply(`Unable to fetch image for card ${card.id}.`);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -65,7 +67,7 @@ export default class View extends Command {
|
|||
try {
|
||||
await interaction.editReply({
|
||||
embeds: [ embed ],
|
||||
files: files,
|
||||
files: [ attachment ],
|
||||
});
|
||||
} catch (e) {
|
||||
AppLogger.LogError("Commands/View", `Error sending view for card ${card.id}: ${e}`);
|
||||
|
|
|
@ -97,18 +97,12 @@ export default class CardDropHelperMetadata {
|
|||
AppLogger.LogWarn("CardDropHelperMetadata/GenerateDropEmbed", `Card's colour override is invalid: ${drop.card.id}, ${drop.card.colour}`);
|
||||
}
|
||||
|
||||
let imageUrl = `attachment://${imageFileName}`;
|
||||
|
||||
if (drop.card.path.startsWith("http://") || drop.card.path.startsWith("https://")) {
|
||||
imageUrl = drop.card.path;
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(drop.card.name)
|
||||
.setDescription(description)
|
||||
.setFooter({ text: `${CardRarityToString(drop.card.type)} · ${drop.card.id}` })
|
||||
.setColor(colour)
|
||||
.setImage(imageUrl)
|
||||
.setImage(`attachment://${imageFileName}`)
|
||||
.addFields([
|
||||
{
|
||||
name: "Claimed",
|
||||
|
|
Loading…
Add table
Reference in a new issue