Compare commits
8 commits
75bdf5b95d
...
27e214d262
Author | SHA1 | Date | |
---|---|---|---|
27e214d262 | |||
f38d1ef23a | |||
b1aab93fad | |||
a8062f20ae | |||
7b73c66a3c | |||
ce75d8fab6 | |||
6c78c0f74d | |||
c24cfc3463 |
6 changed files with 611 additions and 552 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -108,3 +108,4 @@ config.json
|
||||||
ormconfig.json
|
ormconfig.json
|
||||||
gdrive-credentials.json
|
gdrive-credentials.json
|
||||||
cards/
|
cards/
|
||||||
|
*.db
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "card-drop",
|
"name": "card-drop",
|
||||||
"version": "0.1.5",
|
"version": "0.1.6",
|
||||||
"main": "./dist/bot.js",
|
"main": "./dist/bot.js",
|
||||||
"typings": "./dist",
|
"typings": "./dist",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
"@types/uuid": "^9.0.0",
|
"@types/uuid": "^9.0.0",
|
||||||
"discord.js": "^14.3.0",
|
"discord.js": "^14.3.0",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"googleapis": "^126.0.0",
|
"googleapis": "^127.0.0",
|
||||||
"jest": "^29.0.0",
|
"jest": "^29.0.0",
|
||||||
"jest-mock-extended": "^3.0.0",
|
"jest-mock-extended": "^3.0.0",
|
||||||
"minimatch": "9.0.3",
|
"minimatch": "9.0.3",
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default class CardSetupFunction {
|
||||||
const cardDirLegendary = legendaryExists ? readdirSync(path.join(process.cwd(), 'cards', series.Path, 'LEGENDARY')) : [];
|
const cardDirLegendary = legendaryExists ? readdirSync(path.join(process.cwd(), 'cards', series.Path, 'LEGENDARY')) : [];
|
||||||
const cardDirSilver = silverExists ? readdirSync(path.join(process.cwd(), 'cards', series.Path, 'SILVER')) : [];
|
const cardDirSilver = silverExists ? readdirSync(path.join(process.cwd(), 'cards', series.Path, 'SILVER')) : [];
|
||||||
|
|
||||||
for (let file of cardDirBronze) {
|
for (let file of cardDirBronze.filter(x => !x.startsWith('.') && (x.endsWith('.png') || x.endsWith('.jpg') || x.endsWith('.gif')))) {
|
||||||
const filePart = file.split('.');
|
const filePart = file.split('.');
|
||||||
|
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
|
@ -70,7 +70,7 @@ export default class CardSetupFunction {
|
||||||
cardsToSave.push(card);
|
cardsToSave.push(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let file of cardDirGold) {
|
for (let file of cardDirGold.filter(x => !x.startsWith('.') && (x.endsWith('.png') || x.endsWith('.jpg') || x.endsWith('.gif')))) {
|
||||||
const filePart = file.split('.');
|
const filePart = file.split('.');
|
||||||
|
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
|
@ -81,7 +81,7 @@ export default class CardSetupFunction {
|
||||||
cardsToSave.push(card);
|
cardsToSave.push(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let file of cardDirLegendary) {
|
for (let file of cardDirLegendary.filter(x => !x.startsWith('.') && (x.endsWith('.png') || x.endsWith('.jpg') || x.endsWith('.gif')))) {
|
||||||
const filePart = file.split('.');
|
const filePart = file.split('.');
|
||||||
|
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
|
@ -92,7 +92,7 @@ export default class CardSetupFunction {
|
||||||
cardsToSave.push(card);
|
cardsToSave.push(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let file of cardDirSilver) {
|
for (let file of cardDirSilver.filter(x => !x.startsWith('.') && (x.endsWith('.png') || x.endsWith('.jpg') || x.endsWith('.gif')))) {
|
||||||
const filePart = file.split('.');
|
const filePart = file.split('.');
|
||||||
|
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity"
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import { CoreClient } from "../client/client";
|
import { CoreClient } from "../client/client";
|
||||||
import Card from "../database/entities/card/Card";
|
import Card from "../database/entities/card/Card";
|
||||||
|
import Inventory from "../database/entities/app/Inventory";
|
||||||
|
|
||||||
export default class Reroll extends ButtonEvent {
|
export default class Reroll extends ButtonEvent {
|
||||||
public override async execute(interaction: ButtonInteraction) {
|
public override async execute(interaction: ButtonInteraction) {
|
||||||
|
@ -32,9 +33,16 @@ export default class Reroll extends ButtonEvent {
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
|
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
|
||||||
|
|
||||||
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.CardNumber);
|
||||||
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
|
let embedDescription = "";
|
||||||
|
embedDescription += `Series: ${randomCard.Series.Name}\n`;
|
||||||
|
embedDescription += `Claimed: ${quantityClaimed || 0}\n`;
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(randomCard.Name)
|
.setTitle(randomCard.Name)
|
||||||
.setDescription(randomCard.Series.Name)
|
.setDescription(embedDescription)
|
||||||
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
||||||
.setColor(CardRarityToColour(randomCard.Rarity))
|
.setColor(CardRarityToColour(randomCard.Rarity))
|
||||||
.setImage(`attachment://${randomCard.FileName}`);
|
.setImage(`attachment://${randomCard.FileName}`);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { readFileSync } from "fs";
|
||||||
import { CoreClient } from "../client/client";
|
import { CoreClient } from "../client/client";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import Card from "../database/entities/card/Card";
|
import Card from "../database/entities/card/Card";
|
||||||
|
import Inventory from "../database/entities/app/Inventory";
|
||||||
|
|
||||||
export default class Drop extends Command {
|
export default class Drop extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -38,9 +39,16 @@ export default class Drop extends Command {
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
|
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
|
||||||
|
|
||||||
|
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.CardNumber);
|
||||||
|
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||||
|
|
||||||
|
let embedDescription = "";
|
||||||
|
embedDescription += `Series: ${randomCard.Series.Name}\n`;
|
||||||
|
embedDescription += `Claimed: ${quantityClaimed || 0}\n`;
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(randomCard.Name)
|
.setTitle(randomCard.Name)
|
||||||
.setDescription(randomCard.Series.Name)
|
.setDescription(embedDescription)
|
||||||
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
||||||
.setColor(CardRarityToColour(randomCard.Rarity))
|
.setColor(CardRarityToColour(randomCard.Rarity))
|
||||||
.setImage(`attachment://${randomCard.FileName}`);
|
.setImage(`attachment://${randomCard.FileName}`);
|
||||||
|
|
Loading…
Reference in a new issue