Compare commits
9 commits
e4c37f9418
...
2bf961d1e5
Author | SHA1 | Date | |
---|---|---|---|
2bf961d1e5 | |||
983195c477 | |||
30e557692e | |||
bd1f560d17 | |||
12cfc8c3a3 | |||
13ca100b84 | |||
1a30faf678 | |||
7c6e884a22 | |||
5bfa3509c2 |
32 changed files with 1240 additions and 1053 deletions
40
package.json
40
package.json
|
@ -25,40 +25,42 @@
|
|||
"homepage": "https://gitea.vylpes.xyz/External/card-drop",
|
||||
"funding": "https://ko-fi.com/vylpes",
|
||||
"dependencies": {
|
||||
"@discordjs/rest": "^2.5.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",
|
||||
"@discordjs/rest": "^2.5.1",
|
||||
"axios": "^1.10.0",
|
||||
"body-parser": "^2.2.0",
|
||||
"canvas": "^3.1.0",
|
||||
"canvas": "^3.1.1",
|
||||
"clone-deep": "^4.0.1",
|
||||
"cron": "^4.3.1",
|
||||
"discord.js": "^14.19.3",
|
||||
"discord.js": "^14.20.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"express": "^5.1.0",
|
||||
"fuse.js": "^7.1.0",
|
||||
"glob": "^11.0.2",
|
||||
"jest": "^29.0.0",
|
||||
"jest-mock-extended": "^4.0.0-beta1",
|
||||
"glob": "^11.0.3",
|
||||
"jest": "^30.0.2",
|
||||
"jest-mock-extended": "^4.0.0",
|
||||
"jimp": "^1.6.0",
|
||||
"minimatch": "10.0.1",
|
||||
"minimatch": "10.0.3",
|
||||
"mysql": "^2.18.1",
|
||||
"ts-jest": "^29.3.4",
|
||||
"typeorm": "0.3.20",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"ts-jest": "^29.4.0",
|
||||
"typeorm": "0.3.24",
|
||||
"winston": "^3.17.0",
|
||||
"winston-daily-rotate-file": "^5.0.0",
|
||||
"winston-discord-transport": "^1.3.0"
|
||||
},
|
||||
"resolutions": {},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.15.29",
|
||||
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
||||
"@typescript-eslint/parser": "^8.33.1",
|
||||
"eslint": "^9.28.0",
|
||||
"@jest/globals": "^30.0.2",
|
||||
"@types/clone-deep": "^4.0.4",
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/jest": "^30.0.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",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.33.1"
|
||||
"typescript-eslint": "^8.34.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import AppLogger from "../appLogger";
|
|||
|
||||
export default class Button {
|
||||
public static async onButtonClicked(interaction: ButtonInteraction) {
|
||||
if (!interaction.isButton) return;
|
||||
|
||||
const item = CoreClient.buttonEvents.find(x => x.ButtonId == interaction.customId.split(" ")[0]);
|
||||
|
||||
if (!item) {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import { Interaction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
import { CoreClient } from "../client";
|
||||
import ICommandItem from "../../contracts/ICommandItem";
|
||||
import AppLogger from "../appLogger";
|
||||
|
||||
export default class ChatInputCommand {
|
||||
public static async onChatInput(interaction: Interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
public static async onChatInput(interaction: ChatInputCommandInteraction) {
|
||||
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);
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ import AppLogger from "../appLogger";
|
|||
|
||||
export default class StringDropdown {
|
||||
public static async onStringDropdownSelected(interaction: StringSelectMenuInteraction) {
|
||||
if (!interaction.isStringSelectMenu()) return;
|
||||
|
||||
const item = CoreClient.stringDropdowns.find(x => x.DropdownId == interaction.customId.split(" ")[0]);
|
||||
|
||||
if (!item) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import EmbedColours from "../constants/EmbedColours";
|
||||
import { Command } from "../type/command";
|
||||
|
||||
|
@ -11,7 +11,7 @@ export default class About extends Command {
|
|||
.setDescription("About Bot");
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const fundingLink = process.env.ABOUT_FUNDING;
|
||||
const repoLink = process.env.ABOUT_REPO;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import EmbedColours from "../constants/EmbedColours";
|
||||
import { Command } from "../type/command";
|
||||
import User from "../database/entities/app/User";
|
||||
|
@ -13,7 +13,7 @@ export default class AllBalance extends Command {
|
|||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const users = await User.FetchAll(User);
|
||||
|
||||
const filteredUsers = users.filter(x => x.Currency > 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import User from "../database/entities/app/User";
|
||||
import EmbedColours from "../constants/EmbedColours";
|
||||
|
@ -12,7 +12,7 @@ export default class Balance extends Command {
|
|||
.setDescription("Get your currency balance");
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const user = await User.FetchOneById(User, interaction.user.id);
|
||||
|
||||
const userBalance = user != null ? user.Currency : 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import User from "../database/entities/app/User";
|
||||
import CardConstants from "../constants/CardConstants";
|
||||
|
@ -13,7 +13,7 @@ export default class Daily extends Command {
|
|||
.setDescription("Gain bonus currency, once a day");
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
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));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AttachmentBuilder, CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { readFileSync } from "fs";
|
||||
import { CoreClient } from "../client/client";
|
||||
|
@ -23,7 +23,7 @@ export default class Drop extends Command {
|
|||
.setDescription("Summon a new card drop");
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
if (!CoreClient.AllowDrops) {
|
||||
await interaction.reply(ErrorMessages.BotSyncing);
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { EffectChoices } from "../constants/EffectDetails";
|
||||
import AppLogger from "../client/appLogger";
|
||||
|
@ -42,9 +42,7 @@ export default class Effects extends Command {
|
|||
.setMinValue(1)));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
|
||||
switch (subcommand) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
import EffectHelper from "../../helpers/EffectHelper";
|
||||
|
||||
export default async function Buy(interaction: CommandInteraction) {
|
||||
export default async function Buy(interaction: ChatInputCommandInteraction) {
|
||||
const id = interaction.options.get("id", true).value!;
|
||||
const quantity = interaction.options.get("quantity")?.value ?? 1;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
import EffectHelper from "../../helpers/EffectHelper";
|
||||
|
||||
export default async function List(interaction: CommandInteraction) {
|
||||
export default async function List(interaction: ChatInputCommandInteraction) {
|
||||
const pageOption = interaction.options.get("page");
|
||||
|
||||
const page = !isNaN(Number(pageOption?.value)) ? Number(pageOption?.value) : 1;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder } from "discord.js";
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||
import { EffectDetails } from "../../constants/EffectDetails";
|
||||
import AppLogger from "../../client/appLogger";
|
||||
import EffectHelper from "../../helpers/EffectHelper";
|
||||
import TimeLengthInput from "../../helpers/TimeLengthInput";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
|
||||
export default async function Use(interaction: CommandInteraction) {
|
||||
export default async function Use(interaction: ChatInputCommandInteraction) {
|
||||
const id = interaction.options.get("id", true).value!.toString();
|
||||
|
||||
const effectDetail = EffectDetails.get(id);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { ExecException, exec } from "child_process";
|
||||
import { CoreClient } from "../client/client";
|
||||
|
@ -16,9 +16,7 @@ export default class Gdrivesync extends Command {
|
|||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const whitelistedUsers = process.env.BOT_ADMINS!.split(",");
|
||||
|
||||
if (!whitelistedUsers.find(x => x == interaction.user.id)) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { CoreClient } from "../client/client";
|
||||
import Config from "../database/entities/app/Config";
|
||||
|
@ -45,9 +45,7 @@ export default class Give extends Command {
|
|||
.setRequired(true)));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const whitelistedUsers = process.env.BOT_ADMINS!.split(",");
|
||||
|
||||
if (!whitelistedUsers.find(x => x == interaction.user.id)) {
|
||||
|
@ -65,7 +63,7 @@ export default class Give extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
private async GiveCard(interaction: CommandInteraction) {
|
||||
private async GiveCard(interaction: ChatInputCommandInteraction) {
|
||||
if (!CoreClient.AllowDrops) {
|
||||
await interaction.reply("Bot is currently syncing, please wait until its done.");
|
||||
return;
|
||||
|
@ -101,7 +99,7 @@ export default class Give extends Command {
|
|||
await interaction.reply(`Card ${card.card.name} given to ${user.username}, they now have ${inventory.Quantity}`);
|
||||
}
|
||||
|
||||
private async GiveCurrency(interaction: CommandInteraction) {
|
||||
private async GiveCurrency(interaction: ChatInputCommandInteraction) {
|
||||
const amount = interaction.options.get("amount", true);
|
||||
const user = interaction.options.get("user", true).user!;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AttachmentBuilder, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js";
|
||||
import { AttachmentBuilder, ChatInputCommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { CoreClient } from "../client/client";
|
||||
import { readFileSync } from "fs";
|
||||
|
@ -21,7 +21,7 @@ export default class Id extends Command {
|
|||
.setRequired(true));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const cardNumber = interaction.options.get("cardnumber");
|
||||
|
||||
AppLogger.LogSilly("Commands/View", `Parameters: cardNumber=${cardNumber?.value}`);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import InventoryHelper from "../helpers/InventoryHelper";
|
||||
import AppLogger from "../client/appLogger";
|
||||
|
@ -20,7 +20,7 @@ export default class Inventory extends Command {
|
|||
.setDescription("The user to view (Defaults to yourself)"));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const page = interaction.options.get("page");
|
||||
const userOption = interaction.options.get("user");
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AttachmentBuilder, CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { CoreClient } from "../client/client";
|
||||
import ErrorMessages from "../constants/ErrorMessages";
|
||||
|
@ -21,7 +21,7 @@ export default class Multidrop extends Command {
|
|||
.setDescription("Drop 11 cards for the price of 10!");
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
if (!CoreClient.AllowDrops) {
|
||||
await interaction.reply(ErrorMessages.BotSyncing);
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import Config from "../database/entities/app/Config";
|
||||
import CardMetadataFunction from "../Functions/CardMetadataFunction";
|
||||
|
@ -14,7 +14,7 @@ export default class Resync extends Command {
|
|||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const whitelistedUsers = process.env.BOT_ADMINS!.split(",");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CacheType, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import Inventory from "../database/entities/app/Inventory";
|
||||
import { CardRarityToString, GetSacrificeAmount } from "../constants/CardRarity";
|
||||
|
@ -23,7 +23,7 @@ export default class Sacrifice extends Command {
|
|||
.setDescription("The amount to sacrifice (default 1)"));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>): Promise<void> {
|
||||
public override async execute(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||
const cardnumber = interaction.options.get("cardnumber", true);
|
||||
const quantityInput = interaction.options.get("quantity")?.value ?? 1;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { CoreClient } from "../client/client";
|
||||
import AppLogger from "../client/appLogger";
|
||||
|
@ -26,9 +26,7 @@ export default class Series extends Command {
|
|||
.setDescription("List all series")) as SlashCommandBuilder;
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case "view":
|
||||
await this.ViewSeries(interaction);
|
||||
|
@ -42,7 +40,7 @@ export default class Series extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
private async ViewSeries(interaction: CommandInteraction) {
|
||||
private async ViewSeries(interaction: ChatInputCommandInteraction) {
|
||||
const id = interaction.options.get("id");
|
||||
|
||||
AppLogger.LogSilly("Commands/Series/View", `Parameters: id=${id?.value}`);
|
||||
|
@ -74,7 +72,7 @@ export default class Series extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
private async ListSeries(interaction: CommandInteraction) {
|
||||
private async ListSeries(interaction: ChatInputCommandInteraction) {
|
||||
const embed = SeriesHelper.GenerateSeriesListPage(0);
|
||||
|
||||
await interaction.reply({ embeds: [ embed!.embed ], components: [ embed!.row ]});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AttachmentBuilder, CacheType, CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../../type/command";
|
||||
import { readFileSync } from "fs";
|
||||
import Inventory from "../../database/entities/app/Inventory";
|
||||
|
@ -22,9 +22,7 @@ export default class Dropnumber extends Command {
|
|||
.setRequired(true));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const cardNumber = interaction.options.get("cardnumber");
|
||||
|
||||
if (!cardNumber || !cardNumber.value) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AttachmentBuilder, CacheType, CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { AttachmentBuilder, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../../type/command";
|
||||
import { CardRarity, CardRarityChoices, CardRarityParse } from "../../constants/CardRarity";
|
||||
import { readFileSync } from "fs";
|
||||
|
@ -24,9 +24,7 @@ export default class Droprarity extends Command {
|
|||
.setChoices(CardRarityChoices));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction<CacheType>) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const rarity = interaction.options.get("rarity");
|
||||
|
||||
if (!rarity || !rarity.value) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder} from "discord.js";
|
||||
import {ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder} from "discord.js";
|
||||
import {Command} from "../type/command";
|
||||
import {CoreClient} from "../client/client";
|
||||
import {CardRarity} from "../constants/CardRarity";
|
||||
|
@ -14,7 +14,7 @@ export default class Stats extends Command {
|
|||
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const allCards = CoreClient.Cards.flatMap(x => x.cards);
|
||||
|
||||
const totalCards = allCards.length;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import Inventory from "../database/entities/app/Inventory";
|
||||
import { CoreClient } from "../client/client";
|
||||
|
@ -37,7 +37,7 @@ export default class Trade extends Command {
|
|||
.setDescription("Amount to receive"));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const user = interaction.options.get("user", true).user!;
|
||||
const give = interaction.options.get("give", 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 ] });
|
||||
}
|
||||
|
||||
private async autoDecline(interaction: CommandInteraction, user1Username: string, user2Username: string, user1CardNumber: string, user2CardNumber: string, user1CardName: string, user2CardName: string, user1Quantity: number, user2Quantity: number) {
|
||||
private async autoDecline(interaction: ChatInputCommandInteraction, 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}`);
|
||||
|
||||
const tradeEmbed = new EmbedBuilder()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import AppLogger from "../client/appLogger";
|
||||
import CardSearchHelper from "../helpers/CardSearchHelper";
|
||||
|
@ -17,7 +17,7 @@ export default class View extends Command {
|
|||
.setRequired(true));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
public override async execute(interaction: ChatInputCommandInteraction) {
|
||||
const name = interaction.options.get("name", true);
|
||||
|
||||
AppLogger.LogSilly("Commands/View", `Parameters: name=${name.value}`);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { CommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
|
||||
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
|
||||
public CommandBuilder: any;
|
||||
|
||||
abstract execute(interaction: CommandInteraction): Promise<void>;
|
||||
abstract execute(interaction: ChatInputCommandInteraction): Promise<void>;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { CommandInteraction } from "../../__types__/discord.js";
|
||||
import { ChatInputCommandInteraction } from "../../__types__/discord.js";
|
||||
|
||||
export default function GenerateCommandInteractionMock(options?: {
|
||||
subcommand?: string,
|
||||
}): CommandInteraction {
|
||||
}): ChatInputCommandInteraction{
|
||||
return {
|
||||
deferReply: jest.fn(),
|
||||
editReply: jest.fn(),
|
||||
|
|
|
@ -18,7 +18,7 @@ export type ButtonInteraction = {
|
|||
reply: jest.Func,
|
||||
}
|
||||
|
||||
export type CommandInteraction = {
|
||||
export type ChatInputCommandInteraction = {
|
||||
deferReply: jest.Func,
|
||||
editReply: jest.Func,
|
||||
isChatInputCommand: jest.Func,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
import Drop from "../../src/commands/drop";
|
||||
import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock";
|
||||
import { CommandInteraction as CommandInteractionMock } from "../__types__/discord.js";
|
||||
import { ChatInputCommandInteraction as ChatInputCommandInteractionMock } from "../__types__/discord.js";
|
||||
import { CoreClient } from "../../src/client/client";
|
||||
import Config from "../../src/database/entities/app/Config";
|
||||
import User from "../../src/database/entities/app/User";
|
||||
|
@ -25,7 +25,7 @@ beforeEach(() => {
|
|||
|
||||
describe("execute", () => {
|
||||
describe("GIVEN user is in the database", () => {
|
||||
let interaction: CommandInteractionMock;
|
||||
let interaction: ChatInputCommandInteractionMock;
|
||||
let user: User;
|
||||
const randomCard = {
|
||||
card: {
|
||||
|
@ -62,7 +62,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const drop = new Drop();
|
||||
await drop.execute(interaction as unknown as CommandInteraction);
|
||||
await drop.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
});
|
||||
|
||||
test("EXPECT user to be fetched", () => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import Use from "../../src/commands/effects/Use";
|
|||
import Buy from "../../src/commands/effects/Buy";
|
||||
import AppLogger from "../../src/client/appLogger";
|
||||
import GenerateCommandInteractionMock from "../__functions__/discord.js/GenerateCommandInteractionMock";
|
||||
import { CommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
|
||||
jest.mock("../../src/commands/effects/List");
|
||||
jest.mock("../../src/commands/effects/Use");
|
||||
|
@ -32,7 +32,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(List).toHaveBeenCalledTimes(1);
|
||||
|
@ -52,7 +52,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(Use).toHaveBeenCalledTimes(1);
|
||||
|
@ -72,7 +72,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(Buy).toHaveBeenCalledTimes(1);
|
||||
|
@ -92,7 +92,7 @@ describe("execute", () => {
|
|||
|
||||
// Act
|
||||
const effects = new Effects();
|
||||
await effects.execute(interaction as unknown as CommandInteraction);
|
||||
await effects.execute(interaction as unknown as ChatInputCommandInteraction);
|
||||
|
||||
// Assert
|
||||
expect(AppLogger.LogError).toHaveBeenCalledTimes(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue