diff --git a/package.json b/package.json index ec85946..4388727 100644 --- a/package.json +++ b/package.json @@ -25,13 +25,13 @@ "homepage": "https://gitea.vylpes.xyz/External/card-drop", "funding": "https://ko-fi.com/vylpes", "dependencies": { - "@discordjs/rest": "^2.5.0", + "@discordjs/rest": "^2.5.1", "axios": "^1.10.0", "body-parser": "^2.2.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", diff --git a/src/client/interactionCreate/Button.ts b/src/client/interactionCreate/Button.ts index b8abbfc..58e6000 100644 --- a/src/client/interactionCreate/Button.ts +++ b/src/client/interactionCreate/Button.ts @@ -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) { diff --git a/src/client/interactionCreate/ChatInputCommand.ts b/src/client/interactionCreate/ChatInputCommand.ts index 47f7b37..5bb3a09 100644 --- a/src/client/interactionCreate/ChatInputCommand.ts +++ b/src/client/interactionCreate/ChatInputCommand.ts @@ -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); diff --git a/src/client/interactionCreate/StringDropdown.ts b/src/client/interactionCreate/StringDropdown.ts index 608b81b..ff4da2a 100644 --- a/src/client/interactionCreate/StringDropdown.ts +++ b/src/client/interactionCreate/StringDropdown.ts @@ -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) { diff --git a/src/commands/about.ts b/src/commands/about.ts index 3bfcdac..e2db9fe 100644 --- a/src/commands/about.ts +++ b/src/commands/about.ts @@ -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; diff --git a/src/commands/allbalance.ts b/src/commands/allbalance.ts index 0874e54..0e2925c 100644 --- a/src/commands/allbalance.ts +++ b/src/commands/allbalance.ts @@ -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) diff --git a/src/commands/balance.ts b/src/commands/balance.ts index c8f087c..d10d0f6 100644 --- a/src/commands/balance.ts +++ b/src/commands/balance.ts @@ -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; diff --git a/src/commands/daily.ts b/src/commands/daily.ts index 65d69fc..f09330e 100644 --- a/src/commands/daily.ts +++ b/src/commands/daily.ts @@ -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)); diff --git a/src/commands/drop.ts b/src/commands/drop.ts index b6ad224..a826e9f 100644 --- a/src/commands/drop.ts +++ b/src/commands/drop.ts @@ -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; diff --git a/src/commands/effects.ts b/src/commands/effects.ts index cd6d1d4..452d940 100644 --- a/src/commands/effects.ts +++ b/src/commands/effects.ts @@ -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) { diff --git a/src/commands/effects/Buy.ts b/src/commands/effects/Buy.ts index 3ebf587..3e00031 100644 --- a/src/commands/effects/Buy.ts +++ b/src/commands/effects/Buy.ts @@ -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; diff --git a/src/commands/effects/List.ts b/src/commands/effects/List.ts index 14e6085..f5fec97 100644 --- a/src/commands/effects/List.ts +++ b/src/commands/effects/List.ts @@ -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; diff --git a/src/commands/effects/Use.ts b/src/commands/effects/Use.ts index 9f72ae0..ac25317 100644 --- a/src/commands/effects/Use.ts +++ b/src/commands/effects/Use.ts @@ -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); diff --git a/src/commands/gdrivesync.ts b/src/commands/gdrivesync.ts index b02c873..8a37ef3 100644 --- a/src/commands/gdrivesync.ts +++ b/src/commands/gdrivesync.ts @@ -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) { - 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)) { diff --git a/src/commands/give.ts b/src/commands/give.ts index 35dfa04..e0ecd5c 100644 --- a/src/commands/give.ts +++ b/src/commands/give.ts @@ -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) { - 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!; diff --git a/src/commands/id.ts b/src/commands/id.ts index 0f11aaa..0dc7844 100644 --- a/src/commands/id.ts +++ b/src/commands/id.ts @@ -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}`); diff --git a/src/commands/inventory.ts b/src/commands/inventory.ts index deb4735..ef915f6 100644 --- a/src/commands/inventory.ts +++ b/src/commands/inventory.ts @@ -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"); diff --git a/src/commands/multidrop.ts b/src/commands/multidrop.ts index 82d19fe..dab5d0d 100644 --- a/src/commands/multidrop.ts +++ b/src/commands/multidrop.ts @@ -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; diff --git a/src/commands/resync.ts b/src/commands/resync.ts index f90c96c..6071b31 100644 --- a/src/commands/resync.ts +++ b/src/commands/resync.ts @@ -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) { + public override async execute(interaction: ChatInputCommandInteraction) { if (!interaction.isChatInputCommand()) return; const whitelistedUsers = process.env.BOT_ADMINS!.split(","); diff --git a/src/commands/sacrifice.ts b/src/commands/sacrifice.ts index a44a69e..123e41a 100644 --- a/src/commands/sacrifice.ts +++ b/src/commands/sacrifice.ts @@ -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): Promise { + public override async execute(interaction: ChatInputCommandInteraction): Promise { const cardnumber = interaction.options.get("cardnumber", true); const quantityInput = interaction.options.get("quantity")?.value ?? 1; diff --git a/src/commands/series.ts b/src/commands/series.ts index 16ae0db..f3595ff 100644 --- a/src/commands/series.ts +++ b/src/commands/series.ts @@ -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 ]}); diff --git a/src/commands/stage/dropnumber.ts b/src/commands/stage/dropnumber.ts index c61ed43..e931b99 100644 --- a/src/commands/stage/dropnumber.ts +++ b/src/commands/stage/dropnumber.ts @@ -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) { - if (!interaction.isChatInputCommand()) return; - + public override async execute(interaction: ChatInputCommandInteraction) { const cardNumber = interaction.options.get("cardnumber"); if (!cardNumber || !cardNumber.value) { diff --git a/src/commands/stage/droprarity.ts b/src/commands/stage/droprarity.ts index f776930..3eae02a 100644 --- a/src/commands/stage/droprarity.ts +++ b/src/commands/stage/droprarity.ts @@ -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) { - if (!interaction.isChatInputCommand()) return; - + public override async execute(interaction: ChatInputCommandInteraction) { const rarity = interaction.options.get("rarity"); if (!rarity || !rarity.value) { diff --git a/src/commands/stats.ts b/src/commands/stats.ts index e65ab93..1133382 100644 --- a/src/commands/stats.ts +++ b/src/commands/stats.ts @@ -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; diff --git a/src/commands/trade.ts b/src/commands/trade.ts index fcd312a..21ebdda 100644 --- a/src/commands/trade.ts +++ b/src/commands/trade.ts @@ -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() diff --git a/src/commands/view.ts b/src/commands/view.ts index 9a1d447..fb5cb91 100644 --- a/src/commands/view.ts +++ b/src/commands/view.ts @@ -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}`); diff --git a/src/type/command.ts b/src/type/command.ts index 458a81e..621b5af 100644 --- a/src/type/command.ts +++ b/src/type/command.ts @@ -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; + abstract execute(interaction: ChatInputCommandInteraction): Promise; } diff --git a/tests/__functions__/discord.js/GenerateCommandInteractionMock.ts b/tests/__functions__/discord.js/GenerateCommandInteractionMock.ts index 128c25b..4159591 100644 --- a/tests/__functions__/discord.js/GenerateCommandInteractionMock.ts +++ b/tests/__functions__/discord.js/GenerateCommandInteractionMock.ts @@ -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(), diff --git a/tests/__types__/discord.js.ts b/tests/__types__/discord.js.ts index 3304af4..f27aab1 100644 --- a/tests/__types__/discord.js.ts +++ b/tests/__types__/discord.js.ts @@ -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, diff --git a/tests/commands/drop.test.ts b/tests/commands/drop.test.ts index 81b5f4a..22f831e 100644 --- a/tests/commands/drop.test.ts +++ b/tests/commands/drop.test.ts @@ -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", () => { diff --git a/tests/commands/effects.test.ts b/tests/commands/effects.test.ts index 33f612d..9ad5170 100644 --- a/tests/commands/effects.test.ts +++ b/tests/commands/effects.test.ts @@ -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); diff --git a/yarn.lock b/yarn.lock index 724412e..6c89543 100644 --- a/yarn.lock +++ b/yarn.lock @@ -456,10 +456,10 @@ dependencies: discord-api-types "^0.38.1" -"@discordjs/rest@^2.5.0": - version "2.5.0" - resolved "https://registry.yarnpkg.com/@discordjs/rest/-/rest-2.5.0.tgz#fc4c5e23bee31f4df98e6e148e9d22f8eb031924" - integrity sha512-PWhchxTzpn9EV3vvPRpwS0EE2rNYB9pvzDU/eLLW3mByJl0ZHZjHI2/wA8EbH2gRMQV7nu+0FoDF84oiPl8VAQ== +"@discordjs/rest@^2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@discordjs/rest/-/rest-2.5.1.tgz#a6bde4d08f0e23bd763506cc1fcc83564afee077" + integrity sha512-Tg9840IneBcbrAjcGaQzHUJWFNq1MMWZjTdjJ0WS/89IffaNKc++iOvffucPxQTF/gviO9+9r8kEPea1X5J2Dw== dependencies: "@discordjs/collection" "^2.1.1" "@discordjs/util" "^1.1.1" @@ -469,20 +469,20 @@ discord-api-types "^0.38.1" magic-bytes.js "^1.10.0" tslib "^2.6.3" - undici "6.21.1" + undici "6.21.3" "@discordjs/util@^1.1.0", "@discordjs/util@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@discordjs/util/-/util-1.1.1.tgz#bafcde0faa116c834da1258d78ec237080bbab29" integrity sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g== -"@discordjs/ws@^1.2.2": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@discordjs/ws/-/ws-1.2.2.tgz#bab8d16ea2fe9eb205351bd8896e03307bf42fdb" - integrity sha512-dyfq7yn0wO0IYeYOs3z79I6/HumhmKISzFL0Z+007zQJMtAFGtt3AEoq1nuLXtcunUE5YYYQqgKvybXukAK8/w== +"@discordjs/ws@^1.2.3": + version "1.2.3" + resolved "https://registry.yarnpkg.com/@discordjs/ws/-/ws-1.2.3.tgz#7cf80d8528366c6810c02b43ca49958ef154c3d4" + integrity sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw== dependencies: "@discordjs/collection" "^2.1.0" - "@discordjs/rest" "^2.5.0" + "@discordjs/rest" "^2.5.1" "@discordjs/util" "^1.1.0" "@sapphire/async-queue" "^1.5.2" "@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" integrity sha512-xuRXPD44FcbKHrQK15FS1HFlMRNJtsaZou/SVws18vQ7zHqmlxyDktMkZpyvD6gE2ctGOVYC/jUyoMMAyBWfcw== -discord.js@^14.19.3: - version "14.19.3" - resolved "https://registry.yarnpkg.com/discord.js/-/discord.js-14.19.3.tgz#ed08c61ad300efc3033ecf2b70f28a68d95b138a" - integrity sha512-lncTRk0k+8Q5D3nThnODBR8fR8x2fM798o8Vsr40Krx0DjPwpZCuxxTcFMrXMQVOqM1QB9wqWgaXPg3TbmlHqA== +discord.js@^14.20.0: + version "14.20.0" + resolved "https://registry.yarnpkg.com/discord.js/-/discord.js-14.20.0.tgz#eaac6485f756714d31c00b3dcb7ebfbc92beb5d3" + integrity sha512-5fRTptK2vpuz+bTuAEUQLSo/3AgCSLHl6Mm9+/ofb+8cbbnjWllhtaqRBq7XcpzlBnfNEugKv8HvCwcOtIHpCg== dependencies: "@discordjs/builders" "^1.11.2" "@discordjs/collection" "1.5.3" "@discordjs/formatters" "^0.6.1" - "@discordjs/rest" "^2.5.0" + "@discordjs/rest" "^2.5.1" "@discordjs/util" "^1.1.1" - "@discordjs/ws" "^1.2.2" + "@discordjs/ws" "^1.2.3" "@sapphire/snowflake" "3.5.3" discord-api-types "^0.38.1" fast-deep-equal "3.1.3" lodash.snakecase "4.1.1" magic-bytes.js "^1.10.0" tslib "^2.6.3" - undici "6.21.1" + undici "6.21.3" dot-prop@^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" integrity sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw== -undici@6.21.1: - version "6.21.1" - resolved "https://registry.yarnpkg.com/undici/-/undici-6.21.1.tgz#336025a14162e6837e44ad7b819b35b6c6af0e05" - integrity sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ== +undici@6.21.3: + version "6.21.3" + resolved "https://registry.yarnpkg.com/undici/-/undici-6.21.3.tgz#185752ad92c3d0efe7a7d1f6854a50f83b552d7a" + integrity sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw== unicorn-magic@^0.1.0: version "0.1.0"