diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..51c7163cd --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +CHANGELOG.md +.yarn diff --git a/package.json b/package.json index 50318cee6..6b050ac62 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,9 @@ "postpack": "pinst --enable" }, "dependencies": { - "@discordjs/builders": "^0.16.0", - "@sapphire/discord-utilities": "^2.12.0", - "@sapphire/discord.js-utilities": "^5.1.2", + "@discordjs/builders": "^1.4.0", + "@sapphire/discord-utilities": "^3.0.0", + "@sapphire/discord.js-utilities": "6.0.0", "@sapphire/lexure": "^1.1.2", "@sapphire/pieces": "^3.6.0", "@sapphire/ratelimits": "^2.4.5", @@ -41,7 +41,7 @@ "devDependencies": { "@commitlint/cli": "^17.4.0", "@commitlint/config-conventional": "^17.4.0", - "@favware/cliff-jumper": "^1.9.0", + "@favware/cliff-jumper": "^1.10.0", "@favware/npm-deprecate": "^1.0.7", "@favware/rollup-type-bundler": "^2.0.0", "@sapphire/eslint-config": "^4.3.8", @@ -53,7 +53,7 @@ "@typescript-eslint/parser": "^5.48.0", "@vitest/coverage-c8": "^0.26.3", "cz-conventional-changelog": "^3.3.0", - "discord.js": "^13.12.0", + "discord.js": "^14.7.1", "esbuild-plugin-file-path-extensions": "^1.0.0", "esbuild-plugin-version-injector": "^1.0.2", "eslint": "^8.31.0", diff --git a/src/lib/SapphireClient.ts b/src/lib/SapphireClient.ts index 7235298f7..67c8d7b09 100644 --- a/src/lib/SapphireClient.ts +++ b/src/lib/SapphireClient.ts @@ -40,14 +40,14 @@ export interface SapphireClientOptions { baseUserDirectory?: URL | string | null; /** - * Whether commands can be case insensitive + * Whether commands can be case-insensitive * @since 1.0.0 * @default false */ caseInsensitiveCommands?: boolean | null; /** - * Whether prefixes can be case insensitive + * Whether prefixes can be case-insensitive * @since 1.0.0 * @default false */ @@ -100,7 +100,7 @@ export interface SapphireClientOptions { logger?: ClientLoggerOptions; /** - * Whether or not trace logging should be enabled. + * Whether trace logging should be enabled. * @since 2.0.0 * @default container.logger.has(LogLevel.Trace) */ diff --git a/src/lib/errors/Identifiers.ts b/src/lib/errors/Identifiers.ts index 868828894..30fb37519 100644 --- a/src/lib/errors/Identifiers.ts +++ b/src/lib/errors/Identifiers.ts @@ -1,4 +1,4 @@ -export const enum Identifiers { +export enum Identifiers { ArgsMissing = 'argsMissing', ArgsUnavailable = 'argsUnavailable', diff --git a/src/lib/errors/UserError.ts b/src/lib/errors/UserError.ts index a178487ec..8e7ffd28e 100644 --- a/src/lib/errors/UserError.ts +++ b/src/lib/errors/UserError.ts @@ -15,8 +15,7 @@ export class UserError extends Error { /** * Constructs an UserError. - * @param type The identifier, useful to localize emitted errors. - * @param message The error message. + * @param options The UserError options */ public constructor(options: UserError.Options) { super(options.message); diff --git a/src/lib/parsers/Args.ts b/src/lib/parsers/Args.ts index cd52ac179..87584752c 100644 --- a/src/lib/parsers/Args.ts +++ b/src/lib/parsers/Args.ts @@ -73,14 +73,19 @@ export class Args { /** * Retrieves the next parameter and parses it. Advances index on success. * @param type The type of the argument. + * @param options The pickResult options. * @example * ```typescript * // !square 5 - * const resolver = Args.make((arg) => { - * const parsed = Number(arg); - * if (Number.isNaN(parsed)) return err(new UserError('ArgumentNumberNaN', 'You must write a valid number.')); - * return ok(parsed); + * const resolver = Args.make((parameter, { argument }) => { + * const parsed = Number(parameter); + * if (Number.isNaN(parsed)) { + * return Args.error({ argument, parameter, identifier: 'ArgumentNumberNaN', message: 'You must write a valid number.' }); + * } + * + * return Args.ok(parsed); * }); + * * const a = await args.pickResult(resolver); * if (!a.success) throw new UserError('ArgumentNumberNaN', 'You must write a valid number.'); * @@ -92,6 +97,7 @@ export class Args { /** * Retrieves the next parameter and parses it. Advances index on success. * @param type The type of the argument. + * @param options The pickResult options. * @example * ```typescript * // !add 1 2 @@ -130,14 +136,19 @@ export class Args { /** * Similar to {@link Args.pickResult} but returns the value on success, throwing otherwise. * @param type The type of the argument. + * @param options The pick options. * @example * ```typescript * // !square 5 - * const resolver = Args.make((arg) => { - * const parsed = Number(arg); - * if (Number.isNaN(parsed)) return err(new UserError('ArgumentNumberNaN', 'You must write a valid number.')); - * return ok(parsed); + * const resolver = Args.make((parameter, { argument }) => { + * const parsed = Number(parameter); + * if (Number.isNaN(parsed)) { + * return Args.error({ argument, parameter, identifier: 'ArgumentNumberNaN', message: 'You must write a valid number.' }); + * } + * + * return Args.ok(parsed); * }); + * * const a = await args.pick(resolver); * * await message.channel.send(`The result is: ${a ** 2}!`); @@ -148,6 +159,7 @@ export class Args { /** * Similar to {@link Args.pickResult} but returns the value on success, throwing otherwise. * @param type The type of the argument. + * @param options The pick options. * @example * ```typescript * // !add 1 2 @@ -166,10 +178,12 @@ export class Args { /** * Retrieves all the following arguments. * @param type The type of the argument. + * @param options The restResult options. * @example * ```typescript * // !reverse Hello world! - * const resolver = Args.make((arg) => ok(arg.split('').reverse())); + * const resolver = Args.make((parameter) => Args.ok(parameter.split('').reverse())); + * * const a = await args.restResult(resolver); * if (!a.success) throw new UserError('AddArgumentError', 'You must write some text.'); * @@ -181,6 +195,7 @@ export class Args { /** * Retrieves all the following arguments. * @param type The type of the argument. + * @param options The restResult options. * @example * ```typescript * // !add 2 Hello World! @@ -217,10 +232,11 @@ export class Args { /** * Similar to {@link Args.restResult} but returns the value on success, throwing otherwise. * @param type The type of the argument. + * @param options The rest options. * @example * ```typescript * // !reverse Hello world! - * const resolver = Args.make((arg) => ok(arg.split('').reverse())); + * const resolver = Args.make((arg) => Args.ok(arg.split('').reverse())); * const a = await args.rest(resolver); * await message.channel.send(`The reversed value is... ${a}`); * // Sends "The reversed value is... !dlrow olleH" @@ -230,6 +246,7 @@ export class Args { /** * Similar to {@link Args.restResult} but returns the value on success, throwing otherwise. * @param type The type of the argument. + * @param options The rest options. * @example * ```typescript * // !add 2 Hello World! @@ -248,10 +265,11 @@ export class Args { /** * Retrieves all the following arguments. * @param type The type of the argument. + * @param options The repeatResult options. * @example * ```typescript * // !add 2 Hello World! - * const resolver = Args.make((arg) => ok(arg.split('').reverse())); + * const resolver = Args.make((arg) => Args.ok(arg.split('').reverse())); * const result = await args.repeatResult(resolver, { times: 5 }); * if (!result.success) throw new UserError('CountArgumentError', 'You must write up to 5 words.'); * @@ -263,6 +281,7 @@ export class Args { /** * Retrieves all the following arguments. * @param type The type of the argument. + * @param options The repeatResult options. * @example * ```typescript * // !reverse-each 2 Hello World! @@ -311,10 +330,11 @@ export class Args { /** * Similar to {@link Args.repeatResult} but returns the value on success, throwing otherwise. * @param type The type of the argument. + * @param options The repeat options. * @example * ```typescript * // !reverse-each 2 Hello World! - * const resolver = Args.make((arg) => ok(arg.split('').reverse())); + * const resolver = Args.make((arg) => Args.ok(arg.split('').reverse())); * const result = await args.repeat(resolver, { times: 5 }); * await message.channel.send(`You have written ${result.length} word(s): ${result.join(' ')}`); * // Sends "You have written 2 word(s): Hello World!" @@ -324,6 +344,7 @@ export class Args { /** * Similar to {@link Args.repeatResult} but returns the value on success, throwing otherwise. * @param type The type of the argument. + * @param options The repeat options. * @example * ```typescript * // !add 2 Hello World! @@ -347,9 +368,9 @@ export class Args { * @example * ```typescript * // !reversedandscreamfirst hello world - * const resolver = Args.make((arg) => ok(arg.split('').reverse().join(''))); + * const resolver = Args.make((arg) => Args.ok(arg.split('').reverse().join(''))); * - * const result = await args.peekResult(() => args.repeatResult(resolver)); + * const result = await args.repeatResult(resolver); * await result.inspectAsync((value) => * message.channel.send(`Reversed ${value.length} word(s): ${value.join(' ')}`) * ); // Reversed 2 word(s): olleh dlrow @@ -367,13 +388,14 @@ export class Args { * or {@link Args.restResult}; otherwise, passing the custom argument or the argument type with options * will use {@link Args.pickResult} and only peek a single argument. * @param type The function, custom argument, or argument name. + * @param options The peekResult options. * @example * ```typescript * // !reverseandscreamfirst sapphire community - * const resolver = Args.make((arg) => ok(arg.split('').reverse().join(''))); + * const resolver = Args.make((arg) => Args.ok(arg.split('').reverse().join(''))); * * const peekedWord = await args.peekResult(resolver); - * await peekedWord.inspectAsync((value) => message.channel.send(peekedWord.value)); // erihppas + * await peekedWord.inspectAsync((value) => message.channel.send(value)); // erihppas * * const firstWord = await args.pickResult('string'); * await firstWord.inspectAsync((value) => message.channel.send(value.toUpperCase())); // SAPPHIRE @@ -386,17 +408,18 @@ export class Args { * or {@link Args.restResult}; otherwise, passing the custom argument or the argument type with options * will use {@link Args.pickResult} and only peek a single argument. * @param type The function, custom argument, or argument name. + * @param options The peekResult options. * @example * ```typescript * // !datethenaddtwo 1608867472611 * const date = await args.peekResult('date'); * await date.inspectAsync((value) => - * message.channel.send(`Your date (in UTC): ${date.value.toUTCString()}`) + * message.channel.send(`Your date (in UTC): ${value.toUTCString()}`) * ); // Your date (in UTC): Fri, 25 Dec 2020 03:37:52 GMT * * const result = await args.pickResult('number', { maximum: Number.MAX_SAFE_INTEGER - 2 }); * await result.inspectAsync((value) => - * message.channel.send(`Your number plus two: ${result.value + 2}`) + * message.channel.send(`Your number plus two: ${value + 2}`) * ); // Your number plus two: 1608867472613 * ``` */ @@ -421,16 +444,16 @@ export class Args { * @example * ```typescript * // !bigintsumthensquarefirst 25 50 75 - * const resolver = Args.make((arg) => { + * const resolver = Args.make((arg, { argument }) => { * try { - * return ok(BigInt(arg)); + * return Args.ok(BigInt(arg)); * } catch { - * return err(new UserError('InvalidBigInt', 'You must specify a valid number for a bigint.')); + * return Args.error({ parameter: arg, argument, identifier: 'InvalidBigInt', message: 'You must specify a valid number for a bigint.' }) * } * }); * - * const peeked = await args.peek(() => args.repeatResult(resolver)); - * await message.channel.send(`Sum: **${peeked.reduce((x, y) => x + y, 0)}**`); // Sum: 150 + * const peeked = await args.repeatResult(resolver); + * await peeked.inspectAsync((value) => message.channel.send(`Sum: **${value.reduce((x, y) => x + y, 0n)}**`)); // Sum: 150n * * const first = await args.pick(resolver); * await message.channel.send(`First bigint squared: ${first**2n}`); // First bigint squared: 625 @@ -440,15 +463,21 @@ export class Args { /** * Similar to {@link Args.peekResult} but returns the value on success, throwing otherwise. * @param type The function, custom argument, or argument name. + * @param options The peek options. * @example * ```typescript + * import { SnowflakeRegex } from '@sapphire/discord.js-utilities'; + * import { DiscordSnowflake } from '@sapphire/snowflake'; + * * // !createdat 730159185517477900 - * const snowflakeResolver = Args.make((arg) => - * SnowflakeRegex.test(arg) ? ok(BigInt(arg)) : err(new UserError('InvalidSnowflake', 'You must specify a valid snowflake.')); - * ); + * const snowflakeResolver = Args.make((arg, { argument }) => { + * return SnowflakeRegex.test(arg) + * ? Args.ok(BigInt(arg)) + * : Args.error({ parameter: arg, argument, identifier: 'InvalidSnowflake', message: 'You must specify a valid snowflake.' }); + * }); * * const snowflake = await args.peek(snowflakeResolver); - * const timestamp = Number((snowflake >> 22n) + DiscordSnowflake.Epoch); + * const timestamp = Number((snowflake >> 22n) + DiscordSnowflake.epoch); * const createdAt = new Date(timestamp); * * await message.channel.send( @@ -463,6 +492,7 @@ export class Args { /** * Similar to {@link Args.peekResult} but returns the value on success, throwing otherwise. * @param type The function, custom argument, or argument name. + * @param options The peek options. * @example * ```typescript * // !messagelink https://discord.com/channels/737141877803057244/737142209639350343/791843123898089483 @@ -494,7 +524,7 @@ export class Args { public nextMaybe(): Option; /** * Retrieves the value of the next unused ordered token, but only if it could be transformed. - * That token will now be consider used if the transformation succeeds. + * That token will now be used if the transformation succeeds. * @typeparam T Output type of the {@link ArgsNextCallback callback}. * @param cb Gives an option of either the resulting value, or nothing if failed. * @example @@ -709,8 +739,9 @@ export class Args { } /** - * Converts a callback into an usable argument. + * Converts a callback into a usable argument. * @param cb The callback to convert into an {@link IArgument}. + * @param name The name of the argument. */ public static make(cb: IArgument['run'], name = ''): IArgument { return { run: cb, name }; diff --git a/src/lib/resolvers/channel.ts b/src/lib/resolvers/channel.ts index 0599e4b61..c2ded6023 100644 --- a/src/lib/resolvers/channel.ts +++ b/src/lib/resolvers/channel.ts @@ -1,12 +1,12 @@ import { ChannelMentionRegex, type ChannelTypes } from '@sapphire/discord.js-utilities'; import { container } from '@sapphire/pieces'; import { Result } from '@sapphire/result'; -import type { BaseCommandInteraction, Message, Snowflake } from 'discord.js'; +import type { CommandInteraction, Message, Snowflake } from 'discord.js'; import { Identifiers } from '../errors/Identifiers'; export function resolveChannel( parameter: string, - messageOrInteraction: Message | BaseCommandInteraction + messageOrInteraction: Message | CommandInteraction ): Result { const channelId = (ChannelMentionRegex.exec(parameter)?.[1] ?? parameter) as Snowflake; const channel = (messageOrInteraction.guild ? messageOrInteraction.guild.channels : container.client.channels).cache.get(channelId); diff --git a/src/lib/resolvers/dmChannel.ts b/src/lib/resolvers/dmChannel.ts index 96bc8922d..0a372bd36 100644 --- a/src/lib/resolvers/dmChannel.ts +++ b/src/lib/resolvers/dmChannel.ts @@ -1,12 +1,12 @@ import { isDMChannel } from '@sapphire/discord.js-utilities'; import { Result } from '@sapphire/result'; -import type { BaseCommandInteraction, DMChannel, Message } from 'discord.js'; +import type { CommandInteraction, DMChannel, Message } from 'discord.js'; import { Identifiers } from '../errors/Identifiers'; import { resolveChannel } from './channel'; export function resolveDMChannel( parameter: string, - messageOrInteraction: Message | BaseCommandInteraction + messageOrInteraction: Message | CommandInteraction ): Result { const result = resolveChannel(parameter, messageOrInteraction); return result.mapInto((value) => { diff --git a/src/lib/resolvers/emoji.ts b/src/lib/resolvers/emoji.ts index 63c828294..78ee229c6 100644 --- a/src/lib/resolvers/emoji.ts +++ b/src/lib/resolvers/emoji.ts @@ -1,6 +1,6 @@ import { EmojiRegex, TwemojiRegex } from '@sapphire/discord-utilities'; import { Result } from '@sapphire/result'; -import { Util } from 'discord.js'; +import { parseEmoji } from 'discord.js'; import { Identifiers } from '../errors/Identifiers'; export function resolveEmoji(parameter: string): Result { @@ -16,7 +16,7 @@ export function resolveEmoji(parameter: string): Result { * super(context, { name: 'hyperlink', aliases: ['url'] }); * } * - * public run(argument: string): Argument.Result { + * public run(argument: string, context: Argument.Context): Argument.Result { * try { * return this.ok(new URL(argument)); * } catch { - * return this.error(argument, 'ArgumentHyperlinkInvalidURL', 'The argument did not resolve to a valid URL.'); + * return this.error({ + * parameter: argument, + * context, + * identifier: 'ArgumentHyperlinkInvalidURL', + * message: 'The argument did not resolve to a valid URL.' + * }); * } * } * } @@ -81,11 +86,16 @@ export interface IArgument { * super(context, { name: 'hyperlink', aliases: ['url'] }); * } * - * run(argument) { + * run(argument, context) { * try { * return this.ok(new URL(argument)); * } catch { - * return this.error(argument, 'ArgumentHyperlinkInvalidURL', 'The argument did not resolve to a valid URL.'); + * return this.error({ + * parameter: argument, + * context, + * identifier: 'ArgumentHyperlinkInvalidURL', + * message: 'The argument did not resolve to a valid URL.' + * }); * } * } * } diff --git a/src/lib/structures/Command.ts b/src/lib/structures/Command.ts index e1c5e1e5f..f20a34daa 100644 --- a/src/lib/structures/Command.ts +++ b/src/lib/structures/Command.ts @@ -3,10 +3,10 @@ import { AliasPiece, type AliasPieceJSON, type AliasStore } from '@sapphire/piec import { isNullish, type Awaitable, type NonNullObject } from '@sapphire/utilities'; import type { LocalizationMap } from 'discord-api-types/v10'; import { - Permissions, + ChatInputCommandInteraction, + ContextMenuCommandInteraction, + PermissionsBitField, type AutocompleteInteraction, - type CommandInteraction, - type ContextMenuInteraction, type Message, type PermissionResolvable, type Snowflake @@ -43,7 +43,7 @@ export class Command; + public chatInputRun?(interaction: ChatInputCommandInteraction, context: ChatInputCommand.RunContext): Awaitable; /** * Executes the context menu's logic. * @param interaction The interaction that triggered the command. + * @param context The context menu command run context. */ - public contextMenuRun?(interaction: ContextMenuInteraction, context: ContextMenuCommand.RunContext): Awaitable; + public contextMenuRun?(interaction: ContextMenuCommandInteraction, context: ContextMenuCommand.RunContext): Awaitable; /** * Executes the autocomplete logic. @@ -350,7 +352,7 @@ export class Command = CommandInteraction; + export type Interaction = ChatInputCommandInteraction; export type Registry = ApplicationCommandRegistry; } @@ -507,7 +509,7 @@ export namespace ContextMenuCommand { export type Context = AliasPiece.Context; export type RunInTypes = CommandOptionsRunType; export type RunContext = ContextMenuCommandContext; - export type Interaction = ContextMenuInteraction; + export type Interaction = ContextMenuCommandInteraction; export type Registry = ApplicationCommandRegistry; } @@ -525,7 +527,7 @@ export namespace AutocompleteCommand { /** * The allowed values for {@link Command.Options.runIn}. - * @remark It is discouraged to use this type, we recommend using {@link Command.OptionsRunTypeEnum} instead. + * @remark It is discouraged to use this type, we recommend using {@link CommandOptionsRunTypeEnum} instead. * @since 2.0.0 */ export type CommandOptionsRunType = @@ -542,7 +544,7 @@ export type CommandOptionsRunType = * The allowed values for {@link Command.Options.runIn} as an enum. * @since 2.0.0 */ -export const enum CommandOptionsRunTypeEnum { +export enum CommandOptionsRunTypeEnum { Dm = 'DM', GuildText = 'GUILD_TEXT', GuildVoice = 'GUILD_VOICE', @@ -557,7 +559,7 @@ export const enum CommandOptionsRunTypeEnum { * The available command pre-conditions. * @since 2.0.0 */ -export const enum CommandPreConditions { +export enum CommandPreConditions { Cooldown = 'Cooldown', DirectMessageOnly = 'DMOnly', GuildNewsOnly = 'GuildNewsOnly', @@ -643,7 +645,7 @@ export interface CommandOptions extends AliasPiece.Options, FlagStrategyOptions quotes?: [string, string][]; /** - * Sets whether or not the command should be treated as NSFW. If set to true, the `NSFW` precondition will be added to the list. + * Sets whether the command should be treated as NSFW. If set to true, the `NSFW` precondition will be added to the list. * @since 2.0.0 * @default false */ @@ -817,10 +819,10 @@ export namespace Command { export type JSON = CommandJSON; export type Context = AliasPiece.Context; export type RunInTypes = CommandOptionsRunType; - export type ChatInputInteraction = - import('discord.js').CommandInteraction; - export type ContextMenuInteraction = - import('discord.js').ContextMenuInteraction; + export type ChatInputCommandInteraction = + import('discord.js').ChatInputCommandInteraction; + export type ContextMenuCommandInteraction = + import('discord.js').ContextMenuCommandInteraction; export type AutocompleteInteraction = import('discord.js').AutocompleteInteraction; export type Registry = ApplicationCommandRegistry; diff --git a/src/lib/structures/InteractionHandler.ts b/src/lib/structures/InteractionHandler.ts index 6d5c5c977..4f5125ee7 100644 --- a/src/lib/structures/InteractionHandler.ts +++ b/src/lib/structures/InteractionHandler.ts @@ -103,14 +103,14 @@ export namespace InteractionHandler { export type ParseResult = InteractionHandlerParseResult; } -export const enum InteractionHandlerTypes { +export enum InteractionHandlerTypes { // Specifically focused types - Button = 'BUTTON', - SelectMenu = 'SELECT_MENU', - ModalSubmit = 'MODAL_SUBMIT', + Button, + SelectMenu, + ModalSubmit, // More free-falling handlers, for 1 shared handler between buttons and select menus (someone will have a use for this >,>) - MessageComponent = 'MESSAGE_COMPONENT', + MessageComponent, // Optional autocompletes, you can use this or in-command - Autocomplete = 'AUTOCOMPLETE' + Autocomplete } diff --git a/src/lib/structures/Listener.ts b/src/lib/structures/Listener.ts index 0df701b85..0dbe0c4e3 100644 --- a/src/lib/structures/Listener.ts +++ b/src/lib/structures/Listener.ts @@ -57,7 +57,7 @@ export abstract class Listener public messageRun?(message: Message, command: MessageCommand, context: Precondition.Context): Precondition.Result; - public chatInputRun?(interaction: CommandInteraction, command: ChatInputCommand, context: Precondition.Context): Precondition.Result; + public chatInputRun?(interaction: ChatInputCommandInteraction, command: ChatInputCommand, context: Precondition.Context): Precondition.Result; - public contextMenuRun?(interaction: ContextMenuInteraction, command: ContextMenuCommand, context: Precondition.Context): Precondition.Result; + public contextMenuRun?( + interaction: ContextMenuCommandInteraction, + command: ContextMenuCommand, + context: Precondition.Context + ): Precondition.Result; public ok(): Precondition.Result { return Result.ok(); @@ -36,7 +47,7 @@ export class Precondition return Result.err(new PreconditionError({ precondition: this, ...options })); } - protected async fetchChannelFromInteraction(interaction: BaseCommandInteraction) { + protected async fetchChannelFromInteraction(interaction: CommandInteraction): Promise { const channel = (await interaction.client.channels.fetch(interaction.channelId, { cache: false, allowUnknownGuild: true @@ -50,13 +61,13 @@ export abstract class AllFlowsPrecondition extends Precondition { public abstract override messageRun(message: Message, command: MessageCommand, context: Precondition.Context): Precondition.Result; public abstract override chatInputRun( - interaction: CommandInteraction, + interaction: ChatInputCommandInteraction, command: ChatInputCommand, context: Precondition.Context ): Precondition.Result; public abstract override contextMenuRun( - interaction: ContextMenuInteraction, + interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, context: Precondition.Context ): Precondition.Result; @@ -123,10 +134,10 @@ export interface Preconditions { GuildThreadOnly: never; NSFW: never; ClientPermissions: { - permissions: Permissions; + permissions: PermissionsBitField; }; UserPermissions: { - permissions: Permissions; + permissions: PermissionsBitField; }; } diff --git a/src/lib/structures/PreconditionStore.ts b/src/lib/structures/PreconditionStore.ts index 6a060a5ed..e3e2d59b3 100644 --- a/src/lib/structures/PreconditionStore.ts +++ b/src/lib/structures/PreconditionStore.ts @@ -1,6 +1,6 @@ import { Store } from '@sapphire/pieces'; import { Result } from '@sapphire/result'; -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../errors/Identifiers'; import type { ChatInputCommand, ContextMenuCommand, MessageCommand } from './Command'; import { Precondition, type AsyncPreconditionResult } from './Precondition'; @@ -30,7 +30,7 @@ export class PreconditionStore extends Store { } public async chatInputRun( - interaction: CommandInteraction, + interaction: ChatInputCommandInteraction, command: ChatInputCommand, context: Precondition.Context = {} ): AsyncPreconditionResult { @@ -51,7 +51,7 @@ export class PreconditionStore extends Store { } public async contextMenuRun( - interaction: ContextMenuInteraction, + interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, context: Precondition.Context = {} ): AsyncPreconditionResult { diff --git a/src/lib/types/Enums.ts b/src/lib/types/Enums.ts index 9335dd140..dc12f50ee 100644 --- a/src/lib/types/Enums.ts +++ b/src/lib/types/Enums.ts @@ -58,7 +58,7 @@ export enum RegisterBehavior { BulkOverwrite = 'BULK_OVERWRITE' } -export const enum InternalRegistryAPIType { +export enum InternalRegistryAPIType { ChatInput, ContextMenu } diff --git a/src/lib/types/Events.ts b/src/lib/types/Events.ts index 22966e28e..6916b21ba 100644 --- a/src/lib/types/Events.ts +++ b/src/lib/types/Events.ts @@ -1,9 +1,9 @@ import type { Piece, Store } from '@sapphire/pieces'; import { - Constants, + Events as DJSEvents, type AutocompleteInteraction, - type CommandInteraction, - type ContextMenuInteraction, + type ChatInputCommandInteraction, + type ContextMenuCommandInteraction, type Interaction, type Message } from 'discord.js'; @@ -25,70 +25,68 @@ import type { PluginHook } from './Enums'; export const Events = { // #region Discord.js base events - ChannelCreate: Constants.Events.CHANNEL_CREATE, - ChannelDelete: Constants.Events.CHANNEL_DELETE, - ChannelPinsUpdate: Constants.Events.CHANNEL_PINS_UPDATE, - ChannelUpdate: Constants.Events.CHANNEL_UPDATE, - ClientReady: Constants.Events.CLIENT_READY, - Debug: Constants.Events.DEBUG, - Error: Constants.Events.ERROR, - GuildBanAdd: Constants.Events.GUILD_BAN_ADD, - GuildBanRemove: Constants.Events.GUILD_BAN_REMOVE, - GuildCreate: Constants.Events.GUILD_CREATE, - GuildDelete: Constants.Events.GUILD_DELETE, - GuildEmojiCreate: Constants.Events.GUILD_EMOJI_CREATE, - GuildEmojiDelete: Constants.Events.GUILD_EMOJI_DELETE, - GuildEmojiUpdate: Constants.Events.GUILD_EMOJI_UPDATE, - GuildIntegrationsUpdate: Constants.Events.GUILD_INTEGRATIONS_UPDATE, - GuildMemberAdd: Constants.Events.GUILD_MEMBER_ADD, - GuildMemberAvailable: Constants.Events.GUILD_MEMBER_AVAILABLE, - GuildMemberRemove: Constants.Events.GUILD_MEMBER_REMOVE, - GuildMembersChunk: Constants.Events.GUILD_MEMBERS_CHUNK, - GuildMemberUpdate: Constants.Events.GUILD_MEMBER_UPDATE, - GuildRoleCreate: Constants.Events.GUILD_ROLE_CREATE, - GuildRoleDelete: Constants.Events.GUILD_ROLE_DELETE, - GuildRoleUpdate: Constants.Events.GUILD_ROLE_UPDATE, - GuildStickerCreate: Constants.Events.GUILD_STICKER_CREATE, - GuildStickerDelete: Constants.Events.GUILD_STICKER_DELETE, - GuildStickerUpdate: Constants.Events.GUILD_STICKER_UPDATE, - GuildUnavailable: Constants.Events.GUILD_UNAVAILABLE, - GuildUpdate: Constants.Events.GUILD_UPDATE, - InteractionCreate: Constants.Events.INTERACTION_CREATE, - Invalidated: Constants.Events.INVALIDATED, - InvalidRequestWarning: Constants.Events.INVALID_REQUEST_WARNING, - InviteCreate: Constants.Events.INVITE_CREATE, - InviteDelete: Constants.Events.INVITE_DELETE, - MessageBulkDelete: Constants.Events.MESSAGE_BULK_DELETE, - MessageCreate: Constants.Events.MESSAGE_CREATE, - MessageDelete: Constants.Events.MESSAGE_DELETE, - MessageReactionAdd: Constants.Events.MESSAGE_REACTION_ADD, - MessageReactionRemove: Constants.Events.MESSAGE_REACTION_REMOVE, - MessageReactionRemoveAll: Constants.Events.MESSAGE_REACTION_REMOVE_ALL, - MessageReactionRemoveEmoji: Constants.Events.MESSAGE_REACTION_REMOVE_EMOJI, - MessageUpdate: Constants.Events.MESSAGE_UPDATE, - PresenceUpdate: Constants.Events.PRESENCE_UPDATE, - RateLimit: Constants.Events.RATE_LIMIT, - Raw: Constants.Events.RAW, - ShardDisconnect: Constants.Events.SHARD_DISCONNECT, - ShardError: Constants.Events.SHARD_ERROR, - ShardReady: Constants.Events.SHARD_READY, - ShardReconnecting: Constants.Events.SHARD_RECONNECTING, - ShardResume: Constants.Events.SHARD_RESUME, - StageInstanceCreate: Constants.Events.STAGE_INSTANCE_CREATE, - StageInstanceDelete: Constants.Events.STAGE_INSTANCE_DELETE, - StageInstanceUpdate: Constants.Events.STAGE_INSTANCE_UPDATE, - ThreadCreate: Constants.Events.THREAD_CREATE, - ThreadDelete: Constants.Events.THREAD_DELETE, - ThreadListSync: Constants.Events.THREAD_LIST_SYNC, - ThreadMembersUpdate: Constants.Events.THREAD_MEMBERS_UPDATE, - ThreadMemberUpdate: Constants.Events.THREAD_MEMBER_UPDATE, - ThreadUpdate: Constants.Events.THREAD_UPDATE, - TypingStart: Constants.Events.TYPING_START, - UserUpdate: Constants.Events.USER_UPDATE, - VoiceServerUpdate: Constants.Events.VOICE_SERVER_UPDATE, - VoiceStateUpdate: Constants.Events.VOICE_STATE_UPDATE, - Warn: Constants.Events.WARN, - WebhooksUpdate: Constants.Events.WEBHOOKS_UPDATE, + ChannelCreate: DJSEvents.ChannelCreate as const, + ChannelDelete: DJSEvents.ChannelDelete as const, + ChannelPinsUpdate: DJSEvents.ChannelPinsUpdate as const, + ChannelUpdate: DJSEvents.ChannelUpdate as const, + ClientReady: DJSEvents.ClientReady as const, + Debug: DJSEvents.Debug as const, + Error: DJSEvents.Error as const, + GuildBanAdd: DJSEvents.GuildBanAdd as const, + GuildBanRemove: DJSEvents.GuildBanRemove as const, + GuildCreate: DJSEvents.GuildCreate as const, + GuildDelete: DJSEvents.GuildDelete as const, + GuildEmojiCreate: DJSEvents.GuildEmojiCreate as const, + GuildEmojiDelete: DJSEvents.GuildEmojiDelete as const, + GuildEmojiUpdate: DJSEvents.GuildEmojiUpdate as const, + GuildIntegrationsUpdate: DJSEvents.GuildIntegrationsUpdate as const, + GuildMemberAdd: DJSEvents.GuildMemberAdd as const, + GuildMemberAvailable: DJSEvents.GuildMemberAdd as const, + GuildMemberRemove: DJSEvents.GuildMemberRemove as const, + GuildMembersChunk: DJSEvents.GuildMembersChunk as const, + GuildMemberUpdate: DJSEvents.GuildMemberUpdate as const, + GuildRoleCreate: DJSEvents.GuildRoleCreate as const, + GuildRoleDelete: DJSEvents.GuildRoleDelete as const, + GuildRoleUpdate: DJSEvents.GuildRoleUpdate as const, + GuildStickerCreate: DJSEvents.GuildStickerCreate as const, + GuildStickerDelete: DJSEvents.GuildStickerDelete as const, + GuildStickerUpdate: DJSEvents.GuildStickerUpdate as const, + GuildUnavailable: DJSEvents.GuildUnavailable as const, + GuildUpdate: DJSEvents.GuildUpdate as const, + InteractionCreate: DJSEvents.InteractionCreate as const, + Invalidated: DJSEvents.Invalidated as const, + InviteCreate: DJSEvents.InviteCreate as const, + InviteDelete: DJSEvents.InviteDelete as const, + MessageBulkDelete: DJSEvents.MessageBulkDelete as const, + MessageCreate: DJSEvents.MessageCreate as const, + MessageDelete: DJSEvents.MessageDelete as const, + MessageReactionAdd: DJSEvents.MessageReactionAdd as const, + MessageReactionRemove: DJSEvents.MessageReactionRemove as const, + MessageReactionRemoveAll: DJSEvents.MessageReactionRemoveAll as const, + MessageReactionRemoveEmoji: DJSEvents.MessageReactionRemoveEmoji as const, + MessageUpdate: DJSEvents.MessageUpdate as const, + PresenceUpdate: DJSEvents.PresenceUpdate as const, + Raw: DJSEvents.Raw as const, + ShardDisconnect: DJSEvents.ShardDisconnect as const, + ShardError: DJSEvents.ShardError as const, + ShardReady: DJSEvents.ShardReady as const, + ShardReconnecting: DJSEvents.ShardReconnecting as const, + ShardResume: DJSEvents.ShardResume as const, + StageInstanceCreate: DJSEvents.StageInstanceCreate as const, + StageInstanceDelete: DJSEvents.StageInstanceDelete as const, + StageInstanceUpdate: DJSEvents.StageInstanceUpdate as const, + ThreadCreate: DJSEvents.ThreadCreate as const, + ThreadDelete: DJSEvents.ThreadDelete as const, + ThreadListSync: DJSEvents.ThreadListSync as const, + ThreadMembersUpdate: DJSEvents.ThreadMembersUpdate as const, + ThreadMemberUpdate: DJSEvents.ThreadMemberUpdate as const, + ThreadUpdate: DJSEvents.ThreadUpdate as const, + TypingStart: DJSEvents.TypingStart as const, + UserUpdate: DJSEvents.UserUpdate as const, + VoiceServerUpdate: DJSEvents.VoiceServerUpdate as const, + VoiceStateUpdate: DJSEvents.VoiceStateUpdate as const, + Warn: DJSEvents.Warn as const, + WebhooksUpdate: DJSEvents.WebhooksUpdate as const, // #endregion Discord.js base events // #region Sapphire events @@ -192,7 +190,7 @@ export const Events = { /** * Emitted when an error is encountered when handling the command application command registry. * @param {*} error The error that was thrown - * @param {Command} command The command who's registry caused the error + * @param {Command} command The command whose registry caused the error */ CommandApplicationCommandRegistryError: 'commandApplicationCommandRegistryError' as const, @@ -259,7 +257,7 @@ export const Events = { // Chat input command chain /** * Emitted when a chat input command interaction is recieved. - * @param {CommandInteraction} interaction The interaction that was recieved. + * @param {ChatInputCommandInteraction} interaction The interaction that was recieved. */ PossibleChatInputCommand: 'possibleChatInputCommand' as const, /** @@ -292,7 +290,7 @@ export const Events = { /** * Emitted directly before a chat input command is run. - * @param {CommandInteraction} interaction The interaction that executed the command + * @param {ChatInputCommandInteraction} interaction The interaction that executed the command * @param {ChatInputCommand} command The command that is being run * @param {ChatInputCommandRunPayload} payload The contextual payload */ @@ -319,7 +317,7 @@ export const Events = { // Context menu chain /** * Emitted when a context menu interaction is recieved. - * @param {ContextMenuInteraction} interaction The interaction that was recieved. + * @param {ContextMenuCommandInteraction} interaction The interaction that was recieved. */ PossibleContextMenuCommand: 'possibleContextMenuCommand' as const, /** @@ -352,7 +350,7 @@ export const Events = { /** * Emitted directly before a context menu command is run. - * @param {ContextMenuInteraction} interaction The interaction that executed the command + * @param {ContextMenuCommandInteraction} interaction The interaction that executed the command * @param {ContextMenuCommand} command The command that is being run * @param {ContextMenuCommandRunPayload} payload The contextual payload */ @@ -377,7 +375,7 @@ export const Events = { ContextMenuCommandFinish: 'contextMenuCommandFinish' as const // #endregion Sapphire events -}; +} as const; export interface IPieceError { piece: Piece; @@ -442,18 +440,18 @@ export interface MessageCommandSuccessPayload extends MessageCommandRunPayload { export interface MessageCommandTypingErrorPayload extends MessageCommandRunPayload {} export interface UnknownChatInputCommandPayload { - interaction: CommandInteraction; + interaction: ChatInputCommandInteraction; context: ChatInputCommandContext; } export interface CommandDoesNotHaveChatInputCommandHandlerPayload { - interaction: CommandInteraction; + interaction: ChatInputCommandInteraction; command: Command; context: ChatInputCommandContext; } export interface IChatInputCommandPayload { - interaction: CommandInteraction; + interaction: ChatInputCommandInteraction; command: ChatInputCommand; } @@ -484,18 +482,18 @@ export interface ChatInputCommandErrorPayload extends IChatInputCommandPayload { } export interface UnknownContextMenuCommandPayload { - interaction: ContextMenuInteraction; + interaction: ContextMenuCommandInteraction; context: ContextMenuCommandContext; } export interface CommandDoesNotHaveContextMenuCommandHandlerPayload { - interaction: ContextMenuInteraction; + interaction: ContextMenuCommandInteraction; context: ContextMenuCommandContext; command: Command; } export interface IContextMenuCommandPayload { - interaction: ContextMenuInteraction; + interaction: ContextMenuCommandInteraction; command: ContextMenuCommand; } @@ -540,73 +538,87 @@ export interface AutocompleteInteractionPayload { context: AutocompleteCommandContext; } +declare const SapphireEvents: typeof Events; + declare module 'discord.js' { interface ClientEvents { // #region Sapphire load cycle events - [Events.PieceUnload]: [store: Store, piece: Piece]; - [Events.PiecePostLoad]: [store: Store, piece: Piece]; + [SapphireEvents.PieceUnload]: [store: Store, piece: Piece]; + [SapphireEvents.PiecePostLoad]: [store: Store, piece: Piece]; - [Events.ListenerError]: [error: unknown, payload: ListenerErrorPayload]; - [Events.CommandApplicationCommandRegistryError]: [error: unknown, command: Command]; - [Events.ApplicationCommandRegistriesRegistered]: [registries: Map]; + [SapphireEvents.ListenerError]: [error: unknown, payload: ListenerErrorPayload]; + [SapphireEvents.CommandApplicationCommandRegistryError]: [error: unknown, command: Command]; + [SapphireEvents.ApplicationCommandRegistriesRegistered]: [registries: Map]; - [Events.PreMessageParsed]: [message: Message]; - [Events.MentionPrefixOnly]: [message: Message]; - [Events.NonPrefixedMessage]: [message: Message]; - [Events.PrefixedMessage]: [message: Message, prefix: string | RegExp]; + [SapphireEvents.PreMessageParsed]: [message: Message]; + [SapphireEvents.MentionPrefixOnly]: [message: Message]; + [SapphireEvents.NonPrefixedMessage]: [message: Message]; + [SapphireEvents.PrefixedMessage]: [message: Message, prefix: string | RegExp]; - [Events.UnknownMessageCommandName]: [payload: UnknownMessageCommandNamePayload]; - [Events.UnknownMessageCommand]: [payload: UnknownMessageCommandPayload]; - [Events.CommandDoesNotHaveMessageCommandHandler]: [payload: CommandDoesNotHaveMessageCommandHandler]; - [Events.PreMessageCommandRun]: [payload: PreMessageCommandRunPayload]; + [SapphireEvents.UnknownMessageCommandName]: [payload: UnknownMessageCommandNamePayload]; + [SapphireEvents.UnknownMessageCommand]: [payload: UnknownMessageCommandPayload]; + [SapphireEvents.CommandDoesNotHaveMessageCommandHandler]: [payload: CommandDoesNotHaveMessageCommandHandler]; + [SapphireEvents.PreMessageCommandRun]: [payload: PreMessageCommandRunPayload]; - [Events.MessageCommandDenied]: [error: UserError, payload: MessageCommandDeniedPayload]; - [Events.MessageCommandAccepted]: [payload: MessageCommandAcceptedPayload]; + [SapphireEvents.MessageCommandDenied]: [error: UserError, payload: MessageCommandDeniedPayload]; + [SapphireEvents.MessageCommandAccepted]: [payload: MessageCommandAcceptedPayload]; - [Events.MessageCommandRun]: [message: Message, command: Command, payload: MessageCommandRunPayload]; - [Events.MessageCommandSuccess]: [payload: MessageCommandSuccessPayload]; - [Events.MessageCommandError]: [error: unknown, payload: MessageCommandErrorPayload]; - [Events.MessageCommandFinish]: [message: Message, command: Command, payload: MessageCommandFinishPayload]; + [SapphireEvents.MessageCommandRun]: [message: Message, command: Command, payload: MessageCommandRunPayload]; + [SapphireEvents.MessageCommandSuccess]: [payload: MessageCommandSuccessPayload]; + [SapphireEvents.MessageCommandError]: [error: unknown, payload: MessageCommandErrorPayload]; + [SapphireEvents.MessageCommandFinish]: [message: Message, command: Command, payload: MessageCommandFinishPayload]; - [Events.MessageCommandTypingError]: [error: Error, payload: MessageCommandTypingErrorPayload]; + [SapphireEvents.MessageCommandTypingError]: [error: Error, payload: MessageCommandTypingErrorPayload]; - [Events.PluginLoaded]: [hook: PluginHook, name: string | undefined]; + [SapphireEvents.PluginLoaded]: [hook: PluginHook, name: string | undefined]; - [Events.InteractionHandlerParseError]: [error: unknown, payload: InteractionHandlerParseError]; - [Events.InteractionHandlerError]: [error: unknown, payload: InteractionHandlerError]; + [SapphireEvents.InteractionHandlerParseError]: [error: unknown, payload: InteractionHandlerParseError]; + [SapphireEvents.InteractionHandlerError]: [error: unknown, payload: InteractionHandlerError]; - [Events.PossibleAutocompleteInteraction]: [interaction: AutocompleteInteraction]; - [Events.CommandAutocompleteInteractionError]: [error: unknown, payload: AutocompleteInteractionPayload]; - [Events.CommandAutocompleteInteractionSuccess]: [payload: AutocompleteInteractionPayload]; + [SapphireEvents.PossibleAutocompleteInteraction]: [interaction: AutocompleteInteraction]; + [SapphireEvents.CommandAutocompleteInteractionError]: [error: unknown, payload: AutocompleteInteractionPayload]; + [SapphireEvents.CommandAutocompleteInteractionSuccess]: [payload: AutocompleteInteractionPayload]; // Chat input command chain - [Events.PossibleChatInputCommand]: [interaction: CommandInteraction]; - [Events.UnknownChatInputCommand]: [payload: UnknownChatInputCommandPayload]; - [Events.CommandDoesNotHaveChatInputCommandHandler]: [payload: CommandDoesNotHaveChatInputCommandHandlerPayload]; - [Events.PreChatInputCommandRun]: [payload: PreChatInputCommandRunPayload]; + [SapphireEvents.PossibleChatInputCommand]: [interaction: ChatInputCommandInteraction]; + [SapphireEvents.UnknownChatInputCommand]: [payload: UnknownChatInputCommandPayload]; + [SapphireEvents.CommandDoesNotHaveChatInputCommandHandler]: [payload: CommandDoesNotHaveChatInputCommandHandlerPayload]; + [SapphireEvents.PreChatInputCommandRun]: [payload: PreChatInputCommandRunPayload]; + + [SapphireEvents.ChatInputCommandDenied]: [error: UserError, payload: ChatInputCommandDeniedPayload]; + [SapphireEvents.ChatInputCommandAccepted]: [payload: ChatInputCommandAcceptedPayload]; + + [SapphireEvents.ChatInputCommandRun]: [ + interaction: ChatInputCommandInteraction, + command: ChatInputCommand, + payload: ChatInputCommandRunPayload + ]; + [SapphireEvents.ChatInputCommandSuccess]: [payload: ChatInputCommandSuccessPayload]; + [SapphireEvents.ChatInputCommandError]: [error: unknown, payload: ChatInputCommandErrorPayload]; + [SapphireEvents.ChatInputCommandFinish]: [ + interaction: ChatInputCommandInteraction, + command: ChatInputCommand, + payload: ChatInputCommandFinishPayload + ]; - [Events.ChatInputCommandDenied]: [error: UserError, payload: ChatInputCommandDeniedPayload]; - [Events.ChatInputCommandAccepted]: [payload: ChatInputCommandAcceptedPayload]; + // Context menu command chain + [SapphireEvents.PossibleContextMenuCommand]: [interaction: ContextMenuCommandInteraction]; + [SapphireEvents.UnknownContextMenuCommand]: [payload: UnknownContextMenuCommandPayload]; + [SapphireEvents.CommandDoesNotHaveContextMenuCommandHandler]: [payload: CommandDoesNotHaveContextMenuCommandHandlerPayload]; + [SapphireEvents.PreContextMenuCommandRun]: [payload: PreContextMenuCommandRunPayload]; - [Events.ChatInputCommandRun]: [interaction: CommandInteraction, command: ChatInputCommand, payload: ChatInputCommandRunPayload]; - [Events.ChatInputCommandSuccess]: [payload: ChatInputCommandSuccessPayload]; - [Events.ChatInputCommandError]: [error: unknown, payload: ChatInputCommandErrorPayload]; - [Events.ChatInputCommandFinish]: [interaction: CommandInteraction, command: ChatInputCommand, payload: ChatInputCommandFinishPayload]; + [SapphireEvents.ContextMenuCommandDenied]: [error: UserError, payload: ContextMenuCommandDeniedPayload]; + [SapphireEvents.ContextMenuCommandAccepted]: [payload: ContextMenuCommandAcceptedPayload]; - // Context menu command chain - [Events.PossibleContextMenuCommand]: [interaction: ContextMenuInteraction]; - [Events.UnknownContextMenuCommand]: [payload: UnknownContextMenuCommandPayload]; - [Events.CommandDoesNotHaveContextMenuCommandHandler]: [payload: CommandDoesNotHaveContextMenuCommandHandlerPayload]; - [Events.PreContextMenuCommandRun]: [payload: PreContextMenuCommandRunPayload]; - - [Events.ContextMenuCommandDenied]: [error: UserError, payload: ContextMenuCommandDeniedPayload]; - [Events.ContextMenuCommandAccepted]: [payload: ContextMenuCommandAcceptedPayload]; - - [Events.ContextMenuCommandRun]: [interaction: ContextMenuInteraction, command: ContextMenuCommand, payload: ContextMenuCommandRunPayload]; - [Events.ContextMenuCommandSuccess]: [payload: ContextMenuCommandSuccessPayload]; - [Events.ContextMenuCommandError]: [error: unknown, payload: ContextMenuCommandErrorPayload]; - [Events.ContextMenuCommandFinish]: [ - interaction: ContextMenuInteraction, + [SapphireEvents.ContextMenuCommandRun]: [ + interaction: ContextMenuCommandInteraction, + command: ContextMenuCommand, + payload: ContextMenuCommandRunPayload + ]; + [SapphireEvents.ContextMenuCommandSuccess]: [payload: ContextMenuCommandSuccessPayload]; + [SapphireEvents.ContextMenuCommandError]: [error: unknown, payload: ContextMenuCommandErrorPayload]; + [SapphireEvents.ContextMenuCommandFinish]: [ + interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, payload: ContextMenuCommandFinishPayload ]; diff --git a/src/lib/utils/application-commands/ApplicationCommandRegistry.ts b/src/lib/utils/application-commands/ApplicationCommandRegistry.ts index ebd9c3653..a3b2e46ba 100644 --- a/src/lib/utils/application-commands/ApplicationCommandRegistry.ts +++ b/src/lib/utils/application-commands/ApplicationCommandRegistry.ts @@ -16,7 +16,6 @@ import type { ApplicationCommandManager, ChatInputApplicationCommandData, Collection, - Constants, MessageApplicationCommandData, UserApplicationCommandData } from 'discord.js'; @@ -235,25 +234,11 @@ export class ApplicationCommandRegistry { const findCallback = (entry: ApplicationCommand) => { // If the command is a chat input command, we need to check if the entry is a chat input command - if (apiCall.type === InternalRegistryAPIType.ChatInput && entry.type !== 'CHAT_INPUT') return false; + if (apiCall.type === InternalRegistryAPIType.ChatInput && entry.type !== ApplicationCommandType.ChatInput) return false; // If the command is a context menu command, we need to check if the entry is a context menu command of the same type if (apiCall.type === InternalRegistryAPIType.ContextMenu) { - if (entry.type === 'CHAT_INPUT') return false; - - let apiCallType: keyof (typeof Constants)['ApplicationCommandTypes']; - - switch (apiCall.builtData.type) { - case ApplicationCommandType.Message: - apiCallType = 'MESSAGE'; - break; - case ApplicationCommandType.User: - apiCallType = 'USER'; - break; - default: - throw new Error(`Unhandled context command type: ${apiCall.builtData.type}`); - } - - if (apiCallType !== entry.type) return false; + if (entry.type === ApplicationCommandType.ChatInput) return false; + return apiCall.builtData.type === entry.type; } // Find the command by name or by id hint (mostly useful for context menus) @@ -454,8 +439,6 @@ export class ApplicationCommandRegistry { guildId?: string ) { try { - // TODO (favna): Replace with ts-expect-error after website rewrite is done - // @ts-ignore Currently there's a discord-api-types version clash between builders and discord.js const result = await commandsManager.create(apiData, guildId); if (guildId) { diff --git a/src/lib/utils/application-commands/computeDifferences.ts b/src/lib/utils/application-commands/computeDifferences.ts index 95e14e5fe..0aeb2b71d 100644 --- a/src/lib/utils/application-commands/computeDifferences.ts +++ b/src/lib/utils/application-commands/computeDifferences.ts @@ -71,16 +71,6 @@ export function* getCommandDifferences( }; } - // Check defaultPermissions - // TODO(vladfrangu): This will be deprecated - if ((existingCommand.default_permission ?? true) !== (casted.default_permission ?? true)) { - yield { - key: 'defaultPermission', - original: String(existingCommand.default_permission ?? true), - expected: String(casted.default_permission ?? true) - }; - } - // Check dmPermission only for non-guild commands if (!guildCommand && (existingCommand.dm_permission ?? true) !== (casted.dm_permission ?? true)) { yield { @@ -154,16 +144,6 @@ export function* getCommandDifferences( yield* reportLocalizationMapDifferences(originalLocalizedNames, expectedLocalizedNames, 'nameLocalizations'); } - // Check defaultPermissions - // TODO(vladfrangu): This will be deprecated - if ((existingCommand.default_permission ?? true) !== (casted.default_permission ?? true)) { - yield { - key: 'defaultPermission', - original: String(existingCommand.default_permission ?? true), - expected: String(casted.default_permission ?? true) - }; - } - // Check dmPermission if (!guildCommand && (existingCommand.dm_permission ?? true) !== (casted.dm_permission ?? true)) { yield { diff --git a/src/lib/utils/application-commands/normalizeInputs.ts b/src/lib/utils/application-commands/normalizeInputs.ts index 071753d2b..4e70abc11 100644 --- a/src/lib/utils/application-commands/normalizeInputs.ts +++ b/src/lib/utils/application-commands/normalizeInputs.ts @@ -14,7 +14,6 @@ import { } from 'discord-api-types/v10'; import { ApplicationCommand, - Constants, type ChatInputApplicationCommandData, type MessageApplicationCommandData, type UserApplicationCommandData @@ -31,7 +30,6 @@ function isBuilder( } function addDefaultsToChatInputJSON(data: RESTPostAPIChatInputApplicationCommandsJSONBody): RESTPostAPIChatInputApplicationCommandsJSONBody { - data.default_permission ??= true; data.dm_permission ??= true; data.type ??= ApplicationCommandType.ChatInput; @@ -43,7 +41,6 @@ function addDefaultsToChatInputJSON(data: RESTPostAPIChatInputApplicationCommand } function addDefaultsToContextMenuJSON(data: RESTPostAPIContextMenuApplicationCommandsJSONBody): RESTPostAPIContextMenuApplicationCommandsJSONBody { - data.default_permission ??= true; data.dm_permission ??= true; // Localizations default to null from d.js @@ -77,7 +74,6 @@ export function normalizeChatInputCommand( name_localizations: command.nameLocalizations, description: command.description, description_localizations: command.descriptionLocalizations, - default_permission: command.defaultPermission, type: ApplicationCommandType.ChatInput, dm_permission: command.dmPermission }; @@ -110,27 +106,10 @@ export function normalizeContextMenuCommand( return addDefaultsToContextMenuJSON(command.toJSON() as RESTPostAPIContextMenuApplicationCommandsJSONBody); } - let type: ApplicationCommandType; - - switch (command.type) { - case Constants.ApplicationCommandTypes.MESSAGE: - case 'MESSAGE': - type = ApplicationCommandType.Message; - break; - case Constants.ApplicationCommandTypes.USER: - case 'USER': - type = ApplicationCommandType.User; - break; - default: - // @ts-expect-error command gets turned to never, which is half true. - throw new Error(`Unhandled command type: ${command.type}`); - } - const finalObject: RESTPostAPIContextMenuApplicationCommandsJSONBody = { name: command.name, name_localizations: command.nameLocalizations, - type, - default_permission: command.defaultPermission, + type: command.type, dm_permission: command.dmPermission }; @@ -145,7 +124,6 @@ export function convertApplicationCommandToApiData(command: ApplicationCommand): const returnData = { name: command.name, name_localizations: command.nameLocalizations, - default_permission: command.defaultPermission, dm_permission: command.dmPermission } as RESTPostAPIApplicationCommandsJSONBody; @@ -153,16 +131,18 @@ export function convertApplicationCommandToApiData(command: ApplicationCommand): returnData.default_member_permissions = command.defaultMemberPermissions.bitfield.toString(); } - if (command.type === 'CHAT_INPUT') { + if (command.type === ApplicationCommandType.ChatInput) { returnData.type = ApplicationCommandType.ChatInput; (returnData as RESTPostAPIChatInputApplicationCommandsJSONBody).description = command.description; // TODO (favna): Remove this line after website rewrite is done // @ts-ignore this is currently ignored for the website (returnData as RESTPostAPIChatInputApplicationCommandsJSONBody).description_localizations = command.descriptionLocalizations; - } else if (command.type === 'MESSAGE') { + } else if (command.type === ApplicationCommandType.Message) { returnData.type = ApplicationCommandType.Message; - } else if (command.type === 'USER') { + } else if (command.type === ApplicationCommandType.User) { returnData.type = ApplicationCommandType.User; + } else { + throw new Error(`Unknown command type received: ${command.type}`); } if (command.options.length) { diff --git a/src/lib/utils/logger/ILogger.ts b/src/lib/utils/logger/ILogger.ts index 47d436b90..f12a03633 100644 --- a/src/lib/utils/logger/ILogger.ts +++ b/src/lib/utils/logger/ILogger.ts @@ -1,7 +1,7 @@ /** * The logger levels for the {@link ILogger}. */ -export const enum LogLevel { +export enum LogLevel { /** * The lowest log level, used when calling {@link ILogger.trace}. */ diff --git a/src/lib/utils/preconditions/IPreconditionContainer.ts b/src/lib/utils/preconditions/IPreconditionContainer.ts index 283a308cf..c6eb3ea62 100644 --- a/src/lib/utils/preconditions/IPreconditionContainer.ts +++ b/src/lib/utils/preconditions/IPreconditionContainer.ts @@ -1,6 +1,6 @@ import type { Result } from '@sapphire/result'; import type { Awaitable } from '@sapphire/utilities'; -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import type { UserError } from '../../errors/UserError'; import type { Command } from '../../structures/Command'; import type { PreconditionContext } from '../../structures/Precondition'; @@ -33,6 +33,7 @@ export interface IPreconditionContainer { * @since 1.0.0 * @param message The message that ran this precondition. * @param command The command the message invoked. + * @param context The context for the precondition. */ messageRun(message: Message, command: Command, context?: PreconditionContext): PreconditionContainerReturn; /** @@ -40,13 +41,15 @@ export interface IPreconditionContainer { * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. + * @param context The context for the precondition. */ - chatInputRun(interaction: CommandInteraction, command: Command, context?: PreconditionContext): PreconditionContainerReturn; + chatInputRun(interaction: ChatInputCommandInteraction, command: Command, context?: PreconditionContext): PreconditionContainerReturn; /** * Runs a precondition container. * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. + * @param context The context for the precondition. */ - contextMenuRun(interaction: ContextMenuInteraction, command: Command, context?: PreconditionContext): PreconditionContainerReturn; + contextMenuRun(interaction: ContextMenuCommandInteraction, command: Command, context?: PreconditionContext): PreconditionContainerReturn; } diff --git a/src/lib/utils/preconditions/PreconditionContainerArray.ts b/src/lib/utils/preconditions/PreconditionContainerArray.ts index 3f3ea47c2..8cf51d793 100644 --- a/src/lib/utils/preconditions/PreconditionContainerArray.ts +++ b/src/lib/utils/preconditions/PreconditionContainerArray.ts @@ -1,4 +1,4 @@ -import { Collection, type CommandInteraction, type ContextMenuInteraction, type Message } from 'discord.js'; +import { Collection, type ChatInputCommandInteraction, type ContextMenuCommandInteraction, type Message } from 'discord.js'; import type { ChatInputCommand, ContextMenuCommand, MessageCommand } from '../../structures/Command'; import type { PreconditionContext, PreconditionKeys, SimplePreconditionKeys } from '../../structures/Precondition'; import type { IPreconditionCondition } from './conditions/IPreconditionCondition'; @@ -16,7 +16,7 @@ import { * The run mode for a {@link PreconditionContainerArray}. * @since 1.0.0 */ -export const enum PreconditionRunMode { +export enum PreconditionRunMode { /** * The entries are run sequentially, this is the default behaviour and can be slow when doing long asynchronous * tasks, but is performance savvy. @@ -163,6 +163,7 @@ export class PreconditionContainerArray implements IPreconditionContainer { * @since 1.0.0 * @param message The message that ran this precondition. * @param command The command the message invoked. + * @param context The context for the message command precondition. */ public messageRun(message: Message, command: MessageCommand, context: PreconditionContext = {}): PreconditionContainerReturn { return this.mode === PreconditionRunMode.Sequential @@ -175,8 +176,13 @@ export class PreconditionContainerArray implements IPreconditionContainer { * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. + * @param context The context for the chat input precondition. */ - public chatInputRun(interaction: CommandInteraction, command: ChatInputCommand, context: PreconditionContext = {}): PreconditionContainerReturn { + public chatInputRun( + interaction: ChatInputCommandInteraction, + command: ChatInputCommand, + context: PreconditionContext = {} + ): PreconditionContainerReturn { return this.mode === PreconditionRunMode.Sequential ? this.condition.chatInputSequential(interaction, command, this.entries, context) : this.condition.chatInputParallel(interaction, command, this.entries, context); @@ -187,9 +193,10 @@ export class PreconditionContainerArray implements IPreconditionContainer { * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. + * @param context The context for the context menu precondition. */ public contextMenuRun( - interaction: ContextMenuInteraction, + interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, context: PreconditionContext = {} ): PreconditionContainerReturn { diff --git a/src/lib/utils/preconditions/PreconditionContainerSingle.ts b/src/lib/utils/preconditions/PreconditionContainerSingle.ts index 530618e29..ed542aebf 100644 --- a/src/lib/utils/preconditions/PreconditionContainerSingle.ts +++ b/src/lib/utils/preconditions/PreconditionContainerSingle.ts @@ -1,6 +1,6 @@ import { container } from '@sapphire/pieces'; import { err } from '@sapphire/result'; -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../../errors/Identifiers'; import { UserError } from '../../errors/UserError'; import type { ChatInputCommand, ContextMenuCommand, MessageCommand } from '../../structures/Command'; @@ -79,6 +79,7 @@ export class PreconditionContainerSingle implements IPreconditionContainer { * @since 1.0.0 * @param message The message that ran this precondition. * @param command The command the message invoked. + * @param context The context for the message precondition. */ public messageRun(message: Message, command: MessageCommand, context: PreconditionContext = {}) { const precondition = container.stores.get('preconditions').get(this.name); @@ -98,8 +99,9 @@ export class PreconditionContainerSingle implements IPreconditionContainer { * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. + * @param context The context for the chat input command precondition. */ - public chatInputRun(interaction: CommandInteraction, command: ChatInputCommand, context: PreconditionContext = {}) { + public chatInputRun(interaction: ChatInputCommandInteraction, command: ChatInputCommand, context: PreconditionContext = {}) { const precondition = container.stores.get('preconditions').get(this.name); if (precondition) { return precondition.chatInputRun @@ -117,8 +119,9 @@ export class PreconditionContainerSingle implements IPreconditionContainer { * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. + * @param context The context for the context menu command precondition. */ - public contextMenuRun(interaction: ContextMenuInteraction, command: ContextMenuCommand, context: PreconditionContext = {}) { + public contextMenuRun(interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, context: PreconditionContext = {}) { const precondition = container.stores.get('preconditions').get(this.name); if (precondition) { return precondition.contextMenuRun diff --git a/src/lib/utils/preconditions/conditions/IPreconditionCondition.ts b/src/lib/utils/preconditions/conditions/IPreconditionCondition.ts index 327818a45..e74d474fc 100644 --- a/src/lib/utils/preconditions/conditions/IPreconditionCondition.ts +++ b/src/lib/utils/preconditions/conditions/IPreconditionCondition.ts @@ -1,4 +1,4 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import type { ChatInputCommand, ContextMenuCommand, MessageCommand } from '../../../structures/Command'; import type { PreconditionContext } from '../../../structures/Precondition'; import type { IPreconditionContainer, PreconditionContainerReturn } from '../IPreconditionContainer'; @@ -10,11 +10,12 @@ import type { IPreconditionContainer, PreconditionContainerReturn } from '../IPr export interface IPreconditionCondition { /** * Runs the containers one by one. - * @seealso {@link PreconditionRunMode.sequential} + * @seealso {@link PreconditionRunMode.Sequential} * @since 1.0.0 * @param message The message that ran this precondition. * @param command The command the message invoked. * @param entries The containers to run. + * @param context The context for the precondition. */ messageSequential( message: Message, @@ -25,11 +26,12 @@ export interface IPreconditionCondition { /** * Runs all the containers using `Promise.all`, then checks the results once all tasks finished running. - * @seealso {@link PreconditionRunMode.parallel} + * @seealso {@link PreconditionRunMode.Parallel} * @since 1.0.0 * @param message The message that ran this precondition. * @param command The command the message invoked. * @param entries The containers to run. + * @param context The context for the precondition. */ messageParallel( message: Message, @@ -40,14 +42,15 @@ export interface IPreconditionCondition { /** * Runs the containers one by one. - * @seealso {@link PreconditionRunMode.sequential} + * @seealso {@link PreconditionRunMode.Sequential} * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. * @param entries The containers to run. + * @param context The context for the precondition. */ chatInputSequential( - interaction: CommandInteraction, + interaction: ChatInputCommandInteraction, command: ChatInputCommand, entries: readonly IPreconditionContainer[], context: PreconditionContext @@ -55,14 +58,15 @@ export interface IPreconditionCondition { /** * Runs all the containers using `Promise.all`, then checks the results once all tasks finished running. - * @seealso {@link PreconditionRunMode.parallel} + * @seealso {@link PreconditionRunMode.Parallel} * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. * @param entries The containers to run. + * @param context The context for the precondition. */ chatInputParallel( - interaction: CommandInteraction, + interaction: ChatInputCommandInteraction, command: ChatInputCommand, entries: readonly IPreconditionContainer[], context: PreconditionContext @@ -70,14 +74,15 @@ export interface IPreconditionCondition { /** * Runs the containers one by one. - * @seealso {@link PreconditionRunMode.sequential} + * @seealso {@link PreconditionRunMode.Sequential} * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. * @param entries The containers to run. + * @param context The context for the precondition. */ contextMenuSequential( - interaction: ContextMenuInteraction, + interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, entries: readonly IPreconditionContainer[], context: PreconditionContext @@ -85,14 +90,15 @@ export interface IPreconditionCondition { /** * Runs all the containers using `Promise.all`, then checks the results once all tasks finished running. - * @seealso {@link PreconditionRunMode.parallel} + * @seealso {@link PreconditionRunMode.Parallel} * @since 3.0.0 * @param interaction The interaction that ran this precondition. * @param command The command the interaction invoked. * @param entries The containers to run. + * @param context The context for the precondition. */ contextMenuParallel( - interaction: ContextMenuInteraction, + interaction: ContextMenuCommandInteraction, command: ContextMenuCommand, entries: readonly IPreconditionContainer[], context: PreconditionContext diff --git a/src/lib/utils/preconditions/containers/ClientPermissionsPrecondition.ts b/src/lib/utils/preconditions/containers/ClientPermissionsPrecondition.ts index 2f3aa26fc..99252924e 100644 --- a/src/lib/utils/preconditions/containers/ClientPermissionsPrecondition.ts +++ b/src/lib/utils/preconditions/containers/ClientPermissionsPrecondition.ts @@ -1,4 +1,4 @@ -import { Permissions, type PermissionResolvable } from 'discord.js'; +import { PermissionsBitField, type PermissionResolvable } from 'discord.js'; import type { PreconditionSingleResolvableDetails } from '../PreconditionContainerSingle'; /** @@ -24,7 +24,7 @@ import type { PreconditionSingleResolvableDetails } from '../PreconditionContain */ export class ClientPermissionsPrecondition implements PreconditionSingleResolvableDetails<'ClientPermissions'> { public name: 'ClientPermissions'; - public context: { permissions: Permissions }; + public context: { permissions: PermissionsBitField }; /** * Constructs a precondition container entry. @@ -33,7 +33,7 @@ export class ClientPermissionsPrecondition implements PreconditionSingleResolvab public constructor(permissions: PermissionResolvable) { this.name = 'ClientPermissions'; this.context = { - permissions: new Permissions(permissions) + permissions: new PermissionsBitField(permissions) }; } } diff --git a/src/lib/utils/preconditions/containers/UserPermissionsPrecondition.ts b/src/lib/utils/preconditions/containers/UserPermissionsPrecondition.ts index bc67da336..7f1a471f1 100644 --- a/src/lib/utils/preconditions/containers/UserPermissionsPrecondition.ts +++ b/src/lib/utils/preconditions/containers/UserPermissionsPrecondition.ts @@ -1,4 +1,4 @@ -import { Permissions, type PermissionResolvable } from 'discord.js'; +import { PermissionsBitField, type PermissionResolvable } from 'discord.js'; import type { PreconditionSingleResolvableDetails } from '../PreconditionContainerSingle'; /** @@ -24,7 +24,7 @@ import type { PreconditionSingleResolvableDetails } from '../PreconditionContain */ export class UserPermissionsPrecondition implements PreconditionSingleResolvableDetails<'UserPermissions'> { public name: 'UserPermissions'; - public context: { permissions: Permissions }; + public context: { permissions: PermissionsBitField }; /** * Constructs a precondition container entry. @@ -33,7 +33,7 @@ export class UserPermissionsPrecondition implements PreconditionSingleResolvable public constructor(permissions: PermissionResolvable) { this.name = 'UserPermissions'; this.context = { - permissions: new Permissions(permissions) + permissions: new PermissionsBitField(permissions) }; } } diff --git a/src/listeners/CoreInteractionCreate.ts b/src/listeners/CoreInteractionCreate.ts index 0d5c1a575..bd37eeef8 100644 --- a/src/listeners/CoreInteractionCreate.ts +++ b/src/listeners/CoreInteractionCreate.ts @@ -8,16 +8,16 @@ export class CoreEvent extends Listener { } public async run(interaction: Interaction) { - if (interaction.isCommand()) { + if (interaction.isChatInputCommand()) { this.container.client.emit(Events.PossibleChatInputCommand, interaction); - } else if (interaction.isContextMenu()) { + } else if (interaction.isContextMenuCommand()) { this.container.client.emit(Events.PossibleContextMenuCommand, interaction); } else if (interaction.isAutocomplete()) { this.container.client.emit(Events.PossibleAutocompleteInteraction, interaction); } else if (interaction.isMessageComponent() || interaction.isModalSubmit()) { await this.container.stores.get('interaction-handlers').run(interaction); } else { - this.container.logger.warn(`[Sapphire ${this.location.name}] Unhandled interaction type: ${interaction.constructor.name}`); + this.container.logger.warn(`[Sapphire ${this.location.name}] Unhandled interaction type: ${(interaction as any).constructor.name}`); } } } diff --git a/src/listeners/application-commands/chat-input/CorePossibleChatInputCommand.ts b/src/listeners/application-commands/chat-input/CorePossibleChatInputCommand.ts index 877565b65..88751f4b4 100644 --- a/src/listeners/application-commands/chat-input/CorePossibleChatInputCommand.ts +++ b/src/listeners/application-commands/chat-input/CorePossibleChatInputCommand.ts @@ -1,4 +1,4 @@ -import type { CommandInteraction } from 'discord.js'; +import type { ChatInputCommandInteraction } from 'discord.js'; import type { ChatInputCommand } from '../../../lib/structures/Command'; import { Listener } from '../../../lib/structures/Listener'; import { Events } from '../../../lib/types/Events'; @@ -8,7 +8,7 @@ export class CoreListener extends Listener { - private readonly requiredPermissions = new Permissions(['VIEW_CHANNEL', 'SEND_MESSAGES']).freeze(); + private readonly requiredPermissions = new PermissionsBitField([PermissionFlagsBits.ViewChannel, PermissionFlagsBits.SendMessages]).freeze(); public constructor(context: Listener.Context) { super(context, { event: Events.PreMessageParsed }); @@ -42,10 +42,10 @@ export class CoreListener extends Listener { private async canRunInChannel(message: Message): Promise { if (isDMChannel(message.channel)) return true; - const me = message.guild!.me ?? (message.client.id ? await message.guild!.members.fetch(message.client.id) : null); + const me = await message.guild?.members.fetchMe(); if (!me) return false; - const channel = message.channel as GuildBasedChannelTypes; + const { channel } = message; const permissionsFor = channel.permissionsFor(me); if (!permissionsFor) return false; diff --git a/src/preconditions/ClientPermissions.ts b/src/preconditions/ClientPermissions.ts index 20e4ebe84..94bbcb5cd 100644 --- a/src/preconditions/ClientPermissions.ts +++ b/src/preconditions/ClientPermissions.ts @@ -1,36 +1,37 @@ import { - Permissions, + ChatInputCommandInteraction, + ContextMenuCommandInteraction, + PermissionFlagsBits, + PermissionsBitField, + PermissionsString, type BaseGuildTextChannel, - type CommandInteraction, - type ContextMenuInteraction, type GuildTextBasedChannel, - type Message, - type PermissionString + type Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import type { Command } from '../lib/structures/Command'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; export interface PermissionPreconditionContext extends AllFlowsPrecondition.Context { - permissions?: Permissions; + permissions?: PermissionsBitField; } export class CorePrecondition extends AllFlowsPrecondition { - private readonly dmChannelPermissions = new Permissions( - ~new Permissions([ + private readonly dmChannelPermissions = new PermissionsBitField( + ~new PermissionsBitField([ // - 'ADD_REACTIONS', - 'ATTACH_FILES', - 'EMBED_LINKS', - 'READ_MESSAGE_HISTORY', - 'SEND_MESSAGES', - 'USE_EXTERNAL_EMOJIS', - 'VIEW_CHANNEL' - ]).bitfield & Permissions.ALL + PermissionFlagsBits.AddReactions, + PermissionFlagsBits.AttachFiles, + PermissionFlagsBits.EmbedLinks, + PermissionFlagsBits.ReadMessageHistory, + PermissionFlagsBits.SendMessages, + PermissionFlagsBits.UseExternalEmojis, + PermissionFlagsBits.ViewChannel + ]).bitfield & PermissionsBitField.All ).freeze(); public messageRun(message: Message, _: Command, context: PermissionPreconditionContext): AllFlowsPrecondition.Result { - const required = context.permissions ?? new Permissions(); + const required = context.permissions ?? new PermissionsBitField(); const channel = message.channel as BaseGuildTextChannel; if (!message.client.id) { @@ -45,8 +46,12 @@ export class CorePrecondition extends AllFlowsPrecondition { return this.sharedRun(required, permissions, 'message'); } - public async chatInputRun(interaction: CommandInteraction, _: Command, context: PermissionPreconditionContext): AllFlowsPrecondition.AsyncResult { - const required = context.permissions ?? new Permissions(); + public async chatInputRun( + interaction: ChatInputCommandInteraction, + _: Command, + context: PermissionPreconditionContext + ): AllFlowsPrecondition.AsyncResult { + const required = context.permissions ?? new PermissionsBitField(); const channel = (await this.fetchChannelFromInteraction(interaction)) as GuildTextBasedChannel; @@ -56,11 +61,11 @@ export class CorePrecondition extends AllFlowsPrecondition { } public async contextMenuRun( - interaction: ContextMenuInteraction, + interaction: ContextMenuCommandInteraction, _: Command, context: PermissionPreconditionContext ): AllFlowsPrecondition.AsyncResult { - const required = context.permissions ?? new Permissions(); + const required = context.permissions ?? new PermissionsBitField(); const channel = (await this.fetchChannelFromInteraction(interaction)) as GuildTextBasedChannel; const permissions = interaction.inGuild() ? channel.permissionsFor(interaction.applicationId) : this.dmChannelPermissions; @@ -68,7 +73,7 @@ export class CorePrecondition extends AllFlowsPrecondition { return this.sharedRun(required, permissions, 'context menu'); } - private sharedRun(requiredPermissions: Permissions, availablePermissions: Permissions | null, commandType: string) { + private sharedRun(requiredPermissions: PermissionsBitField, availablePermissions: PermissionsBitField | null, commandType: string) { if (!availablePermissions) { return this.error({ identifier: Identifiers.PreconditionClientPermissionsNoPermissions, @@ -88,49 +93,47 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public static readonly readablePermissions: Record = { - ADD_REACTIONS: 'Add Reactions', - ADMINISTRATOR: 'Administrator', - ATTACH_FILES: 'Attach Files', - BAN_MEMBERS: 'Ban Members', - CHANGE_NICKNAME: 'Change Nickname', - CONNECT: 'Connect', - CREATE_INSTANT_INVITE: 'Create Instant Invite', - CREATE_PRIVATE_THREADS: 'Create Private Threads', - CREATE_PUBLIC_THREADS: 'Create Public Threads', - DEAFEN_MEMBERS: 'Deafen Members', - EMBED_LINKS: 'Embed Links', - KICK_MEMBERS: 'Kick Members', - MANAGE_CHANNELS: 'Manage Channels', - MANAGE_EMOJIS_AND_STICKERS: 'Manage Emojis and Stickers', - MANAGE_EVENTS: 'Manage Events', - MANAGE_GUILD: 'Manage Server', - MANAGE_MESSAGES: 'Manage Messages', - MANAGE_NICKNAMES: 'Manage Nicknames', - MANAGE_ROLES: 'Manage Roles', - MANAGE_THREADS: 'Manage Threads', - MANAGE_WEBHOOKS: 'Manage Webhooks', - MENTION_EVERYONE: 'Mention Everyone', - MODERATE_MEMBERS: 'Moderate Members', - MOVE_MEMBERS: 'Move Members', - MUTE_MEMBERS: 'Mute Members', - PRIORITY_SPEAKER: 'Priority Speaker', - READ_MESSAGE_HISTORY: 'Read Message History', - REQUEST_TO_SPEAK: 'Request to Speak', - SEND_MESSAGES_IN_THREADS: 'Send Messages in Threads', - SEND_MESSAGES: 'Send Messages', - SEND_TTS_MESSAGES: 'Send TTS Messages', - SPEAK: 'Speak', - START_EMBEDDED_ACTIVITIES: 'Start Activities', - STREAM: 'Stream', - USE_APPLICATION_COMMANDS: 'Use Application Commands', - USE_EXTERNAL_EMOJIS: 'Use External Emojis', - USE_EXTERNAL_STICKERS: 'Use External Stickers', - USE_PRIVATE_THREADS: 'Use Private Threads', - USE_PUBLIC_THREADS: 'Use Public Threads', - USE_VAD: 'Use Voice Activity', - VIEW_AUDIT_LOG: 'View Audit Log', - VIEW_CHANNEL: 'Read Messages', - VIEW_GUILD_INSIGHTS: 'View Guild Insights' + public static readonly readablePermissions: Record = { + AddReactions: 'Add Reactions', + Administrator: 'Administrator', + AttachFiles: 'Attach Files', + BanMembers: 'Ban Members', + ChangeNickname: 'Change Nickname', + Connect: 'Connect', + CreateInstantInvite: 'Create Instant Invite', + CreatePrivateThreads: 'Create Private Threads', + CreatePublicThreads: 'Create Public Threads', + DeafenMembers: 'Deafen Members', + EmbedLinks: 'Embed Links', + KickMembers: 'Kick Members', + ManageChannels: 'Manage Channels', + ManageEmojisAndStickers: 'Manage Emojis and Stickers', + ManageEvents: 'Manage Events', + ManageGuild: 'Manage Server', + ManageMessages: 'Manage Messages', + ManageNicknames: 'Manage Nicknames', + ManageRoles: 'Manage Roles', + ManageThreads: 'Manage Threads', + ManageWebhooks: 'Manage Webhooks', + MentionEveryone: 'Mention Everyone', + ModerateMembers: 'Moderate Members', + MoveMembers: 'Move Members', + MuteMembers: 'Mute Members', + PrioritySpeaker: 'Priority Speaker', + ReadMessageHistory: 'Read Message History', + RequestToSpeak: 'Request to Speak', + SendMessagesInThreads: 'Send Messages in Threads', + SendMessages: 'Send Messages', + SendTTSMessages: 'Send TTS Messages', + Speak: 'Speak', + UseEmbeddedActivities: 'Start Activities', + Stream: 'Stream', + UseApplicationCommands: 'Use Application Commands', + UseExternalEmojis: 'Use External Emojis', + UseExternalStickers: 'Use External Stickers', + UseVAD: 'Use Voice Activity', + ViewAuditLog: 'View Audit Log', + ViewChannel: 'Read Messages', + ViewGuildInsights: 'View Guild Insights' }; } diff --git a/src/preconditions/Cooldown.ts b/src/preconditions/Cooldown.ts index 319bd2c43..fabc9a535 100644 --- a/src/preconditions/Cooldown.ts +++ b/src/preconditions/Cooldown.ts @@ -1,5 +1,5 @@ import { RateLimitManager } from '@sapphire/ratelimits'; -import type { BaseCommandInteraction, CommandInteraction, ContextMenuInteraction, Message, Snowflake } from 'discord.js'; +import type { ChatInputCommandInteraction, CommandInteraction, ContextMenuCommandInteraction, Message, Snowflake } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import type { Command } from '../lib/structures/Command'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; @@ -21,13 +21,21 @@ export class CorePrecondition extends AllFlowsPrecondition { return this.sharedRun(message.author.id, command, context, cooldownId, 'message'); } - public chatInputRun(interaction: CommandInteraction, command: Command, context: CooldownPreconditionContext): AllFlowsPrecondition.Result { + public chatInputRun( + interaction: ChatInputCommandInteraction, + command: Command, + context: CooldownPreconditionContext + ): AllFlowsPrecondition.Result { const cooldownId = this.getIdFromInteraction(interaction, context); return this.sharedRun(interaction.user.id, command, context, cooldownId, 'chat input'); } - public contextMenuRun(interaction: ContextMenuInteraction, command: Command, context: CooldownPreconditionContext): AllFlowsPrecondition.Result { + public contextMenuRun( + interaction: ContextMenuCommandInteraction, + command: Command, + context: CooldownPreconditionContext + ): AllFlowsPrecondition.Result { const cooldownId = this.getIdFromInteraction(interaction, context); return this.sharedRun(interaction.user.id, command, context, cooldownId, 'context menu'); @@ -49,21 +57,21 @@ export class CorePrecondition extends AllFlowsPrecondition { // If the user has provided any filtered users and the authorId is in that array, return ok: if (context.filteredUsers?.includes(authorId)) return this.ok(); - const ratelimit = this.getManager(command, context).acquire(cooldownId); + const rateLimit = this.getManager(command, context).acquire(cooldownId); - if (ratelimit.limited) { - const remaining = ratelimit.remainingTime; + if (rateLimit.limited) { + const remaining = rateLimit.remainingTime; return this.error({ identifier: Identifiers.PreconditionCooldown, message: `There is a cooldown in effect for this ${commandType} command. It'll be available at ${new Date( - ratelimit.expires + rateLimit.expires ).toISOString()}.`, context: { remaining } }); } - ratelimit.consume(); + rateLimit.consume(); return this.ok(); } @@ -80,7 +88,7 @@ export class CorePrecondition extends AllFlowsPrecondition { } } - private getIdFromInteraction(interaction: BaseCommandInteraction, context: CooldownPreconditionContext) { + private getIdFromInteraction(interaction: CommandInteraction, context: CooldownPreconditionContext) { switch (context.scope) { case BucketScope.Global: return 'global'; diff --git a/src/preconditions/DMOnly.ts b/src/preconditions/DMOnly.ts index 6338e0625..ca1f3abed 100644 --- a/src/preconditions/DMOnly.ts +++ b/src/preconditions/DMOnly.ts @@ -1,4 +1,4 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; @@ -9,13 +9,13 @@ export class CorePrecondition extends AllFlowsPrecondition { : this.error({ identifier: Identifiers.PreconditionDMOnly, message: 'You cannot run this message command outside DMs.' }); } - public chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.Result { + public chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.Result { return interaction.guildId === null ? this.ok() : this.error({ identifier: Identifiers.PreconditionDMOnly, message: 'You cannot run this chat input command outside DMs.' }); } - public contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.Result { + public contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.Result { return interaction.guildId === null ? this.ok() : this.error({ identifier: Identifiers.PreconditionDMOnly, message: 'You cannot run this context menu command outside DMs.' }); diff --git a/src/preconditions/Enabled.ts b/src/preconditions/Enabled.ts index 90f7bdcb6..5526e1250 100644 --- a/src/preconditions/Enabled.ts +++ b/src/preconditions/Enabled.ts @@ -1,5 +1,5 @@ import type { PieceContext } from '@sapphire/pieces'; -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import type { Command } from '../lib/structures/Command'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; @@ -15,13 +15,13 @@ export class CorePrecondition extends AllFlowsPrecondition { : this.error({ identifier: Identifiers.CommandDisabled, message: 'This message command is disabled.', context }); } - public chatInputRun(_: CommandInteraction, command: Command, context: AllFlowsPrecondition.Context): AllFlowsPrecondition.Result { + public chatInputRun(_: ChatInputCommandInteraction, command: Command, context: AllFlowsPrecondition.Context): AllFlowsPrecondition.Result { return command.enabled ? this.ok() : this.error({ identifier: Identifiers.CommandDisabled, message: 'This chat input command is disabled.', context }); } - public contextMenuRun(_: ContextMenuInteraction, command: Command, context: AllFlowsPrecondition.Context): AllFlowsPrecondition.Result { + public contextMenuRun(_: ContextMenuCommandInteraction, command: Command, context: AllFlowsPrecondition.Context): AllFlowsPrecondition.Result { return command.enabled ? this.ok() : this.error({ identifier: Identifiers.CommandDisabled, message: 'This context menu command is disabled.', context }); diff --git a/src/preconditions/GuildNewsOnly.ts b/src/preconditions/GuildNewsOnly.ts index 8db9c8c67..6a157d6bf 100644 --- a/src/preconditions/GuildNewsOnly.ts +++ b/src/preconditions/GuildNewsOnly.ts @@ -1,9 +1,9 @@ -import type { CommandInteraction, ContextMenuInteraction, Message, TextBasedChannelTypes } from 'discord.js'; +import { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, Message, TextBasedChannelTypes } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; export class CorePrecondition extends AllFlowsPrecondition { - private readonly allowedTypes: TextBasedChannelTypes[] = ['GUILD_NEWS', 'GUILD_NEWS_THREAD']; + private readonly allowedTypes: TextBasedChannelTypes[] = [ChannelType.GuildNews, ChannelType.GuildNewsThread]; public messageRun(message: Message): AllFlowsPrecondition.Result { return this.allowedTypes.includes(message.channel.type) @@ -14,7 +14,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return this.allowedTypes.includes(channel.type) @@ -25,7 +25,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return this.allowedTypes.includes(channel.type) diff --git a/src/preconditions/GuildNewsThreadOnly.ts b/src/preconditions/GuildNewsThreadOnly.ts index ce6982d4a..64bd7f23d 100644 --- a/src/preconditions/GuildNewsThreadOnly.ts +++ b/src/preconditions/GuildNewsThreadOnly.ts @@ -1,10 +1,10 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; export class CorePrecondition extends AllFlowsPrecondition { public messageRun(message: Message): AllFlowsPrecondition.Result { - return message.thread?.type === 'GUILD_NEWS_THREAD' + return message.thread?.type === ChannelType.GuildNewsThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildNewsThreadOnly, @@ -12,10 +12,10 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); - return channel.type === 'GUILD_NEWS_THREAD' + return channel.type === ChannelType.GuildNewsThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildNewsThreadOnly, @@ -23,10 +23,10 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); - return channel.type === 'GUILD_NEWS_THREAD' + return channel.type === ChannelType.GuildNewsThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildNewsThreadOnly, diff --git a/src/preconditions/GuildOnly.ts b/src/preconditions/GuildOnly.ts index 78e8d4ba7..14698991b 100644 --- a/src/preconditions/GuildOnly.ts +++ b/src/preconditions/GuildOnly.ts @@ -1,4 +1,4 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; @@ -9,13 +9,13 @@ export class CorePrecondition extends AllFlowsPrecondition { : this.ok(); } - public chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.Result { + public chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.Result { return interaction.guildId === null ? this.error({ identifier: Identifiers.PreconditionGuildOnly, message: 'You cannot run this chat input command in DMs.' }) : this.ok(); } - public contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.Result { + public contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.Result { return interaction.guildId === null ? this.error({ identifier: Identifiers.PreconditionGuildOnly, message: 'You cannot run this context menu command in DMs.' }) : this.ok(); diff --git a/src/preconditions/GuildPrivateThreadOnly.ts b/src/preconditions/GuildPrivateThreadOnly.ts index 96c8b1407..f7437143d 100644 --- a/src/preconditions/GuildPrivateThreadOnly.ts +++ b/src/preconditions/GuildPrivateThreadOnly.ts @@ -1,10 +1,10 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; export class CorePrecondition extends AllFlowsPrecondition { public messageRun(message: Message): AllFlowsPrecondition.Result { - return message.thread?.type === 'GUILD_PRIVATE_THREAD' + return message.thread?.type === ChannelType.GuildPrivateThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildPrivateThreadOnly, @@ -12,10 +12,10 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); - return channel.type === 'GUILD_PRIVATE_THREAD' + return channel.type === ChannelType.GuildPrivateThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildPrivateThreadOnly, @@ -23,10 +23,10 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); - return channel.type === 'GUILD_PRIVATE_THREAD' + return channel.type === ChannelType.GuildPrivateThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildPrivateThreadOnly, diff --git a/src/preconditions/GuildPublicThreadOnly.ts b/src/preconditions/GuildPublicThreadOnly.ts index 992b2e2e6..d0cb39dc0 100644 --- a/src/preconditions/GuildPublicThreadOnly.ts +++ b/src/preconditions/GuildPublicThreadOnly.ts @@ -1,10 +1,10 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; export class CorePrecondition extends AllFlowsPrecondition { public messageRun(message: Message): AllFlowsPrecondition.Result { - return message.thread?.type === 'GUILD_PUBLIC_THREAD' + return message.thread?.type === ChannelType.GuildPublicThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildPublicThreadOnly, @@ -12,10 +12,10 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); - return channel.type === 'GUILD_PUBLIC_THREAD' + return channel.type === ChannelType.GuildPublicThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildPublicThreadOnly, @@ -23,10 +23,10 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); - return channel.type === 'GUILD_PUBLIC_THREAD' + return channel.type === ChannelType.GuildPublicThread ? this.ok() : this.error({ identifier: Identifiers.PreconditionGuildPublicThreadOnly, diff --git a/src/preconditions/GuildTextOnly.ts b/src/preconditions/GuildTextOnly.ts index f23bea865..12ec70099 100644 --- a/src/preconditions/GuildTextOnly.ts +++ b/src/preconditions/GuildTextOnly.ts @@ -1,9 +1,9 @@ -import type { CommandInteraction, ContextMenuInteraction, Message, TextBasedChannelTypes } from 'discord.js'; +import { ChannelType, ChatInputCommandInteraction, ContextMenuCommandInteraction, Message, TextBasedChannelTypes } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; export class CorePrecondition extends AllFlowsPrecondition { - private readonly allowedTypes: TextBasedChannelTypes[] = ['GUILD_TEXT', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD']; + private readonly allowedTypes: TextBasedChannelTypes[] = [ChannelType.GuildText, ChannelType.GuildPublicThread, ChannelType.GuildPrivateThread]; public messageRun(message: Message): AllFlowsPrecondition.Result { return this.allowedTypes.includes(message.channel.type) @@ -14,7 +14,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return this.allowedTypes.includes(channel.type) @@ -25,7 +25,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return this.allowedTypes.includes(channel.type) diff --git a/src/preconditions/GuildThreadOnly.ts b/src/preconditions/GuildThreadOnly.ts index 16db45998..f3c12f9db 100644 --- a/src/preconditions/GuildThreadOnly.ts +++ b/src/preconditions/GuildThreadOnly.ts @@ -1,4 +1,4 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; @@ -12,7 +12,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return channel.isThread() @@ -23,7 +23,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return channel.isThread() diff --git a/src/preconditions/GuildVoiceOnly.ts b/src/preconditions/GuildVoiceOnly.ts index 7a7bce58b..ce2a48869 100644 --- a/src/preconditions/GuildVoiceOnly.ts +++ b/src/preconditions/GuildVoiceOnly.ts @@ -1,5 +1,5 @@ import { isVoiceChannel } from '@sapphire/discord.js-utilities'; -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; @@ -13,7 +13,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return isVoiceChannel(channel) @@ -24,7 +24,7 @@ export class CorePrecondition extends AllFlowsPrecondition { }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); return isVoiceChannel(channel) diff --git a/src/preconditions/NSFW.ts b/src/preconditions/NSFW.ts index ace63f6e4..5e1fa77dc 100644 --- a/src/preconditions/NSFW.ts +++ b/src/preconditions/NSFW.ts @@ -1,4 +1,4 @@ -import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js'; +import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; @@ -11,7 +11,7 @@ export class CorePrecondition extends AllFlowsPrecondition { : this.error({ identifier: Identifiers.PreconditionNSFW, message: 'You cannot run this message command outside NSFW channels.' }); } - public async chatInputRun(interaction: CommandInteraction): AllFlowsPrecondition.AsyncResult { + public async chatInputRun(interaction: ChatInputCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); // `nsfw` is undefined in DMChannel, doing `=== true` @@ -21,7 +21,7 @@ export class CorePrecondition extends AllFlowsPrecondition { : this.error({ identifier: Identifiers.PreconditionNSFW, message: 'You cannot run this chat input command outside NSFW channels.' }); } - public async contextMenuRun(interaction: ContextMenuInteraction): AllFlowsPrecondition.AsyncResult { + public async contextMenuRun(interaction: ContextMenuCommandInteraction): AllFlowsPrecondition.AsyncResult { const channel = await this.fetchChannelFromInteraction(interaction); // `nsfw` is undefined in DMChannel, doing `=== true` diff --git a/src/preconditions/UserPermissions.ts b/src/preconditions/UserPermissions.ts index 65976554d..3ea6672e5 100644 --- a/src/preconditions/UserPermissions.ts +++ b/src/preconditions/UserPermissions.ts @@ -1,51 +1,67 @@ -import { Permissions, type CommandInteraction, type ContextMenuInteraction, type Message, type NewsChannel, type TextChannel } from 'discord.js'; +import { + ChatInputCommandInteraction, + ContextMenuCommandInteraction, + PermissionFlagsBits, + PermissionsBitField, + type Message, + type NewsChannel, + type TextChannel +} from 'discord.js'; import { Identifiers } from '../lib/errors/Identifiers'; import type { Command } from '../lib/structures/Command'; import { AllFlowsPrecondition } from '../lib/structures/Precondition'; import { CorePrecondition as ClientPrecondition, type PermissionPreconditionContext } from './ClientPermissions'; export class CorePrecondition extends AllFlowsPrecondition { - private readonly dmChannelPermissions = new Permissions( - ~new Permissions([ - 'ADD_REACTIONS', - 'ATTACH_FILES', - 'EMBED_LINKS', - 'READ_MESSAGE_HISTORY', - 'SEND_MESSAGES', - 'USE_EXTERNAL_EMOJIS', - 'VIEW_CHANNEL', - 'USE_EXTERNAL_STICKERS', - 'MENTION_EVERYONE' - ]).bitfield & Permissions.ALL + private readonly dmChannelPermissions = new PermissionsBitField( + ~new PermissionsBitField([ + PermissionFlagsBits.AddReactions, + PermissionFlagsBits.AttachFiles, + PermissionFlagsBits.EmbedLinks, + PermissionFlagsBits.ReadMessageHistory, + PermissionFlagsBits.SendMessages, + PermissionFlagsBits.UseExternalEmojis, + PermissionFlagsBits.ViewChannel, + PermissionFlagsBits.UseExternalStickers, + PermissionFlagsBits.MentionEveryone + ]).bitfield & PermissionsBitField.All ).freeze(); public messageRun(message: Message, _command: Command, context: PermissionPreconditionContext): AllFlowsPrecondition.Result { - const required = context.permissions ?? new Permissions(); + const required = context.permissions ?? new PermissionsBitField(); const channel = message.channel as TextChannel | NewsChannel; const permissions = message.guild ? channel.permissionsFor(message.author) : this.dmChannelPermissions; return this.sharedRun(required, permissions, 'message'); } - public chatInputRun(interaction: CommandInteraction, _command: Command, context: PermissionPreconditionContext): AllFlowsPrecondition.Result { - const required = context.permissions ?? new Permissions(); + public chatInputRun( + interaction: ChatInputCommandInteraction, + _command: Command, + context: PermissionPreconditionContext + ): AllFlowsPrecondition.Result { + const required = context.permissions ?? new PermissionsBitField(); const permissions = interaction.guildId ? interaction.memberPermissions : this.dmChannelPermissions; return this.sharedRun(required, permissions, 'chat input'); } public contextMenuRun( - interaction: ContextMenuInteraction, + interaction: ContextMenuCommandInteraction, _command: Command, context: PermissionPreconditionContext ): AllFlowsPrecondition.Result { - const required = context.permissions ?? new Permissions(); + const required = context.permissions ?? new PermissionsBitField(); const permissions = interaction.guildId ? interaction.memberPermissions : this.dmChannelPermissions; return this.sharedRun(required, permissions, 'context menu'); } - private sharedRun(requiredPermissions: Permissions, availablePermissions: Permissions | null, commandType: string): AllFlowsPrecondition.Result { + private sharedRun( + requiredPermissions: PermissionsBitField, + availablePermissions: PermissionsBitField | null, + commandType: string + ): AllFlowsPrecondition.Result { if (!availablePermissions) { return this.error({ identifier: Identifiers.PreconditionUserPermissionsNoPermissions, diff --git a/tests/application-commands/computeDifferences.test.ts b/tests/application-commands/computeDifferences.test.ts index 8342160f9..450a880cb 100644 --- a/tests/application-commands/computeDifferences.test.ts +++ b/tests/application-commands/computeDifferences.test.ts @@ -44,30 +44,6 @@ describe('Compute differences for provided application commands', () => { ]); }); - test('GIVEN a context menu command WHEN a "default_permission" set to true and one set to false THEN return the difference', () => { - expect( - getCommandDifferences( - { - type: ApplicationCommandType.Message, - name: 'boop', - default_permission: true - }, - { - type: ApplicationCommandType.Message, - name: 'boop', - default_permission: false - }, - false - ) - ).toEqual([ - { - key: 'defaultPermission', - original: 'true', - expected: 'false' - } - ]); - }); - test('GIVEN two identical commands THEN do not return any difference', () => { const command1: RESTPostAPIChatInputApplicationCommandsJSONBody = { description: 'description 1', @@ -102,28 +78,6 @@ describe('Compute differences for provided application commands', () => { ]); }); - test('GIVEN a command WHEN a default_permission set to true and one set to false THEN should return the difference', () => { - const command1: RESTPostAPIChatInputApplicationCommandsJSONBody = { - description: 'description 1', - name: 'command1', - default_permission: true - }; - - const command2: RESTPostAPIChatInputApplicationCommandsJSONBody = { - description: 'description 1', - name: 'command1', - default_permission: false - }; - - expect(getCommandDifferences(command1, command2, false)).toEqual([ - { - key: 'defaultPermission', - original: String(command1.default_permission), - expected: String(command2.default_permission) - } - ]); - }); - test('GIVEN a command WHEN "dm_permission" set to undefined and one set to false THEN return the difference', () => { const command1: RESTPostAPIChatInputApplicationCommandsJSONBody = { description: 'description 1', diff --git a/yarn.lock b/yarn.lock index d5d676c67..c52941968 100644 --- a/yarn.lock +++ b/yarn.lock @@ -244,36 +244,53 @@ __metadata: languageName: node linkType: hard -"@discordjs/builders@npm:^0.16.0": - version: 0.16.0 - resolution: "@discordjs/builders@npm:0.16.0" +"@discordjs/builders@npm:^1.4.0": + version: 1.4.0 + resolution: "@discordjs/builders@npm:1.4.0" dependencies: - "@sapphire/shapeshift": ^3.5.1 - discord-api-types: ^0.36.2 + "@discordjs/util": ^0.1.0 + "@sapphire/shapeshift": ^3.7.1 + discord-api-types: ^0.37.20 fast-deep-equal: ^3.1.3 - ts-mixer: ^6.0.1 - tslib: ^2.4.0 - checksum: bf7ab00924bf84678c139b32c3b6bda16d62f190a1674ebaa4ec8767c7105890b1375716296037306661e138fe1c09c535b3141a047b7fceafaa92937a76cb8b - languageName: node - linkType: hard - -"@discordjs/collection@npm:^0.7.0": - version: 0.7.0 - resolution: "@discordjs/collection@npm:0.7.0" - checksum: 141aa35a5433bacba3617b533557b4948388c7b59cdaecee51ccd721c1b9242e50d95bdef53ee2491535a017095f5072ace3c3e9e594193f67a1c5a8a4b7db93 + ts-mixer: ^6.0.2 + tslib: ^2.4.1 + checksum: 3089ea5dc58e62c0314fd5fd995281d183d1a938d14a71b89c47b71b6cdf4cdf9f8c2ee1d04ca59e6bdde583b8bb785f3b53d917fb155cade8d27ac0dedbc942 languageName: node linkType: hard -"@discordjs/collection@npm:^1.2.0": +"@discordjs/collection@npm:^1.2.0, @discordjs/collection@npm:^1.3.0": version: 1.3.0 resolution: "@discordjs/collection@npm:1.3.0" checksum: 5ca6e9757f4c1e19564a0ac96ebfcabd1a83bf3ac0270034a0ea887f418f196caea4b54ebac5aaf0fc28d98f58f12794a6242d07acf08c946f23aa2e0047e87d languageName: node linkType: hard -"@esbuild/android-arm64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/android-arm64@npm:0.16.14" +"@discordjs/rest@npm:^1.4.0": + version: 1.5.0 + resolution: "@discordjs/rest@npm:1.5.0" + dependencies: + "@discordjs/collection": ^1.3.0 + "@discordjs/util": ^0.1.0 + "@sapphire/async-queue": ^1.5.0 + "@sapphire/snowflake": ^3.2.2 + discord-api-types: ^0.37.23 + file-type: ^18.0.0 + tslib: ^2.4.1 + undici: ^5.13.0 + checksum: 98b3a97fa3dbecd406cefca5e5245d51a1ab9eb748001f9d128065cc6dd6f61cc23efbdfa11e84e5147131fe40239d23c37b503d8c4c1a40b10d67b4c5b255ef + languageName: node + linkType: hard + +"@discordjs/util@npm:^0.1.0": + version: 0.1.0 + resolution: "@discordjs/util@npm:0.1.0" + checksum: 880e15cd761437a21cf17b8a9dab50e7e5418fcc77dc34037c31a52b871fab1b958218ab6218aafd20af8b7a4e658a705d3f257268324773a285d9a06368c1b9 + languageName: node + linkType: hard + +"@esbuild/android-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/android-arm64@npm:0.16.15" conditions: os=android & cpu=arm64 languageName: node linkType: hard @@ -285,65 +302,65 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-arm@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/android-arm@npm:0.16.14" +"@esbuild/android-arm@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/android-arm@npm:0.16.15" conditions: os=android & cpu=arm languageName: node linkType: hard -"@esbuild/android-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/android-x64@npm:0.16.14" +"@esbuild/android-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/android-x64@npm:0.16.15" conditions: os=android & cpu=x64 languageName: node linkType: hard -"@esbuild/darwin-arm64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/darwin-arm64@npm:0.16.14" +"@esbuild/darwin-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/darwin-arm64@npm:0.16.15" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@esbuild/darwin-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/darwin-x64@npm:0.16.14" +"@esbuild/darwin-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/darwin-x64@npm:0.16.15" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@esbuild/freebsd-arm64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/freebsd-arm64@npm:0.16.14" +"@esbuild/freebsd-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/freebsd-arm64@npm:0.16.15" conditions: os=freebsd & cpu=arm64 languageName: node linkType: hard -"@esbuild/freebsd-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/freebsd-x64@npm:0.16.14" +"@esbuild/freebsd-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/freebsd-x64@npm:0.16.15" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@esbuild/linux-arm64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-arm64@npm:0.16.14" +"@esbuild/linux-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-arm64@npm:0.16.15" conditions: os=linux & cpu=arm64 languageName: node linkType: hard -"@esbuild/linux-arm@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-arm@npm:0.16.14" +"@esbuild/linux-arm@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-arm@npm:0.16.15" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@esbuild/linux-ia32@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-ia32@npm:0.16.14" +"@esbuild/linux-ia32@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-ia32@npm:0.16.15" conditions: os=linux & cpu=ia32 languageName: node linkType: hard @@ -355,86 +372,86 @@ __metadata: languageName: node linkType: hard -"@esbuild/linux-loong64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-loong64@npm:0.16.14" +"@esbuild/linux-loong64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-loong64@npm:0.16.15" conditions: os=linux & cpu=loong64 languageName: node linkType: hard -"@esbuild/linux-mips64el@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-mips64el@npm:0.16.14" +"@esbuild/linux-mips64el@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-mips64el@npm:0.16.15" conditions: os=linux & cpu=mips64el languageName: node linkType: hard -"@esbuild/linux-ppc64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-ppc64@npm:0.16.14" +"@esbuild/linux-ppc64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-ppc64@npm:0.16.15" conditions: os=linux & cpu=ppc64 languageName: node linkType: hard -"@esbuild/linux-riscv64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-riscv64@npm:0.16.14" +"@esbuild/linux-riscv64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-riscv64@npm:0.16.15" conditions: os=linux & cpu=riscv64 languageName: node linkType: hard -"@esbuild/linux-s390x@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-s390x@npm:0.16.14" +"@esbuild/linux-s390x@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-s390x@npm:0.16.15" conditions: os=linux & cpu=s390x languageName: node linkType: hard -"@esbuild/linux-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/linux-x64@npm:0.16.14" +"@esbuild/linux-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-x64@npm:0.16.15" conditions: os=linux & cpu=x64 languageName: node linkType: hard -"@esbuild/netbsd-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/netbsd-x64@npm:0.16.14" +"@esbuild/netbsd-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/netbsd-x64@npm:0.16.15" conditions: os=netbsd & cpu=x64 languageName: node linkType: hard -"@esbuild/openbsd-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/openbsd-x64@npm:0.16.14" +"@esbuild/openbsd-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/openbsd-x64@npm:0.16.15" conditions: os=openbsd & cpu=x64 languageName: node linkType: hard -"@esbuild/sunos-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/sunos-x64@npm:0.16.14" +"@esbuild/sunos-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/sunos-x64@npm:0.16.15" conditions: os=sunos & cpu=x64 languageName: node linkType: hard -"@esbuild/win32-arm64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/win32-arm64@npm:0.16.14" +"@esbuild/win32-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/win32-arm64@npm:0.16.15" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@esbuild/win32-ia32@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/win32-ia32@npm:0.16.14" +"@esbuild/win32-ia32@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/win32-ia32@npm:0.16.15" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@esbuild/win32-x64@npm:0.16.14": - version: 0.16.14 - resolution: "@esbuild/win32-x64@npm:0.16.14" +"@esbuild/win32-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/win32-x64@npm:0.16.15" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -456,23 +473,23 @@ __metadata: languageName: node linkType: hard -"@favware/cliff-jumper@npm:^1.9.0": - version: 1.9.0 - resolution: "@favware/cliff-jumper@npm:1.9.0" +"@favware/cliff-jumper@npm:^1.10.0": + version: 1.10.0 + resolution: "@favware/cliff-jumper@npm:1.10.0" dependencies: + "@favware/conventional-changelog-angular": ^5.0.14 "@sapphire/result": ^2.6.0 "@sapphire/utilities": 3.11.0 colorette: ^2.0.19 - commander: ^9.4.1 - conventional-changelog-angular: ^5.0.13 + commander: ^9.5.0 conventional-recommended-bump: ^6.1.0 js-yaml: ^4.1.0 semver: ^7.3.8 - typescript: ^4.8.4 + typescript: ^4.9.4 bin: cj: ./dist/cli.js cliff-jumper: ./dist/cli.js - checksum: 4218704159a44b25fed0bbe71babc37d26b63231b72343f580fa22cd132e5d1dba6717bd6d53365b49b1e8acd8906f1d391d6b8cc0fe0b59541c43d3aa82765e + checksum: 27cf33b0e363dd5ba1f7087dea167114aa70e95e92592c4b0bc4225ad14c91be17eb9a177c9c2a57d8ffa30cab9df8eb4d09b2a39e139e3bcd25f055e9cc6f06 languageName: node linkType: hard @@ -485,6 +502,16 @@ __metadata: languageName: node linkType: hard +"@favware/conventional-changelog-angular@npm:^5.0.14": + version: 5.0.14 + resolution: "@favware/conventional-changelog-angular@npm:5.0.14" + dependencies: + compare-func: ^2.0.0 + q: ^1.5.1 + checksum: 32293091dff8a3dc3b3dadd2cb9697efdef51e05165d5c22255b72d6202c3ac156fcbf9526dc073001450343885b39f597ddb7304c9eb37ffc512445a9f10d99 + languageName: node + linkType: hard + "@favware/npm-deprecate@npm:^1.0.7": version: 1.0.7 resolution: "@favware/npm-deprecate@npm:1.0.7" @@ -568,7 +595,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/sourcemap-codec@npm:1.4.14, @jridgewell/sourcemap-codec@npm:^1.4.10": +"@jridgewell/sourcemap-codec@npm:1.4.14, @jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.13": version: 1.4.14 resolution: "@jridgewell/sourcemap-codec@npm:1.4.14" checksum: 61100637b6d173d3ba786a5dff019e1a74b1f394f323c1fee337ff390239f053b87266c7a948777f4b1ee68c01a8ad0ab61e5ff4abb5a012a0b091bec391ab97 @@ -658,24 +685,24 @@ __metadata: languageName: node linkType: hard -"@sapphire/discord-utilities@npm:^2.12.0": - version: 2.12.0 - resolution: "@sapphire/discord-utilities@npm:2.12.0" +"@sapphire/discord-utilities@npm:^3.0.0": + version: 3.0.0 + resolution: "@sapphire/discord-utilities@npm:3.0.0" dependencies: - discord-api-types: ^0.36.3 - checksum: a699d8cca46033a0eafa42dc44651f1e72ccb2a5eb8e94710dbe4b7f154aed0d7729c7eba515bcdfe1592a0b0c8181f2712a43939188a44603b940e877fa81a7 + discord-api-types: ^0.37.25 + checksum: c17ddb5c663fb474e134f881bfa9fb803bdb315220894079c92966b72208ae52f4a995faae2701519d99690f0ed591d7e9995e8c7ffc36821435fd454af5d4b1 languageName: node linkType: hard -"@sapphire/discord.js-utilities@npm:^5.1.2": - version: 5.1.2 - resolution: "@sapphire/discord.js-utilities@npm:5.1.2" +"@sapphire/discord.js-utilities@npm:6.0.0": + version: 6.0.0 + resolution: "@sapphire/discord.js-utilities@npm:6.0.0" dependencies: - "@sapphire/discord-utilities": ^2.12.0 + "@sapphire/discord-utilities": ^3.0.0 "@sapphire/duration": ^1.0.0 "@sapphire/utilities": ^3.11.0 tslib: ^2.4.1 - checksum: 60c02e2e62699df2c770ac6dae57222dc413b51784b463fffe4aa571493b63a1045c57d5d068cc3761f5cc20ff0b29d3611c34eba876a2092c926ba32973bea0 + checksum: 00752fe7c79666db905e3b1a8d0a20c968b62d1b5279081da2de530c8370b2d3124579cf0a186f5ac4145bb1d107e0bc75988d1f9d1700fe1f5622367c57c37d languageName: node linkType: hard @@ -716,12 +743,12 @@ __metadata: dependencies: "@commitlint/cli": ^17.4.0 "@commitlint/config-conventional": ^17.4.0 - "@discordjs/builders": ^0.16.0 - "@favware/cliff-jumper": ^1.9.0 + "@discordjs/builders": ^1.4.0 + "@favware/cliff-jumper": ^1.10.0 "@favware/npm-deprecate": ^1.0.7 "@favware/rollup-type-bundler": ^2.0.0 - "@sapphire/discord-utilities": ^2.12.0 - "@sapphire/discord.js-utilities": ^5.1.2 + "@sapphire/discord-utilities": ^3.0.0 + "@sapphire/discord.js-utilities": 6.0.0 "@sapphire/eslint-config": ^4.3.8 "@sapphire/lexure": ^1.1.2 "@sapphire/pieces": ^3.6.0 @@ -737,7 +764,7 @@ __metadata: "@typescript-eslint/parser": ^5.48.0 "@vitest/coverage-c8": ^0.26.3 cz-conventional-changelog: ^3.3.0 - discord.js: ^13.12.0 + discord.js: ^14.7.1 esbuild-plugin-file-path-extensions: ^1.0.0 esbuild-plugin-version-injector: ^1.0.2 eslint: ^8.31.0 @@ -810,7 +837,7 @@ __metadata: languageName: node linkType: hard -"@sapphire/shapeshift@npm:^3.5.1": +"@sapphire/shapeshift@npm:^3.7.1": version: 3.8.1 resolution: "@sapphire/shapeshift@npm:3.8.1" dependencies: @@ -820,6 +847,13 @@ __metadata: languageName: node linkType: hard +"@sapphire/snowflake@npm:^3.2.2": + version: 3.4.0 + resolution: "@sapphire/snowflake@npm:3.4.0" + checksum: 556b7001f33d6edbbbcbca46f6abfa56c732a29e78b693161e358688e688edcb012d2c1bc944e7ffb41bd6c9950d261bc73f95656dc01643361a218b4f5ab985 + languageName: node + linkType: hard + "@sapphire/stopwatch@npm:^1.5.0": version: 1.5.0 resolution: "@sapphire/stopwatch@npm:1.5.0" @@ -853,6 +887,13 @@ __metadata: languageName: node linkType: hard +"@tokenizer/token@npm:^0.3.0": + version: 0.3.0 + resolution: "@tokenizer/token@npm:0.3.0" + checksum: 1d575d02d2a9f0c5a4ca5180635ebd2ad59e0f18b42a65f3d04844148b49b3db35cf00b6012a1af2d59c2ab3caca59451c5689f747ba8667ee586ad717ee58e1 + languageName: node + linkType: hard + "@tootallnate/once@npm:2": version: 2.0.0 resolution: "@tootallnate/once@npm:2.0.0" @@ -932,16 +973,6 @@ __metadata: languageName: node linkType: hard -"@types/node-fetch@npm:^2.6.2": - version: 2.6.2 - resolution: "@types/node-fetch@npm:2.6.2" - dependencies: - "@types/node": "*" - form-data: ^3.0.0 - checksum: 6f73b1470000d303d25a6fb92875ea837a216656cb7474f66cdd67bb014aa81a5a11e7ac9c21fe19bee9ecb2ef87c1962bceeaec31386119d1ac86e4c30ad7a6 - languageName: node - linkType: hard - "@types/node@npm:*, @types/node@npm:^18.11.18": version: 18.11.18 resolution: "@types/node@npm:18.11.18" @@ -1348,13 +1379,6 @@ __metadata: languageName: node linkType: hard -"asynckit@npm:^0.4.0": - version: 0.4.0 - resolution: "asynckit@npm:0.4.0" - checksum: 7b78c451df768adba04e2d02e63e2d0bf3b07adcd6e42b4cf665cb7ce899bedd344c69a1dcbce355b5f972d597b25aaa1c1742b52cffd9caccb22f348114f6be - languageName: node - linkType: hard - "at-least-node@npm:^1.0.0": version: 1.0.0 resolution: "at-least-node@npm:1.0.0" @@ -1459,6 +1483,15 @@ __metadata: languageName: node linkType: hard +"busboy@npm:^1.6.0": + version: 1.6.0 + resolution: "busboy@npm:1.6.0" + dependencies: + streamsearch: ^1.1.0 + checksum: 32801e2c0164e12106bf236291a00795c3c4e4b709ae02132883fe8478ba2ae23743b11c5735a0aae8afe65ac4b6ca4568b91f0d9fed1fdbc32ede824a73746e + languageName: node + linkType: hard + "c8@npm:^7.12.0": version: 7.12.0 resolution: "c8@npm:7.12.0" @@ -1780,15 +1813,6 @@ __metadata: languageName: node linkType: hard -"combined-stream@npm:^1.0.8": - version: 1.0.8 - resolution: "combined-stream@npm:1.0.8" - dependencies: - delayed-stream: ~1.0.0 - checksum: 49fa4aeb4916567e33ea81d088f6584749fc90c7abec76fd516bf1c5aa5c79f3584b5ba3de6b86d26ddd64bae5329c4c7479343250cfe71c75bb366eae53bb7c - languageName: node - linkType: hard - "commander@npm:^4.0.0": version: 4.1.1 resolution: "commander@npm:4.1.1" @@ -1796,10 +1820,10 @@ __metadata: languageName: node linkType: hard -"commander@npm:^9.4.1": - version: 9.4.1 - resolution: "commander@npm:9.4.1" - checksum: bfb18e325a5bdf772763c2213d5c7d9e77144d944124e988bcd8e5e65fb6d45d5d4e86b09155d0f2556c9a59c31e428720e57968bcd050b2306e910a0bf3cf13 +"commander@npm:^9.4.1, commander@npm:^9.5.0": + version: 9.5.0 + resolution: "commander@npm:9.5.0" + checksum: c7a3e27aa59e913b54a1bafd366b88650bc41d6651f0cbe258d4ff09d43d6a7394232a4dadd0bf518b3e696fdf595db1028a0d82c785b88bd61f8a440cecfade languageName: node linkType: hard @@ -1865,7 +1889,7 @@ __metadata: languageName: node linkType: hard -"conventional-changelog-angular@npm:^5.0.11, conventional-changelog-angular@npm:^5.0.13": +"conventional-changelog-angular@npm:^5.0.11": version: 5.0.13 resolution: "conventional-changelog-angular@npm:5.0.13" dependencies: @@ -2088,13 +2112,6 @@ __metadata: languageName: node linkType: hard -"delayed-stream@npm:~1.0.0": - version: 1.0.0 - resolution: "delayed-stream@npm:1.0.0" - checksum: 46fe6e83e2cb1d85ba50bd52803c68be9bd953282fa7096f51fc29edd5d67ff84ff753c51966061e5ba7cb5e47ef6d36a91924eddb7f3f3483b1c560f77a0020 - languageName: node - linkType: hard - "delegates@npm:^1.0.0": version: 1.0.0 resolution: "delegates@npm:1.0.0" @@ -2139,34 +2156,30 @@ __metadata: languageName: node linkType: hard -"discord-api-types@npm:^0.33.5": - version: 0.33.5 - resolution: "discord-api-types@npm:0.33.5" - checksum: 6dcaad640c5693a69c9a4f5e444e739dde11ba835164ae6fd3dd5a1ab7b4d7f96cd022ed653eeaff2c8051ead0d998a5d502a2915cfacdde596364b82d9e3b3f - languageName: node - linkType: hard - -"discord-api-types@npm:^0.36.2, discord-api-types@npm:^0.36.3": - version: 0.36.3 - resolution: "discord-api-types@npm:0.36.3" - checksum: 3089c0fb37425dc5df03c76d82988d43fcc272699b06a02fc830d0a3bef550009aaebdf6d646529e8a7ccea76ae3f43b099d736ea5ef37a0be143142ab49871d +"discord-api-types@npm:^0.37.20, discord-api-types@npm:^0.37.23, discord-api-types@npm:^0.37.25": + version: 0.37.26 + resolution: "discord-api-types@npm:0.37.26" + checksum: 66a1e43568af6d928aab253c81a192985c9025de72100881b8b206f1b8a746ef211670e1e88d152f59d7a186176a6afc3f81629ba7ccb91dab264b027f187004 languageName: node linkType: hard -"discord.js@npm:^13.12.0": - version: 13.12.0 - resolution: "discord.js@npm:13.12.0" +"discord.js@npm:^14.7.1": + version: 14.7.1 + resolution: "discord.js@npm:14.7.1" dependencies: - "@discordjs/builders": ^0.16.0 - "@discordjs/collection": ^0.7.0 - "@sapphire/async-queue": ^1.5.0 - "@types/node-fetch": ^2.6.2 + "@discordjs/builders": ^1.4.0 + "@discordjs/collection": ^1.3.0 + "@discordjs/rest": ^1.4.0 + "@discordjs/util": ^0.1.0 + "@sapphire/snowflake": ^3.2.2 "@types/ws": ^8.5.3 - discord-api-types: ^0.33.5 - form-data: ^4.0.0 - node-fetch: ^2.6.7 - ws: ^8.9.0 - checksum: e7121efac94cf8dba04999f1050cc369e03651afe7c2d440edab415cfac5b6072cca908e7c1310f0027805deaa955922c4bc0d531ff48d84202c643a0bd5141e + discord-api-types: ^0.37.20 + fast-deep-equal: ^3.1.3 + lodash.snakecase: ^4.1.1 + tslib: ^2.4.1 + undici: ^5.13.0 + ws: ^8.11.0 + checksum: fa861275b1f5360ef1b06cd514014ebd4e3f384655834dd1f73fd9f715bee643500f9d837c52f496d306825bc9c3d6c94e67463d91326e3750a28db765926ad6 languageName: node linkType: hard @@ -2484,31 +2497,31 @@ __metadata: linkType: hard "esbuild@npm:^0.16.3": - version: 0.16.14 - resolution: "esbuild@npm:0.16.14" - dependencies: - "@esbuild/android-arm": 0.16.14 - "@esbuild/android-arm64": 0.16.14 - "@esbuild/android-x64": 0.16.14 - "@esbuild/darwin-arm64": 0.16.14 - "@esbuild/darwin-x64": 0.16.14 - "@esbuild/freebsd-arm64": 0.16.14 - "@esbuild/freebsd-x64": 0.16.14 - "@esbuild/linux-arm": 0.16.14 - "@esbuild/linux-arm64": 0.16.14 - "@esbuild/linux-ia32": 0.16.14 - "@esbuild/linux-loong64": 0.16.14 - "@esbuild/linux-mips64el": 0.16.14 - "@esbuild/linux-ppc64": 0.16.14 - "@esbuild/linux-riscv64": 0.16.14 - "@esbuild/linux-s390x": 0.16.14 - "@esbuild/linux-x64": 0.16.14 - "@esbuild/netbsd-x64": 0.16.14 - "@esbuild/openbsd-x64": 0.16.14 - "@esbuild/sunos-x64": 0.16.14 - "@esbuild/win32-arm64": 0.16.14 - "@esbuild/win32-ia32": 0.16.14 - "@esbuild/win32-x64": 0.16.14 + version: 0.16.15 + resolution: "esbuild@npm:0.16.15" + dependencies: + "@esbuild/android-arm": 0.16.15 + "@esbuild/android-arm64": 0.16.15 + "@esbuild/android-x64": 0.16.15 + "@esbuild/darwin-arm64": 0.16.15 + "@esbuild/darwin-x64": 0.16.15 + "@esbuild/freebsd-arm64": 0.16.15 + "@esbuild/freebsd-x64": 0.16.15 + "@esbuild/linux-arm": 0.16.15 + "@esbuild/linux-arm64": 0.16.15 + "@esbuild/linux-ia32": 0.16.15 + "@esbuild/linux-loong64": 0.16.15 + "@esbuild/linux-mips64el": 0.16.15 + "@esbuild/linux-ppc64": 0.16.15 + "@esbuild/linux-riscv64": 0.16.15 + "@esbuild/linux-s390x": 0.16.15 + "@esbuild/linux-x64": 0.16.15 + "@esbuild/netbsd-x64": 0.16.15 + "@esbuild/openbsd-x64": 0.16.15 + "@esbuild/sunos-x64": 0.16.15 + "@esbuild/win32-arm64": 0.16.15 + "@esbuild/win32-ia32": 0.16.15 + "@esbuild/win32-x64": 0.16.15 dependenciesMeta: "@esbuild/android-arm": optional: true @@ -2556,7 +2569,7 @@ __metadata: optional: true bin: esbuild: bin/esbuild - checksum: befe262cce76f30518834a385922984a363c9223e8c4c03afc9b54fa43376cc47cadf526a335e97794c824bff395f303f1d51334dbea5e1923a361ee39267cf3 + checksum: 38a2784bced605b81352f05b151928c27ac7ed9ecd3f265339ef937b3f9571443bb233edb97f2de24bbdb0e6097ec68ffa096b0475f716a3d8bb3034e20066bf languageName: node linkType: hard @@ -2890,6 +2903,17 @@ __metadata: languageName: node linkType: hard +"file-type@npm:^18.0.0": + version: 18.0.0 + resolution: "file-type@npm:18.0.0" + dependencies: + readable-web-to-node-stream: ^3.0.2 + strtok3: ^7.0.0 + token-types: ^5.0.1 + checksum: 67f5a927b8030e35a4faf9dd9dea9e17bcb042fb61b9851b7dd1b1b3bb3ecfdd9f83bc3bc72686316ea2bac70df652c61e10affa9b5957b1a3d731df4925e3cb + languageName: node + linkType: hard + "fill-range@npm:^7.0.1": version: 7.0.1 resolution: "fill-range@npm:7.0.1" @@ -2975,28 +2999,6 @@ __metadata: languageName: node linkType: hard -"form-data@npm:^3.0.0": - version: 3.0.1 - resolution: "form-data@npm:3.0.1" - dependencies: - asynckit: ^0.4.0 - combined-stream: ^1.0.8 - mime-types: ^2.1.12 - checksum: b019e8d35c8afc14a2bd8a7a92fa4f525a4726b6d5a9740e8d2623c30e308fbb58dc8469f90415a856698933c8479b01646a9dff33c87cc4e76d72aedbbf860d - languageName: node - linkType: hard - -"form-data@npm:^4.0.0": - version: 4.0.0 - resolution: "form-data@npm:4.0.0" - dependencies: - asynckit: ^0.4.0 - combined-stream: ^1.0.8 - mime-types: ^2.1.12 - checksum: 01135bf8675f9d5c61ff18e2e2932f719ca4de964e3be90ef4c36aacfc7b9cb2fceb5eca0b7e0190e3383fe51c5b37f4cb80b62ca06a99aaabfcfd6ac7c9328c - languageName: node - linkType: hard - "fs-extra@npm:9.1.0": version: 9.1.0 resolution: "fs-extra@npm:9.1.0" @@ -3447,7 +3449,7 @@ __metadata: languageName: node linkType: hard -"ieee754@npm:^1.1.13": +"ieee754@npm:^1.1.13, ieee754@npm:^1.2.1": version: 1.2.1 resolution: "ieee754@npm:1.2.1" checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e @@ -3798,7 +3800,7 @@ __metadata: languageName: node linkType: hard -"jsonc-parser@npm:^3.0.0, jsonc-parser@npm:^3.2.0": +"jsonc-parser@npm:^3.2.0": version: 3.2.0 resolution: "jsonc-parser@npm:3.2.0" checksum: 946dd9a5f326b745aa326d48a7257e3f4a4b62c5e98ec8e49fa2bdd8d96cef7e6febf1399f5c7016114fd1f68a1c62c6138826d5d90bc650448e3cf0951c53c7 @@ -4091,12 +4093,12 @@ __metadata: languageName: node linkType: hard -"magic-string@npm:^0.26.7": - version: 0.26.7 - resolution: "magic-string@npm:0.26.7" +"magic-string@npm:^0.27.0": + version: 0.27.0 + resolution: "magic-string@npm:0.27.0" dependencies: - sourcemap-codec: ^1.4.8 - checksum: 89b0d60cbb32bbf3d1e23c46ea93db082d18a8230b972027aecb10a40bba51be519ecce0674f995571e3affe917b76b09f59d8dbc9a1b2c9c4102a2b6e8a2b01 + "@jridgewell/sourcemap-codec": ^1.4.13 + checksum: 273faaa50baadb7a2df6e442eac34ad611304fc08fe16e24fe2e472fd944bfcb73ffb50d2dc972dc04e92784222002af46868cb9698b1be181c81830fd95a13e languageName: node linkType: hard @@ -4178,7 +4180,7 @@ __metadata: languageName: node linkType: hard -"marked@npm:^4.2.4, marked@npm:^4.2.5": +"marked@npm:^4.2.5": version: 4.2.5 resolution: "marked@npm:4.2.5" bin: @@ -4237,22 +4239,6 @@ __metadata: languageName: node linkType: hard -"mime-db@npm:1.52.0": - version: 1.52.0 - resolution: "mime-db@npm:1.52.0" - checksum: 0d99a03585f8b39d68182803b12ac601d9c01abfa28ec56204fa330bc9f3d1c5e14beb049bafadb3dbdf646dfb94b87e24d4ec7b31b7279ef906a8ea9b6a513f - languageName: node - linkType: hard - -"mime-types@npm:^2.1.12": - version: 2.1.35 - resolution: "mime-types@npm:2.1.35" - dependencies: - mime-db: 1.52.0 - checksum: 89a5b7f1def9f3af5dad6496c5ed50191ae4331cc5389d7c521c8ad28d5fdad2d06fd81baf38fed813dc4e46bb55c8145bb0ff406330818c9cf712fb2e9b3836 - languageName: node - linkType: hard - "mimic-fn@npm:^2.1.0": version: 2.1.0 resolution: "mimic-fn@npm:2.1.0" @@ -4283,7 +4269,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^5.0.1, minimatch@npm:^5.1.1, minimatch@npm:^5.1.2": +"minimatch@npm:^5.0.1, minimatch@npm:^5.1.2": version: 5.1.2 resolution: "minimatch@npm:5.1.2" dependencies: @@ -4524,7 +4510,7 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:2.6.7, node-fetch@npm:^2.6.7": +"node-fetch@npm:2.6.7": version: 2.6.7 resolution: "node-fetch@npm:2.6.7" dependencies: @@ -4879,6 +4865,13 @@ __metadata: languageName: node linkType: hard +"peek-readable@npm:^5.0.0": + version: 5.0.0 + resolution: "peek-readable@npm:5.0.0" + checksum: bef5ceb50586eb42e14efba274ac57ffe97f0ed272df9239ce029f688f495d9bf74b2886fa27847c706a9db33acda4b7d23bbd09a2d21eb4c2a54da915117414 + languageName: node + linkType: hard + "picocolors@npm:^1.0.0": version: 1.0.0 resolution: "picocolors@npm:1.0.0" @@ -4948,13 +4941,13 @@ __metadata: linkType: hard "postcss@npm:^8.4.20": - version: 8.4.20 - resolution: "postcss@npm:8.4.20" + version: 8.4.21 + resolution: "postcss@npm:8.4.21" dependencies: nanoid: ^3.3.4 picocolors: ^1.0.0 source-map-js: ^1.0.2 - checksum: 1a5609ea1c1b204f9c2974a0019ae9eef2d99bf645c2c9aac675166c4cb1005be7b5e2ba196160bc771f5d9ac896ed883f236f888c891e835e59d28fff6651aa + checksum: e39ac60ccd1542d4f9d93d894048aac0d686b3bb38e927d8386005718e6793dbbb46930f0a523fe382f1bbd843c6d980aaea791252bf5e176180e5a4336d9679 languageName: node linkType: hard @@ -4974,16 +4967,7 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^2.7.1": - version: 2.8.1 - resolution: "prettier@npm:2.8.1" - bin: - prettier: bin-prettier.js - checksum: 4f21a0f1269f76fb36f54e9a8a1ea4c11e27478958bf860661fb4b6d7ac69aac1581f8724fa98ea3585e56d42a2ea317a17ff6e3324f40cb11ff9e20b73785cc - languageName: node - linkType: hard - -"prettier@npm:^2.8.2": +"prettier@npm:^2.7.1, prettier@npm:^2.8.2": version: 2.8.2 resolution: "prettier@npm:2.8.2" bin: @@ -5106,6 +5090,15 @@ __metadata: languageName: node linkType: hard +"readable-web-to-node-stream@npm:^3.0.2": + version: 3.0.2 + resolution: "readable-web-to-node-stream@npm:3.0.2" + dependencies: + readable-stream: ^3.6.0 + checksum: 8c56cc62c68513425ddfa721954875b382768f83fa20e6b31e365ee00cbe7a3d6296f66f7f1107b16cd3416d33aa9f1680475376400d62a081a88f81f0ea7f9c + languageName: node + linkType: hard + "readdirp@npm:~3.6.0": version: 3.6.0 resolution: "readdirp@npm:3.6.0" @@ -5248,18 +5241,18 @@ __metadata: linkType: hard "rollup-plugin-dts@npm:^5.0.0": - version: 5.1.0 - resolution: "rollup-plugin-dts@npm:5.1.0" + version: 5.1.1 + resolution: "rollup-plugin-dts@npm:5.1.1" dependencies: "@babel/code-frame": ^7.18.6 - magic-string: ^0.26.7 + magic-string: ^0.27.0 peerDependencies: rollup: ^3.0.0 typescript: ^4.1 dependenciesMeta: "@babel/code-frame": optional: true - checksum: 74bcee3076f2689272f240227e6c08a7486bc1f4451a2495ea3c1408ac96cbc034bdc88f584a926d8593e06d2a28e5167b2cbc3a85310e1c94fd35ddbc935be0 + checksum: 12de87d537cf10f1808d6e6304c5f0b17620456b1ef0f4dfb80d2aa82d4fa5a40ebcf1c99bca840578dd53315696efcf0825b731707102540013edadcdd529f3 languageName: node linkType: hard @@ -5368,17 +5361,6 @@ __metadata: languageName: node linkType: hard -"shiki@npm:^0.11.1": - version: 0.11.1 - resolution: "shiki@npm:0.11.1" - dependencies: - jsonc-parser: ^3.0.0 - vscode-oniguruma: ^1.6.1 - vscode-textmate: ^6.0.0 - checksum: 2a4ebc3b466816263fc244ae4f67a4ff96aa74d863b9c5e7e4affc50f37fd6d1a781405de0dbf763b777bc33e49a0d441de7ff3fededb8b01e3b8dbb37e2927d - languageName: node - linkType: hard - "shiki@npm:^0.12.1": version: 0.12.1 resolution: "shiki@npm:0.12.1" @@ -5497,13 +5479,6 @@ __metadata: languageName: node linkType: hard -"sourcemap-codec@npm:^1.4.8": - version: 1.4.8 - resolution: "sourcemap-codec@npm:1.4.8" - checksum: b57981c05611afef31605732b598ccf65124a9fcb03b833532659ac4d29ac0f7bfacbc0d6c5a28a03e84c7510e7e556d758d0bb57786e214660016fb94279316 - languageName: node - linkType: hard - "spdx-correct@npm:^3.0.0": version: 3.1.1 resolution: "spdx-correct@npm:3.1.1" @@ -5565,6 +5540,13 @@ __metadata: languageName: node linkType: hard +"streamsearch@npm:^1.1.0": + version: 1.1.0 + resolution: "streamsearch@npm:1.1.0" + checksum: 1cce16cea8405d7a233d32ca5e00a00169cc0e19fbc02aa839959985f267335d435c07f96e5e0edd0eadc6d39c98d5435fb5bbbdefc62c41834eadc5622ad942 + languageName: node + linkType: hard + "string-argv@npm:^0.3.1": version: 0.3.1 resolution: "string-argv@npm:0.3.1" @@ -5667,6 +5649,16 @@ __metadata: languageName: node linkType: hard +"strtok3@npm:^7.0.0": + version: 7.0.0 + resolution: "strtok3@npm:7.0.0" + dependencies: + "@tokenizer/token": ^0.3.0 + peek-readable: ^5.0.0 + checksum: 2ebe7ad8f2aea611dec6742cf6a42e82764892a362907f7ce493faf334501bf981ce21c828dcc300457e6d460dc9c34d644ededb3b01dcb9e37559203cf1748c + languageName: node + linkType: hard + "sucrase@npm:^3.20.3": version: 3.29.0 resolution: "sucrase@npm:3.29.0" @@ -5821,6 +5813,16 @@ __metadata: languageName: node linkType: hard +"token-types@npm:^5.0.1": + version: 5.0.1 + resolution: "token-types@npm:5.0.1" + dependencies: + "@tokenizer/token": ^0.3.0 + ieee754: ^1.2.1 + checksum: 32780123bc6ce8b6a2231d860445c994a02a720abf38df5583ea957aa6626873cd1c4dd8af62314da4cf16ede00c379a765707a3b06f04b8808c38efdae1c785 + languageName: node + linkType: hard + "tr46@npm:^1.0.1": version: 1.0.1 resolution: "tr46@npm:1.0.1" @@ -5860,7 +5862,7 @@ __metadata: languageName: node linkType: hard -"ts-mixer@npm:^6.0.1": +"ts-mixer@npm:^6.0.2": version: 6.0.2 resolution: "ts-mixer@npm:6.0.2" checksum: cbe9935886fab201f2265ebde8e7e4147a3147ba6b6b4701ed5b92fd52729cda340f45f80f486131d203ed25c8c896a2a3623b2c33cd14314bd7ba961e97ee2e @@ -6041,23 +6043,7 @@ __metadata: languageName: node linkType: hard -"typedoc@npm:^0.23.23": - version: 0.23.23 - resolution: "typedoc@npm:0.23.23" - dependencies: - lunr: ^2.3.9 - marked: ^4.2.4 - minimatch: ^5.1.1 - shiki: ^0.11.1 - peerDependencies: - typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x - bin: - typedoc: bin/typedoc - checksum: 2b64f9c9dc1992ec1bbcc688f6cfc8161481872c485ba9226d1797f572469d02f7798ebe96e3626587a6952af685fa1f4aaa0d9a6137fe9fb3d37f677cb41161 - languageName: node - linkType: hard - -"typedoc@npm:^0.23.24": +"typedoc@npm:^0.23.23, typedoc@npm:^0.23.24": version: 0.23.24 resolution: "typedoc@npm:0.23.24" dependencies: @@ -6100,6 +6086,15 @@ __metadata: languageName: node linkType: hard +"undici@npm:^5.13.0": + version: 5.14.0 + resolution: "undici@npm:5.14.0" + dependencies: + busboy: ^1.6.0 + checksum: 7a076e44d84b25844b4eb657034437b8b9bb91f17d347de474fdea1d4263ce7ae9406db79cd30de5642519277b4893f43073258bcc8fed420b295da3fdd11b26 + languageName: node + linkType: hard + "unique-filename@npm:^2.0.0": version: 2.0.1 resolution: "unique-filename@npm:2.0.1" @@ -6301,20 +6296,13 @@ __metadata: languageName: node linkType: hard -"vscode-oniguruma@npm:^1.6.1, vscode-oniguruma@npm:^1.7.0": +"vscode-oniguruma@npm:^1.7.0": version: 1.7.0 resolution: "vscode-oniguruma@npm:1.7.0" checksum: 53519d91d90593e6fb080260892e87d447e9b200c4964d766772b5053f5699066539d92100f77f1302c91e8fc5d9c772fbe40fe4c90f3d411a96d5a9b1e63f42 languageName: node linkType: hard -"vscode-textmate@npm:^6.0.0": - version: 6.0.0 - resolution: "vscode-textmate@npm:6.0.0" - checksum: ff6f17a406c2906586afc14ef01cb122e33acd35312e815abb5c924347a777c6783ce3fe7db8b83f1760ebf843c669843b9390f905b69c433b3395af28e4b483 - languageName: node - linkType: hard - "vscode-textmate@npm:^8.0.0": version: 8.0.0 resolution: "vscode-textmate@npm:8.0.0" @@ -6433,18 +6421,18 @@ __metadata: languageName: node linkType: hard -"ws@npm:^8.9.0": - version: 8.11.0 - resolution: "ws@npm:8.11.0" +"ws@npm:^8.11.0": + version: 8.12.0 + resolution: "ws@npm:8.12.0" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 + utf-8-validate: ">=5.0.2" peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 316b33aba32f317cd217df66dbfc5b281a2f09ff36815de222bc859e3424d83766d9eb2bd4d667de658b6ab7be151f258318fb1da812416b30be13103e5b5c67 + checksum: 818ff3f8749c172a95a114cceb8b89cedd27e43a82d65c7ad0f7882b1e96a2ee6709e3746a903c3fa88beec0c8bae9a9fcd75f20858b32a166dfb7519316a5d7 languageName: node linkType: hard