Upgrade discord.js
All checks were successful
Test / build (push) Successful in 53s

This commit is contained in:
Ethan Lane 2025-06-19 19:14:40 +01:00
parent 983195c477
commit 2bf961d1e5
32 changed files with 88 additions and 106 deletions

View file

@ -25,13 +25,13 @@
"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.0", "@discordjs/rest": "^2.5.1",
"axios": "^1.10.0", "axios": "^1.10.0",
"body-parser": "^2.2.0", "body-parser": "^2.2.0",
"canvas": "^3.1.1", "canvas": "^3.1.1",
"clone-deep": "^4.0.1", "clone-deep": "^4.0.1",
"cron": "^4.3.1", "cron": "^4.3.1",
"discord.js": "^14.19.3", "discord.js": "^14.20.0",
"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",

View file

@ -4,8 +4,6 @@ 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,12 +1,10 @@
import { Interaction } from "discord.js"; import { ChatInputCommandInteraction } 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: Interaction) { public static async onChatInput(interaction: ChatInputCommandInteraction) {
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,8 +4,6 @@ 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, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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, CommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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,9 +42,7 @@ export default class Effects extends Command {
.setMinValue(1))); .setMinValue(1)));
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CommandInteraction } from "discord.js"; import { ChatInputCommandInteraction } from "discord.js";
import EffectHelper from "../../helpers/EffectHelper"; 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 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 { CommandInteraction } from "discord.js"; import { ChatInputCommandInteraction } from "discord.js";
import EffectHelper from "../../helpers/EffectHelper"; 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 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, CommandInteraction, EmbedBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, 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: CommandInteraction) { export default async function Use(interaction: ChatInputCommandInteraction) {
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 { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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,9 +16,7 @@ export default class Gdrivesync extends Command {
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); .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(","); 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 { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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,9 +45,7 @@ export default class Give extends Command {
.setRequired(true))); .setRequired(true)));
} }
public override async execute(interaction: CommandInteraction<CacheType>) { public override async execute(interaction: ChatInputCommandInteraction) {
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)) {
@ -65,7 +63,7 @@ export default class Give extends Command {
} }
} }
private async GiveCard(interaction: CommandInteraction) { private async GiveCard(interaction: ChatInputCommandInteraction) {
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;
@ -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}`); 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 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, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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, CommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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: CommandInteraction<CacheType>) { public override async execute(interaction: ChatInputCommandInteraction) {
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, CacheType, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, 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: CommandInteraction<CacheType>): Promise<void> { public override async execute(interaction: ChatInputCommandInteraction): 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 { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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,9 +26,7 @@ export default class Series extends Command {
.setDescription("List all series")) as SlashCommandBuilder; .setDescription("List all series")) as SlashCommandBuilder;
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
if (!interaction.isChatInputCommand()) return;
switch (interaction.options.getSubcommand()) { switch (interaction.options.getSubcommand()) {
case "view": case "view":
await this.ViewSeries(interaction); 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"); const id = interaction.options.get("id");
AppLogger.LogSilly("Commands/Series/View", `Parameters: id=${id?.value}`); 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); 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, CacheType, CommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, ChatInputCommandInteraction, 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,9 +22,7 @@ export default class Dropnumber extends Command {
.setRequired(true)); .setRequired(true));
} }
public override async execute(interaction: CommandInteraction<CacheType>) { public override async execute(interaction: ChatInputCommandInteraction) {
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, CacheType, CommandInteraction, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, ChatInputCommandInteraction, 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,9 +24,7 @@ export default class Droprarity extends Command {
.setChoices(CardRarityChoices)); .setChoices(CardRarityChoices));
} }
public override async execute(interaction: CommandInteraction<CacheType>) { public override async execute(interaction: ChatInputCommandInteraction) {
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 {CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder} from "discord.js"; import {ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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: 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}`); 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 { CommandInteraction, SlashCommandBuilder } from "discord.js"; import { ChatInputCommandInteraction, 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: CommandInteraction) { public override async execute(interaction: ChatInputCommandInteraction) {
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 { CommandInteraction } from "discord.js"; import { ChatInputCommandInteraction } 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: CommandInteraction): Promise<void>; abstract execute(interaction: ChatInputCommandInteraction): Promise<void>;
} }

View file

@ -1,8 +1,8 @@
import { CommandInteraction } from "../../__types__/discord.js"; import { ChatInputCommandInteraction } from "../../__types__/discord.js";
export default function GenerateCommandInteractionMock(options?: { export default function GenerateCommandInteractionMock(options?: {
subcommand?: string, subcommand?: string,
}): CommandInteraction { }): ChatInputCommandInteraction{
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 CommandInteraction = { export type ChatInputCommandInteraction = {
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 { CommandInteraction } from "discord.js"; import { ChatInputCommandInteraction } 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 { CommandInteraction as CommandInteractionMock } from "../__types__/discord.js"; import { ChatInputCommandInteraction as ChatInputCommandInteractionMock } 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: CommandInteractionMock; let interaction: ChatInputCommandInteractionMock;
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 CommandInteraction); await drop.execute(interaction as unknown as ChatInputCommandInteraction);
}); });
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 { CommandInteraction } from "discord.js"; import { ChatInputCommandInteraction } 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 CommandInteraction); await effects.execute(interaction as unknown as ChatInputCommandInteraction);
// 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 CommandInteraction); await effects.execute(interaction as unknown as ChatInputCommandInteraction);
// 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 CommandInteraction); await effects.execute(interaction as unknown as ChatInputCommandInteraction);
// 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 CommandInteraction); await effects.execute(interaction as unknown as ChatInputCommandInteraction);
// Assert // Assert
expect(AppLogger.LogError).toHaveBeenCalledTimes(1); expect(AppLogger.LogError).toHaveBeenCalledTimes(1);

View file

@ -456,10 +456,10 @@
dependencies: dependencies:
discord-api-types "^0.38.1" discord-api-types "^0.38.1"
"@discordjs/rest@^2.5.0": "@discordjs/rest@^2.5.1":
version "2.5.0" version "2.5.1"
resolved "https://registry.yarnpkg.com/@discordjs/rest/-/rest-2.5.0.tgz#fc4c5e23bee31f4df98e6e148e9d22f8eb031924" resolved "https://registry.yarnpkg.com/@discordjs/rest/-/rest-2.5.1.tgz#a6bde4d08f0e23bd763506cc1fcc83564afee077"
integrity sha512-PWhchxTzpn9EV3vvPRpwS0EE2rNYB9pvzDU/eLLW3mByJl0ZHZjHI2/wA8EbH2gRMQV7nu+0FoDF84oiPl8VAQ== integrity sha512-Tg9840IneBcbrAjcGaQzHUJWFNq1MMWZjTdjJ0WS/89IffaNKc++iOvffucPxQTF/gviO9+9r8kEPea1X5J2Dw==
dependencies: dependencies:
"@discordjs/collection" "^2.1.1" "@discordjs/collection" "^2.1.1"
"@discordjs/util" "^1.1.1" "@discordjs/util" "^1.1.1"
@ -469,20 +469,20 @@
discord-api-types "^0.38.1" discord-api-types "^0.38.1"
magic-bytes.js "^1.10.0" magic-bytes.js "^1.10.0"
tslib "^2.6.3" tslib "^2.6.3"
undici "6.21.1" undici "6.21.3"
"@discordjs/util@^1.1.0", "@discordjs/util@^1.1.1": "@discordjs/util@^1.1.0", "@discordjs/util@^1.1.1":
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/@discordjs/util/-/util-1.1.1.tgz#bafcde0faa116c834da1258d78ec237080bbab29" resolved "https://registry.yarnpkg.com/@discordjs/util/-/util-1.1.1.tgz#bafcde0faa116c834da1258d78ec237080bbab29"
integrity sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g== integrity sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==
"@discordjs/ws@^1.2.2": "@discordjs/ws@^1.2.3":
version "1.2.2" version "1.2.3"
resolved "https://registry.yarnpkg.com/@discordjs/ws/-/ws-1.2.2.tgz#bab8d16ea2fe9eb205351bd8896e03307bf42fdb" resolved "https://registry.yarnpkg.com/@discordjs/ws/-/ws-1.2.3.tgz#7cf80d8528366c6810c02b43ca49958ef154c3d4"
integrity sha512-dyfq7yn0wO0IYeYOs3z79I6/HumhmKISzFL0Z+007zQJMtAFGtt3AEoq1nuLXtcunUE5YYYQqgKvybXukAK8/w== integrity sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==
dependencies: dependencies:
"@discordjs/collection" "^2.1.0" "@discordjs/collection" "^2.1.0"
"@discordjs/rest" "^2.5.0" "@discordjs/rest" "^2.5.1"
"@discordjs/util" "^1.1.0" "@discordjs/util" "^1.1.0"
"@sapphire/async-queue" "^1.5.2" "@sapphire/async-queue" "^1.5.2"
"@types/ws" "^8.5.10" "@types/ws" "^8.5.10"
@ -2723,24 +2723,24 @@ discord-api-types@^0.38.1:
resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.38.8.tgz#ad69f82c85a510c5778ca152dfa9a91b9e43d8a6" resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.38.8.tgz#ad69f82c85a510c5778ca152dfa9a91b9e43d8a6"
integrity sha512-xuRXPD44FcbKHrQK15FS1HFlMRNJtsaZou/SVws18vQ7zHqmlxyDktMkZpyvD6gE2ctGOVYC/jUyoMMAyBWfcw== integrity sha512-xuRXPD44FcbKHrQK15FS1HFlMRNJtsaZou/SVws18vQ7zHqmlxyDktMkZpyvD6gE2ctGOVYC/jUyoMMAyBWfcw==
discord.js@^14.19.3: discord.js@^14.20.0:
version "14.19.3" version "14.20.0"
resolved "https://registry.yarnpkg.com/discord.js/-/discord.js-14.19.3.tgz#ed08c61ad300efc3033ecf2b70f28a68d95b138a" resolved "https://registry.yarnpkg.com/discord.js/-/discord.js-14.20.0.tgz#eaac6485f756714d31c00b3dcb7ebfbc92beb5d3"
integrity sha512-lncTRk0k+8Q5D3nThnODBR8fR8x2fM798o8Vsr40Krx0DjPwpZCuxxTcFMrXMQVOqM1QB9wqWgaXPg3TbmlHqA== integrity sha512-5fRTptK2vpuz+bTuAEUQLSo/3AgCSLHl6Mm9+/ofb+8cbbnjWllhtaqRBq7XcpzlBnfNEugKv8HvCwcOtIHpCg==
dependencies: dependencies:
"@discordjs/builders" "^1.11.2" "@discordjs/builders" "^1.11.2"
"@discordjs/collection" "1.5.3" "@discordjs/collection" "1.5.3"
"@discordjs/formatters" "^0.6.1" "@discordjs/formatters" "^0.6.1"
"@discordjs/rest" "^2.5.0" "@discordjs/rest" "^2.5.1"
"@discordjs/util" "^1.1.1" "@discordjs/util" "^1.1.1"
"@discordjs/ws" "^1.2.2" "@discordjs/ws" "^1.2.3"
"@sapphire/snowflake" "3.5.3" "@sapphire/snowflake" "3.5.3"
discord-api-types "^0.38.1" discord-api-types "^0.38.1"
fast-deep-equal "3.1.3" fast-deep-equal "3.1.3"
lodash.snakecase "4.1.1" lodash.snakecase "4.1.1"
magic-bytes.js "^1.10.0" magic-bytes.js "^1.10.0"
tslib "^2.6.3" tslib "^2.6.3"
undici "6.21.1" undici "6.21.3"
dot-prop@^9.0.0: dot-prop@^9.0.0:
version "9.0.0" version "9.0.0"
@ -6532,10 +6532,10 @@ undici-types@~7.8.0:
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.8.0.tgz#de00b85b710c54122e44fbfd911f8d70174cd294" resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.8.0.tgz#de00b85b710c54122e44fbfd911f8d70174cd294"
integrity sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw== integrity sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==
undici@6.21.1: undici@6.21.3:
version "6.21.1" version "6.21.3"
resolved "https://registry.yarnpkg.com/undici/-/undici-6.21.1.tgz#336025a14162e6837e44ad7b819b35b6c6af0e05" resolved "https://registry.yarnpkg.com/undici/-/undici-6.21.3.tgz#185752ad92c3d0efe7a7d1f6854a50f83b552d7a"
integrity sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ== integrity sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==
unicorn-magic@^0.1.0: unicorn-magic@^0.1.0:
version "0.1.0" version "0.1.0"