Compare commits
No commits in common. "3e81f8ce1d4b01fb5fc4e4ee710b5ed95fa34202" and "ed52f3e3dc508fdc5e6a5dca3f7c317e686d1721" have entirely different histories.
3e81f8ce1d
...
ed52f3e3dc
11 changed files with 68 additions and 82 deletions
|
@ -7,7 +7,7 @@
|
||||||
# any secret values.
|
# any secret values.
|
||||||
|
|
||||||
BOT_TOKEN=
|
BOT_TOKEN=
|
||||||
BOT_VER=0.8.3
|
BOT_VER=0.8.2
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
BOT_CLIENTID=682942374040961060
|
BOT_CLIENTID=682942374040961060
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "card-drop",
|
"name": "card-drop",
|
||||||
"version": "0.8.3",
|
"version": "0.8.2",
|
||||||
"main": "./dist/bot.js",
|
"main": "./dist/bot.js",
|
||||||
"typings": "./dist",
|
"typings": "./dist",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -51,18 +51,11 @@ export default class Reroll extends ButtonEvent {
|
||||||
try {
|
try {
|
||||||
AppLogger.LogVerbose("Button/Reroll", `Sending next drop: ${randomCard.card.id} (${randomCard.card.name})`);
|
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));
|
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 });
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
|
|
||||||
files.push(attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -74,7 +67,7 @@ export default class Reroll extends ButtonEvent {
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: files,
|
files: [ attachment ],
|
||||||
components: [ row ],
|
components: [ row ],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default class View extends ButtonEvent {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ searchResult.embed ],
|
embeds: [ searchResult.embed ],
|
||||||
components: [ searchResult.row ],
|
components: [ searchResult.row ],
|
||||||
files: searchResult.attachments,
|
files: [ searchResult.attachment ],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,18 +58,11 @@ export default class Drop extends Command {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
try {
|
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 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 });
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
|
|
||||||
files.push(attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -81,7 +74,7 @@ export default class Drop extends Command {
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: files,
|
files: [ attachment ],
|
||||||
components: [ row ],
|
components: [ row ],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -43,20 +43,22 @@ export default class Id extends Command {
|
||||||
const series = CoreClient.Cards
|
const series = CoreClient.Cards
|
||||||
.find(x => x.cards.includes(card))!;
|
.find(x => x.cards.includes(card))!;
|
||||||
|
|
||||||
const files = [];
|
let image: Buffer;
|
||||||
let imageFileName = "";
|
const imageFileName = card.path.split("/").pop()!;
|
||||||
|
|
||||||
if (!(card.path.startsWith("http://") || card.path.startsWith("https://"))) {
|
try {
|
||||||
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
||||||
imageFileName = card.path.split("/").pop()!;
|
} catch {
|
||||||
|
AppLogger.LogError("Commands/View", `Unable to fetch image for card ${card.id}.`);
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
await interaction.reply(`Unable to fetch image for card ${card.id}.`);
|
||||||
|
return;
|
||||||
files.push(attachment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
|
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
|
||||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ export default class Id extends Command {
|
||||||
try {
|
try {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: files,
|
files: [ attachment ],
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
AppLogger.LogError("Commands/View", `Error sending view for card ${card.id}: ${e}`);
|
AppLogger.LogError("Commands/View", `Error sending view for card ${card.id}: ${e}`);
|
||||||
|
|
|
@ -43,20 +43,20 @@ export default class Dropnumber extends Command {
|
||||||
const series = CoreClient.Cards
|
const series = CoreClient.Cards
|
||||||
.find(x => x.cards.includes(card))!;
|
.find(x => x.cards.includes(card))!;
|
||||||
|
|
||||||
const files = [];
|
let image: Buffer;
|
||||||
let imageFileName = "";
|
const imageFileName = card.path.split("/").pop()!;
|
||||||
|
|
||||||
if (!(card.path.startsWith("http://") || card.path.startsWith("https://"))) {
|
try {
|
||||||
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
||||||
imageFileName = card.path.split("/").pop()!;
|
} catch {
|
||||||
|
await interaction.reply(`Unable to fetch image for card ${card.id}`);
|
||||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
return;
|
||||||
|
|
||||||
files.push(attachment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
|
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
|
||||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ export default class Dropnumber extends Command {
|
||||||
try {
|
try {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: files,
|
files: [ attachment ],
|
||||||
components: [ row ],
|
components: [ row ],
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -46,18 +46,20 @@ export default class Droprarity extends Command {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = [];
|
let image: Buffer;
|
||||||
let imageFileName = "";
|
const imageFileName = card.card.path.split("/").pop()!;
|
||||||
|
|
||||||
if (!(card.card.path.startsWith("http://") || card.card.path.startsWith("https://"))) {
|
try {
|
||||||
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
|
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
|
||||||
imageFileName = card.card.path.split("/").pop()!;
|
} catch {
|
||||||
|
await interaction.reply(`Unable to fetch image for card ${card.card.id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await interaction.deferReply();
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
|
|
||||||
files.push(attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.card.id);
|
||||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ export default class Droprarity extends Command {
|
||||||
try {
|
try {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: files,
|
files: [ attachment ],
|
||||||
components: [ row ],
|
components: [ row ],
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ export default class View extends Command {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [ searchResult.embed ],
|
embeds: [ searchResult.embed ],
|
||||||
components: [ searchResult.row ],
|
components: [ searchResult.row ],
|
||||||
files: searchResult.attachments,
|
files: [ searchResult.attachment ],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -97,18 +97,12 @@ export default class CardDropHelperMetadata {
|
||||||
AppLogger.LogWarn("CardDropHelperMetadata/GenerateDropEmbed", `Card's colour override is invalid: ${drop.card.id}, ${drop.card.colour}`);
|
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()
|
const embed = 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(colour)
|
.setColor(colour)
|
||||||
.setImage(imageUrl)
|
.setImage(`attachment://${imageFileName}`)
|
||||||
.addFields([
|
.addFields([
|
||||||
{
|
{
|
||||||
name: "Claimed",
|
name: "Claimed",
|
||||||
|
|
|
@ -10,7 +10,7 @@ import AppLogger from "../client/appLogger.js";
|
||||||
interface ReturnedPage {
|
interface ReturnedPage {
|
||||||
embed: EmbedBuilder,
|
embed: EmbedBuilder,
|
||||||
row: ActionRowBuilder<ButtonBuilder>,
|
row: ActionRowBuilder<ButtonBuilder>,
|
||||||
attachments: AttachmentBuilder[],
|
attachment: AttachmentBuilder,
|
||||||
results: string[],
|
results: string[],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,18 +36,19 @@ export default class CardSearchHelper {
|
||||||
|
|
||||||
if (!card) return undefined;
|
if (!card) return undefined;
|
||||||
|
|
||||||
const attachments = [];
|
let image: Buffer;
|
||||||
let imageFileName = "";
|
const imageFileName = card.card.path.split("/").pop()!;
|
||||||
|
|
||||||
if (!(card.card.path.startsWith("http://") || card.card.path.startsWith("https://"))) {
|
try {
|
||||||
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
|
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
|
||||||
imageFileName = card.card.path.split("/").pop()!;
|
} catch {
|
||||||
|
AppLogger.LogError("CardSearchHelper/GenerateSearchQuery", `Unable to fetch image for card ${card.card.id}.`);
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
|
|
||||||
attachments.push(attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(userid, card.card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(userid, card.card.id);
|
||||||
const quantityClaimed = inventory?.Quantity ?? 0;
|
const quantityClaimed = inventory?.Quantity ?? 0;
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ export default class CardSearchHelper {
|
||||||
.setStyle(ButtonStyle.Primary)
|
.setStyle(ButtonStyle.Primary)
|
||||||
.setDisabled(pages == 1));
|
.setDisabled(pages == 1));
|
||||||
|
|
||||||
return { embed, row, attachments, results };
|
return { embed, row, attachment, results };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async GenerateSearchPageFromQuery(results: string[], userid: string, page: number): Promise<ReturnedPage | undefined> {
|
public static async GenerateSearchPageFromQuery(results: string[], userid: string, page: number): Promise<ReturnedPage | undefined> {
|
||||||
|
@ -80,18 +81,19 @@ export default class CardSearchHelper {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const attachments = [];
|
let image: Buffer;
|
||||||
let imageFileName = "";
|
const imageFileName = card.card.path.split("/").pop()!;
|
||||||
|
|
||||||
if (!(card.card.path.startsWith("http://") || card.card.path.startsWith("https://"))) {
|
try {
|
||||||
const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
|
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.card.path));
|
||||||
imageFileName = card.card.path.split("/").pop()!;
|
} catch {
|
||||||
|
AppLogger.LogError("CardSearchHelper/GenerateSearchPageFromQuery", `Unable to fetch image for card ${card.card.id}.`);
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||||
|
|
||||||
attachments.push(attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(userid, card.card.id);
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(userid, card.card.id);
|
||||||
const quantityClaimed = inventory?.Quantity ?? 0;
|
const quantityClaimed = inventory?.Quantity ?? 0;
|
||||||
|
|
||||||
|
@ -110,6 +112,6 @@ export default class CardSearchHelper {
|
||||||
.setStyle(ButtonStyle.Primary)
|
.setStyle(ButtonStyle.Primary)
|
||||||
.setDisabled(page == results.length));
|
.setDisabled(page == results.length));
|
||||||
|
|
||||||
return { embed, row, attachments, results };
|
return { embed, row, attachment, results };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue