Compare commits

..

No commits in common. "2bf961d1e589e9a3fff1a725c1696a06f98b04bc" and "e4c37f941805520544eb092245a182769a4e88a5" have entirely different histories.

32 changed files with 1053 additions and 1240 deletions

View file

@ -25,42 +25,40 @@
"homepage": "https://gitea.vylpes.xyz/External/card-drop", "homepage": "https://gitea.vylpes.xyz/External/card-drop",
"funding": "https://ko-fi.com/vylpes", "funding": "https://ko-fi.com/vylpes",
"dependencies": { "dependencies": {
"@discordjs/rest": "^2.5.1", "@discordjs/rest": "^2.5.0",
"axios": "^1.10.0", "@types/clone-deep": "^4.0.4",
"@types/express": "^5.0.2",
"@types/jest": "^29.5.14",
"@types/uuid": "^10.0.0",
"axios": "^1.9.0",
"body-parser": "^2.2.0", "body-parser": "^2.2.0",
"canvas": "^3.1.1", "canvas": "^3.1.0",
"clone-deep": "^4.0.1", "clone-deep": "^4.0.1",
"cron": "^4.3.1", "cron": "^4.3.1",
"discord.js": "^14.20.0", "discord.js": "^14.19.3",
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"express": "^5.1.0", "express": "^5.1.0",
"fuse.js": "^7.1.0", "fuse.js": "^7.1.0",
"glob": "^11.0.3", "glob": "^11.0.2",
"jest": "^30.0.2", "jest": "^29.0.0",
"jest-mock-extended": "^4.0.0", "jest-mock-extended": "^4.0.0-beta1",
"jimp": "^1.6.0", "jimp": "^1.6.0",
"minimatch": "10.0.3", "minimatch": "10.0.1",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"reflect-metadata": "^0.2.2", "ts-jest": "^29.3.4",
"ts-jest": "^29.4.0", "typeorm": "0.3.20",
"typeorm": "0.3.24",
"winston": "^3.17.0", "winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0", "winston-daily-rotate-file": "^5.0.0",
"winston-discord-transport": "^1.3.0" "winston-discord-transport": "^1.3.0"
}, },
"resolutions": {}, "resolutions": {},
"devDependencies": { "devDependencies": {
"@jest/globals": "^30.0.2", "@types/node": "^22.15.29",
"@types/clone-deep": "^4.0.4", "@typescript-eslint/eslint-plugin": "^8.33.1",
"@types/express": "^5.0.3", "@typescript-eslint/parser": "^8.33.1",
"@types/jest": "^30.0.0", "eslint": "^9.28.0",
"@types/node": "^24.0.3",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.34.1",
"@typescript-eslint/parser": "^8.34.1",
"eslint": "^9.29.0",
"np": "^10.2.0", "np": "^10.2.0",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"typescript-eslint": "^8.34.1" "typescript-eslint": "^8.33.1"
} }
} }

View file

@ -4,6 +4,8 @@ import AppLogger from "../appLogger";
export default class Button { export default class Button {
public static async onButtonClicked(interaction: ButtonInteraction) { public static async onButtonClicked(interaction: ButtonInteraction) {
if (!interaction.isButton) return;
const item = CoreClient.buttonEvents.find(x => x.ButtonId == interaction.customId.split(" ")[0]); const item = CoreClient.buttonEvents.find(x => x.ButtonId == interaction.customId.split(" ")[0]);
if (!item) { if (!item) {

View file

@ -1,10 +1,12 @@
import { ChatInputCommandInteraction } from "discord.js"; import { Interaction } from "discord.js";
import { CoreClient } from "../client"; import { CoreClient } from "../client";
import ICommandItem from "../../contracts/ICommandItem"; import ICommandItem from "../../contracts/ICommandItem";
import AppLogger from "../appLogger"; import AppLogger from "../appLogger";
export default class ChatInputCommand { export default class ChatInputCommand {
public static async onChatInput(interaction: ChatInputCommandInteraction) { public static async onChatInput(interaction: Interaction) {
if (!interaction.isChatInputCommand()) return;
const item = CoreClient.commandItems.find(x => x.Name == interaction.commandName && !x.ServerId); const item = CoreClient.commandItems.find(x => x.Name == interaction.commandName && !x.ServerId);
const itemForServer = CoreClient.commandItems.find(x => x.Name == interaction.commandName && x.ServerId == interaction.guildId); const itemForServer = CoreClient.commandItems.find(x => x.Name == interaction.commandName && x.ServerId == interaction.guildId);

View file

@ -4,6 +4,8 @@ import AppLogger from "../appLogger";
export default class StringDropdown { export default class StringDropdown {
public static async onStringDropdownSelected(interaction: StringSelectMenuInteraction) { public static async onStringDropdownSelected(interaction: StringSelectMenuInteraction) {
if (!interaction.isStringSelectMenu()) return;
const item = CoreClient.stringDropdowns.find(x => x.DropdownId == interaction.customId.split(" ")[0]); const item = CoreClient.stringDropdowns.find(x => x.DropdownId == interaction.customId.split(" ")[0]);
if (!item) { if (!item) {

View file

@ -1,4 +1,4 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
import EmbedColours from "../constants/EmbedColours"; import EmbedColours from "../constants/EmbedColours";
import { Command } from "../type/command"; import { Command } from "../type/command";
@ -11,7 +11,7 @@ export default class About extends Command {
.setDescription("About Bot"); .setDescription("About Bot");
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const fundingLink = process.env.ABOUT_FUNDING; const fundingLink = process.env.ABOUT_FUNDING;
const repoLink = process.env.ABOUT_REPO; const repoLink = process.env.ABOUT_REPO;

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import EmbedColours from "../constants/EmbedColours"; import EmbedColours from "../constants/EmbedColours";
import { Command } from "../type/command"; import { Command } from "../type/command";
import User from "../database/entities/app/User"; import User from "../database/entities/app/User";
@ -13,7 +13,7 @@ export default class AllBalance extends Command {
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const users = await User.FetchAll(User); const users = await User.FetchAll(User);
const filteredUsers = users.filter(x => x.Currency > 0) const filteredUsers = users.filter(x => x.Currency > 0)

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import User from "../database/entities/app/User"; import User from "../database/entities/app/User";
import EmbedColours from "../constants/EmbedColours"; import EmbedColours from "../constants/EmbedColours";
@ -12,7 +12,7 @@ export default class Balance extends Command {
.setDescription("Get your currency balance"); .setDescription("Get your currency balance");
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const user = await User.FetchOneById(User, interaction.user.id); const user = await User.FetchOneById(User, interaction.user.id);
const userBalance = user != null ? user.Currency : 0; const userBalance = user != null ? user.Currency : 0;

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import User from "../database/entities/app/User"; import User from "../database/entities/app/User";
import CardConstants from "../constants/CardConstants"; import CardConstants from "../constants/CardConstants";
@ -13,7 +13,7 @@ export default class Daily extends Command {
.setDescription("Gain bonus currency, once a day"); .setDescription("Gain bonus currency, once a day");
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const user = await User.FetchOneById(User, interaction.user.id) ?? new User(interaction.user.id, CardConstants.StartingCurrency); const user = await User.FetchOneById(User, interaction.user.id) ?? new User(interaction.user.id, CardConstants.StartingCurrency);
const dayAgo = new Date(Date.now() - (1000 * 60 * 60 * 24)); const dayAgo = new Date(Date.now() - (1000 * 60 * 60 * 24));

View file

@ -1,4 +1,4 @@
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
@ -23,7 +23,7 @@ export default class Drop extends Command {
.setDescription("Summon a new card drop"); .setDescription("Summon a new card drop");
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
if (!CoreClient.AllowDrops) { if (!CoreClient.AllowDrops) {
await interaction.reply(ErrorMessages.BotSyncing); await interaction.reply(ErrorMessages.BotSyncing);
return; return;

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { EffectChoices } from "../constants/EffectDetails"; import { EffectChoices } from "../constants/EffectDetails";
import AppLogger from "../client/appLogger"; import AppLogger from "../client/appLogger";
@ -42,7 +42,9 @@ export default class Effects extends Command {
.setMinValue(1))); .setMinValue(1)));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return;
const subcommand = interaction.options.getSubcommand(); const subcommand = interaction.options.getSubcommand();
switch (subcommand) { switch (subcommand) {

View file

@ -1,7 +1,7 @@
import { ChatInputCommandInteraction } from "discord.js"; import { CommandInteraction } from "discord.js";
import EffectHelper from "../../helpers/EffectHelper"; import EffectHelper from "../../helpers/EffectHelper";
export default async function Buy(interaction: ChatInputCommandInteraction) { export default async function Buy(interaction: CommandInteraction) {
const id = interaction.options.get("id", true).value!; const id = interaction.options.get("id", true).value!;
const quantity = interaction.options.get("quantity")?.value ?? 1; const quantity = interaction.options.get("quantity")?.value ?? 1;

View file

@ -1,7 +1,7 @@
import { ChatInputCommandInteraction } from "discord.js"; import { CommandInteraction } from "discord.js";
import EffectHelper from "../../helpers/EffectHelper"; import EffectHelper from "../../helpers/EffectHelper";
export default async function List(interaction: ChatInputCommandInteraction) { export default async function List(interaction: CommandInteraction) {
const pageOption = interaction.options.get("page"); const pageOption = interaction.options.get("page");
const page = !isNaN(Number(pageOption?.value)) ? Number(pageOption?.value) : 1; const page = !isNaN(Number(pageOption?.value)) ? Number(pageOption?.value) : 1;

View file

@ -1,11 +1,11 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder } from "discord.js";
import { EffectDetails } from "../../constants/EffectDetails"; import { EffectDetails } from "../../constants/EffectDetails";
import AppLogger from "../../client/appLogger"; import AppLogger from "../../client/appLogger";
import EffectHelper from "../../helpers/EffectHelper"; import EffectHelper from "../../helpers/EffectHelper";
import TimeLengthInput from "../../helpers/TimeLengthInput"; import TimeLengthInput from "../../helpers/TimeLengthInput";
import EmbedColours from "../../constants/EmbedColours"; import EmbedColours from "../../constants/EmbedColours";
export default async function Use(interaction: ChatInputCommandInteraction) { export default async function Use(interaction: CommandInteraction) {
const id = interaction.options.get("id", true).value!.toString(); const id = interaction.options.get("id", true).value!.toString();
const effectDetail = EffectDetails.get(id); const effectDetail = EffectDetails.get(id);

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { ExecException, exec } from "child_process"; import { ExecException, exec } from "child_process";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
@ -16,7 +16,9 @@ export default class Gdrivesync extends Command {
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const whitelistedUsers = process.env.BOT_ADMINS!.split(","); const whitelistedUsers = process.env.BOT_ADMINS!.split(",");
if (!whitelistedUsers.find(x => x == interaction.user.id)) { if (!whitelistedUsers.find(x => x == interaction.user.id)) {

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
import Config from "../database/entities/app/Config"; import Config from "../database/entities/app/Config";
@ -45,7 +45,9 @@ export default class Give extends Command {
.setRequired(true))); .setRequired(true)));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const whitelistedUsers = process.env.BOT_ADMINS!.split(","); const whitelistedUsers = process.env.BOT_ADMINS!.split(",");
if (!whitelistedUsers.find(x => x == interaction.user.id)) { if (!whitelistedUsers.find(x => x == interaction.user.id)) {
@ -63,7 +65,7 @@ export default class Give extends Command {
} }
} }
private async GiveCard(interaction: ChatInputCommandInteraction) { private async GiveCard(interaction: CommandInteraction) {
if (!CoreClient.AllowDrops) { if (!CoreClient.AllowDrops) {
await interaction.reply("Bot is currently syncing, please wait until its done."); await interaction.reply("Bot is currently syncing, please wait until its done.");
return; return;
@ -99,7 +101,7 @@ export default class Give extends Command {
await interaction.reply(`Card ${card.card.name} given to ${user.username}, they now have ${inventory.Quantity}`); await interaction.reply(`Card ${card.card.name} given to ${user.username}, they now have ${inventory.Quantity}`);
} }
private async GiveCurrency(interaction: ChatInputCommandInteraction) { private async GiveCurrency(interaction: CommandInteraction) {
const amount = interaction.options.get("amount", true); const amount = interaction.options.get("amount", true);
const user = interaction.options.get("user", true).user!; const user = interaction.options.get("user", true).user!;

View file

@ -1,4 +1,4 @@
import { AttachmentBuilder, ChatInputCommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
@ -21,7 +21,7 @@ export default class Id extends Command {
.setRequired(true)); .setRequired(true));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const cardNumber = interaction.options.get("cardnumber"); const cardNumber = interaction.options.get("cardnumber");
AppLogger.LogSilly("Commands/View", `Parameters: cardNumber=${cardNumber?.value}`); AppLogger.LogSilly("Commands/View", `Parameters: cardNumber=${cardNumber?.value}`);

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import InventoryHelper from "../helpers/InventoryHelper"; import InventoryHelper from "../helpers/InventoryHelper";
import AppLogger from "../client/appLogger"; import AppLogger from "../client/appLogger";
@ -20,7 +20,7 @@ export default class Inventory extends Command {
.setDescription("The user to view (Defaults to yourself)")); .setDescription("The user to view (Defaults to yourself)"));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const page = interaction.options.get("page"); const page = interaction.options.get("page");
const userOption = interaction.options.get("user"); const userOption = interaction.options.get("user");

View file

@ -1,4 +1,4 @@
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
import ErrorMessages from "../constants/ErrorMessages"; import ErrorMessages from "../constants/ErrorMessages";
@ -21,7 +21,7 @@ export default class Multidrop extends Command {
.setDescription("Drop 11 cards for the price of 10!"); .setDescription("Drop 11 cards for the price of 10!");
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
if (!CoreClient.AllowDrops) { if (!CoreClient.AllowDrops) {
await interaction.reply(ErrorMessages.BotSyncing); await interaction.reply(ErrorMessages.BotSyncing);
return; return;

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import Config from "../database/entities/app/Config"; import Config from "../database/entities/app/Config";
import CardMetadataFunction from "../Functions/CardMetadataFunction"; import CardMetadataFunction from "../Functions/CardMetadataFunction";
@ -14,7 +14,7 @@ export default class Resync extends Command {
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;
const whitelistedUsers = process.env.BOT_ADMINS!.split(","); const whitelistedUsers = process.env.BOT_ADMINS!.split(",");

View file

@ -1,4 +1,4 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CacheType, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import Inventory from "../database/entities/app/Inventory"; import Inventory from "../database/entities/app/Inventory";
import { CardRarityToString, GetSacrificeAmount } from "../constants/CardRarity"; import { CardRarityToString, GetSacrificeAmount } from "../constants/CardRarity";
@ -23,7 +23,7 @@ export default class Sacrifice extends Command {
.setDescription("The amount to sacrifice (default 1)")); .setDescription("The amount to sacrifice (default 1)"));
} }
public override async execute(interaction: ChatInputCommandInteraction): Promise<void> { public override async execute(interaction: CommandInteraction<CacheType>): Promise<void> {
const cardnumber = interaction.options.get("cardnumber", true); const cardnumber = interaction.options.get("cardnumber", true);
const quantityInput = interaction.options.get("quantity")?.value ?? 1; const quantityInput = interaction.options.get("quantity")?.value ?? 1;

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
import AppLogger from "../client/appLogger"; import AppLogger from "../client/appLogger";
@ -26,7 +26,9 @@ export default class Series extends Command {
.setDescription("List all series")) as SlashCommandBuilder; .setDescription("List all series")) as SlashCommandBuilder;
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return;
switch (interaction.options.getSubcommand()) { switch (interaction.options.getSubcommand()) {
case "view": case "view":
await this.ViewSeries(interaction); await this.ViewSeries(interaction);
@ -40,7 +42,7 @@ export default class Series extends Command {
} }
} }
private async ViewSeries(interaction: ChatInputCommandInteraction) { private async ViewSeries(interaction: CommandInteraction) {
const id = interaction.options.get("id"); const id = interaction.options.get("id");
AppLogger.LogSilly("Commands/Series/View", `Parameters: id=${id?.value}`); AppLogger.LogSilly("Commands/Series/View", `Parameters: id=${id?.value}`);
@ -72,7 +74,7 @@ export default class Series extends Command {
} }
} }
private async ListSeries(interaction: ChatInputCommandInteraction) { private async ListSeries(interaction: CommandInteraction) {
const embed = SeriesHelper.GenerateSeriesListPage(0); const embed = SeriesHelper.GenerateSeriesListPage(0);
await interaction.reply({ embeds: [ embed!.embed ], components: [ embed!.row ]}); await interaction.reply({ embeds: [ embed!.embed ], components: [ embed!.row ]});

View file

@ -1,4 +1,4 @@
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, CacheType, CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../../type/command"; import { Command } from "../../type/command";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import Inventory from "../../database/entities/app/Inventory"; import Inventory from "../../database/entities/app/Inventory";
@ -22,7 +22,9 @@ export default class Dropnumber extends Command {
.setRequired(true)); .setRequired(true));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const cardNumber = interaction.options.get("cardnumber"); const cardNumber = interaction.options.get("cardnumber");
if (!cardNumber || !cardNumber.value) { if (!cardNumber || !cardNumber.value) {

View file

@ -1,4 +1,4 @@
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, CacheType, CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../../type/command"; import { Command } from "../../type/command";
import { CardRarity, CardRarityChoices, CardRarityParse } from "../../constants/CardRarity"; import { CardRarity, CardRarityChoices, CardRarityParse } from "../../constants/CardRarity";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
@ -24,7 +24,9 @@ export default class Droprarity extends Command {
.setChoices(CardRarityChoices)); .setChoices(CardRarityChoices));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const rarity = interaction.options.get("rarity"); const rarity = interaction.options.get("rarity");
if (!rarity || !rarity.value) { if (!rarity || !rarity.value) {

View file

@ -1,4 +1,4 @@
import {ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder} from "discord.js"; import {CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder} from "discord.js";
import {Command} from "../type/command"; import {Command} from "../type/command";
import {CoreClient} from "../client/client"; import {CoreClient} from "../client/client";
import {CardRarity} from "../constants/CardRarity"; import {CardRarity} from "../constants/CardRarity";
@ -14,7 +14,7 @@ export default class Stats extends Command {
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const allCards = CoreClient.Cards.flatMap(x => x.cards); const allCards = CoreClient.Cards.flatMap(x => x.cards);
const totalCards = allCards.length; const totalCards = allCards.length;

View file

@ -1,4 +1,4 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import Inventory from "../database/entities/app/Inventory"; import Inventory from "../database/entities/app/Inventory";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
@ -37,7 +37,7 @@ export default class Trade extends Command {
.setDescription("Amount to receive")); .setDescription("Amount to receive"));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const user = interaction.options.get("user", true).user!; const user = interaction.options.get("user", true).user!;
const give = interaction.options.get("give", true); const give = interaction.options.get("give", true);
const receive = interaction.options.get("receive", true); const receive = interaction.options.get("receive", true);
@ -122,7 +122,7 @@ export default class Trade extends Command {
await interaction.reply({ content: `${user}`, embeds: [ tradeEmbed ], components: [ row ] }); await interaction.reply({ content: `${user}`, embeds: [ tradeEmbed ], components: [ row ] });
} }
private async autoDecline(interaction: ChatInputCommandInteraction, user1Username: string, user2Username: string, user1CardNumber: string, user2CardNumber: string, user1CardName: string, user2CardName: string, user1Quantity: number, user2Quantity: number) { private async autoDecline(interaction: CommandInteraction, user1Username: string, user2Username: string, user1CardNumber: string, user2CardNumber: string, user1CardName: string, user2CardName: string, user1Quantity: number, user2Quantity: number) {
AppLogger.LogSilly("Commands/Trade/AutoDecline", `Auto declining trade between ${user1Username} and ${user2Username}`); AppLogger.LogSilly("Commands/Trade/AutoDecline", `Auto declining trade between ${user1Username} and ${user2Username}`);
const tradeEmbed = new EmbedBuilder() const tradeEmbed = new EmbedBuilder()

View file

@ -1,4 +1,4 @@
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import AppLogger from "../client/appLogger"; import AppLogger from "../client/appLogger";
import CardSearchHelper from "../helpers/CardSearchHelper"; import CardSearchHelper from "../helpers/CardSearchHelper";
@ -17,7 +17,7 @@ export default class View extends Command {
.setRequired(true)); .setRequired(true));
} }
public override async execute(interaction: ChatInputCommandInteraction) { public override async execute(interaction: CommandInteraction) {
const name = interaction.options.get("name", true); const name = interaction.options.get("name", true);
AppLogger.LogSilly("Commands/View", `Parameters: name=${name.value}`); AppLogger.LogSilly("Commands/View", `Parameters: name=${name.value}`);

View file

@ -1,8 +1,8 @@
import { ChatInputCommandInteraction } from "discord.js"; import { CommandInteraction } from "discord.js";
export abstract class Command { export abstract class Command {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- CommandBuilder type is dynamic depending on options and can't be strictly typed // eslint-disable-next-line @typescript-eslint/no-explicit-any -- CommandBuilder type is dynamic depending on options and can't be strictly typed
public CommandBuilder: any; public CommandBuilder: any;
abstract execute(interaction: ChatInputCommandInteraction): Promise<void>; abstract execute(interaction: CommandInteraction): Promise<void>;
} }

View file

@ -1,8 +1,8 @@
import { ChatInputCommandInteraction } from "../../__types__/discord.js"; import { CommandInteraction } from "../../__types__/discord.js";
export default function GenerateCommandInteractionMock(options?: { export default function GenerateCommandInteractionMock(options?: {
subcommand?: string, subcommand?: string,
}): ChatInputCommandInteraction{ }): CommandInteraction {
return { return {
deferReply: jest.fn(), deferReply: jest.fn(),
editReply: jest.fn(), editReply: jest.fn(),

View file

@ -18,7 +18,7 @@ export type ButtonInteraction = {
reply: jest.Func, reply: jest.Func,
} }
export type ChatInputCommandInteraction = { export type CommandInteraction = {
deferReply: jest.Func, deferReply: jest.Func,
editReply: jest.Func, editReply: jest.Func,
isChatInputCommand: jest.Func, isChatInputCommand: jest.Func,

View file

@ -1,7 +1,7 @@
import { ChatInputCommandInteraction } from "discord.js"; import { CommandInteraction } from "discord.js";
import Drop from "../../src/commands/drop"; import Drop from "../../src/commands/drop";
import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock"; import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock";
import { ChatInputCommandInteraction as ChatInputCommandInteractionMock } from "../__types__/discord.js"; import { CommandInteraction as CommandInteractionMock } from "../__types__/discord.js";
import { CoreClient } from "../../src/client/client"; import { CoreClient } from "../../src/client/client";
import Config from "../../src/database/entities/app/Config"; import Config from "../../src/database/entities/app/Config";
import User from "../../src/database/entities/app/User"; import User from "../../src/database/entities/app/User";
@ -25,7 +25,7 @@ beforeEach(() => {
describe("execute", () => { describe("execute", () => {
describe("GIVEN user is in the database", () => { describe("GIVEN user is in the database", () => {
let interaction: ChatInputCommandInteractionMock; let interaction: CommandInteractionMock;
let user: User; let user: User;
const randomCard = { const randomCard = {
card: { card: {
@ -62,7 +62,7 @@ describe("execute", () => {
// Act // Act
const drop = new Drop(); const drop = new Drop();
await drop.execute(interaction as unknown as ChatInputCommandInteraction); await drop.execute(interaction as unknown as CommandInteraction);
}); });
test("EXPECT user to be fetched", () => { test("EXPECT user to be fetched", () => {

View file

@ -4,7 +4,7 @@ import Use from "../../src/commands/effects/Use";
import Buy from "../../src/commands/effects/Buy"; import Buy from "../../src/commands/effects/Buy";
import AppLogger from "../../src/client/appLogger"; import AppLogger from "../../src/client/appLogger";
import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock"; import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock";
import { ChatInputCommandInteraction } from "discord.js"; import { CommandInteraction } from "discord.js";
jest.mock("../../src/commands/effects/List"); jest.mock("../../src/commands/effects/List");
jest.mock("../../src/commands/effects/Use"); jest.mock("../../src/commands/effects/Use");
@ -32,7 +32,7 @@ describe("execute", () => {
// Act // Act
const effects = new Effects(); const effects = new Effects();
await effects.execute(interaction as unknown as ChatInputCommandInteraction); await effects.execute(interaction as unknown as CommandInteraction);
// Assert // Assert
expect(List).toHaveBeenCalledTimes(1); expect(List).toHaveBeenCalledTimes(1);
@ -52,7 +52,7 @@ describe("execute", () => {
// Act // Act
const effects = new Effects(); const effects = new Effects();
await effects.execute(interaction as unknown as ChatInputCommandInteraction); await effects.execute(interaction as unknown as CommandInteraction);
// Assert // Assert
expect(Use).toHaveBeenCalledTimes(1); expect(Use).toHaveBeenCalledTimes(1);
@ -72,7 +72,7 @@ describe("execute", () => {
// Act // Act
const effects = new Effects(); const effects = new Effects();
await effects.execute(interaction as unknown as ChatInputCommandInteraction); await effects.execute(interaction as unknown as CommandInteraction);
// Assert // Assert
expect(Buy).toHaveBeenCalledTimes(1); expect(Buy).toHaveBeenCalledTimes(1);
@ -92,7 +92,7 @@ describe("execute", () => {
// Act // Act
const effects = new Effects(); const effects = new Effects();
await effects.execute(interaction as unknown as ChatInputCommandInteraction); await effects.execute(interaction as unknown as CommandInteraction);
// Assert // Assert
expect(AppLogger.LogError).toHaveBeenCalledTimes(1); expect(AppLogger.LogError).toHaveBeenCalledTimes(1);

2105
yarn.lock

File diff suppressed because it is too large Load diff