@notenoughupdates/discord-akairo
Advanced tools
Comparing version 9.0.10-dev.1642805126.3369dbe to 9.0.10-dev.1642853858.d99b3b4
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1642805126.3369dbe", | ||
"version": "9.0.10-dev.1642853858.d99b3b4", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -10,3 +10,3 @@ import "source-map-support/register"; | ||
import Command, { AkairoApplicationCommandAutocompleteOption, AkairoApplicationCommandChannelOptionData, AkairoApplicationCommandChoicesData, AkairoApplicationCommandNonOptionsData, AkairoApplicationCommandNumericOptionData, AkairoApplicationCommandOptionData, AkairoApplicationCommandSubCommandData, AkairoApplicationCommandSubGroupData, ArgumentGenerator, BeforeAction, CommandOptions, ExecutionPredicate, KeySupplier, MissingPermissionSupplier, RegexSupplier, SlashOption, SlashPermissionsSupplier } from "./struct/commands/Command"; | ||
import CommandHandler, { CommandHandlerOptions, CooldownData, IgnoreCheckPredicate, InteractionArgs, MentionPrefixPredicate, ParsedComponentData, PrefixSupplier, RegisterInteractionCommandError, SlashResolveTypes } from "./struct/commands/CommandHandler"; | ||
import CommandHandler, { CommandHandlerOptions, CooldownData, IgnoreCheckPredicate, MentionPrefixPredicate, ParsedComponentData, PrefixSupplier, RegisterInteractionCommandError, SlashResolveTypes } from "./struct/commands/CommandHandler"; | ||
import CommandUtil from "./struct/commands/CommandUtil"; | ||
@@ -42,3 +42,3 @@ import ContentParser, { ContentParserOptions, ContentParserResult, ExtractedFlags, StringData } from "./struct/commands/ContentParser"; | ||
export { AkairoClient, AkairoError, AkairoHandler, AkairoMessage, AkairoModule, Argument, ArgumentRunner, ArgumentRunnerState, Category, ClientUtil, Command, CommandHandler, CommandUtil, Constants, ContentParser, ContentParserResult, ContextMenuCommand, ContextMenuCommandHandler, Flag, Inhibitor, InhibitorHandler, Listener, ListenerHandler, PromptContentModifier, RegisterInteractionCommandError, Task, TaskHandler, TypeResolver, Util, version }; | ||
export type { AkairoApplicationCommandAutocompleteOption, AkairoApplicationCommandChannelOptionData, AkairoApplicationCommandChoicesData, AkairoApplicationCommandNonOptionsData, AkairoApplicationCommandNumericOptionData, AkairoApplicationCommandOptionData, AkairoApplicationCommandSubCommandData, AkairoApplicationCommandSubGroupData, AkairoClientEvents, AkairoHandlerEvents, AkairoHandlerOptions, AkairoModuleOptions, AkairoOptions, ArgumentGenerator, ArgumentMatch, ArgumentOptions, ArgumentPromptData, ArgumentPromptOptions, ArgumentType, ArgumentTypeCaster, BaseArgumentType, BeforeAction, CommandHandlerEvents, CommandHandlerOptions, CommandOptions, ContentParserOptions, ContextMenuCommandHandlerEvents, ContextMenuCommandOptions, CooldownData, DefaultArgumentOptions, DefaultValueSupplier, ExecutionPredicate, ExtractedFlags, FailureData, IgnoreCheckPredicate, InhibitorHandlerEvents, InhibitorOptions, InteractionArgs, KeySupplier, ListenerHandlerEvents, ListenerOptions, ListenerType, LoadPredicate, MentionPrefixPredicate, MissingPermissionSupplier, OtherwiseContentModifier, OtherwiseContentSupplier, ParsedComponentData, ParsedValuePredicate, PrefixSupplier, PromptContentSupplier, RegexSupplier, SlashOption, SlashPermissionsSupplier, SlashResolveTypes, StringData, TaskHandlerEvents, TaskOptions }; | ||
export type { AkairoApplicationCommandAutocompleteOption, AkairoApplicationCommandChannelOptionData, AkairoApplicationCommandChoicesData, AkairoApplicationCommandNonOptionsData, AkairoApplicationCommandNumericOptionData, AkairoApplicationCommandOptionData, AkairoApplicationCommandSubCommandData, AkairoApplicationCommandSubGroupData, AkairoClientEvents, AkairoHandlerEvents, AkairoHandlerOptions, AkairoModuleOptions, AkairoOptions, ArgumentGenerator, ArgumentMatch, ArgumentOptions, ArgumentPromptData, ArgumentPromptOptions, ArgumentType, ArgumentTypeCaster, BaseArgumentType, BeforeAction, CommandHandlerEvents, CommandHandlerOptions, CommandOptions, ContentParserOptions, ContextMenuCommandHandlerEvents, ContextMenuCommandOptions, CooldownData, DefaultArgumentOptions, DefaultValueSupplier, ExecutionPredicate, ExtractedFlags, FailureData, IgnoreCheckPredicate, InhibitorHandlerEvents, InhibitorOptions, KeySupplier, ListenerHandlerEvents, ListenerOptions, ListenerType, LoadPredicate, MentionPrefixPredicate, MissingPermissionSupplier, OtherwiseContentModifier, OtherwiseContentSupplier, ParsedComponentData, ParsedValuePredicate, PrefixSupplier, PromptContentSupplier, RegexSupplier, SlashOption, SlashPermissionsSupplier, SlashResolveTypes, StringData, TaskHandlerEvents, TaskOptions }; | ||
//# sourceMappingURL=index.d.ts.map |
/// <reference types="node" /> | ||
import { ApplicationCommandOptionData, AutocompleteInteraction, Awaitable, ChatInputCommandInteraction, Collection, DiscordAPIError, Guild, Message, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import { ApplicationCommandData, AutocompleteInteraction, Awaitable, ChatInputCommandInteraction, Collection, DiscordAPIError, Guild, Message, Snowflake, TextBasedChannel, User } from "discord.js"; | ||
import type { CommandHandlerEvents as CommandHandlerEventsType } from "../../typings/events"; | ||
@@ -377,15 +377,8 @@ import AkairoMessage from "../../util/AkairoMessage.js"; | ||
} | ||
export declare type InteractionArgs = { | ||
name: string; | ||
description: string; | ||
options: ApplicationCommandOptionData[]; | ||
defaultPermission: boolean; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[]; | ||
export declare class RegisterInteractionCommandError extends Error { | ||
original: DiscordAPIError; | ||
type: "guild" | "global"; | ||
data: InteractionArgs; | ||
data: ApplicationCommandData[]; | ||
guild: Guild | null; | ||
constructor(original: DiscordAPIError, type: "guild" | "global", data: InteractionArgs, guild?: Guild | null); | ||
constructor(original: DiscordAPIError, type: "guild" | "global", data: ApplicationCommandData[], guild?: Guild | null); | ||
} | ||
@@ -392,0 +385,0 @@ export interface CommandHandlerOptions extends AkairoHandlerOptions { |
@@ -153,4 +153,3 @@ "use strict"; | ||
options: data.slashOptions?.map(o => { | ||
// this may not be necessary but im not sure | ||
const temp = Object.assign({}, o); | ||
const temp = { ...o }; | ||
delete temp.resolve; | ||
@@ -161,3 +160,3 @@ return temp; | ||
defaultPermission: data.slashDefaultPermission, | ||
type: "ChatInput" | ||
type: 1 /* ChatInput */ | ||
}); | ||
@@ -185,8 +184,8 @@ } | ||
.filter(({ guilds }) => !guilds.length) | ||
.map(({ name, description, options, defaultPermission, type }) => ({ | ||
name, | ||
description: description ?? "", | ||
options: options ?? [], | ||
defaultPermission, | ||
type | ||
.map(options => ({ | ||
name: options.name, | ||
description: options.type === 1 /* ChatInput */ ? options.description ?? "" : undefined, | ||
options: options.type === 1 /* ChatInput */ ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
type: options.type | ||
})) | ||
@@ -228,7 +227,13 @@ .sort((a, b) => { | ||
/* Guilds */ | ||
for (const { name, description, options, guilds, defaultPermission, type } of parsedSlashCommands) { | ||
for (const guildId of guilds) { | ||
for (const options of parsedSlashCommands) { | ||
for (const guildId of options.guilds) { | ||
guildSlashCommandsParsed.set(guildId, [ | ||
...(guildSlashCommandsParsed.get(guildId) ?? []), | ||
{ name, description: description, options: options, defaultPermission, type } | ||
{ | ||
name: options.name, | ||
description: options.type === 1 /* ChatInput */ ? options.description ?? "" : undefined, | ||
options: options.type === 1 /* ChatInput */ ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
type: options.type | ||
} | ||
]); | ||
@@ -235,0 +240,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type { ContextMenuCommandInteraction, Snowflake } from "discord.js"; | ||
import type { ApplicationCommandType, ContextMenuCommandInteraction, Snowflake } from "discord.js"; | ||
import type Category from "../../util/Category.js"; | ||
@@ -29,3 +29,3 @@ import type AkairoClient from "../AkairoClient.js"; | ||
*/ | ||
type: "User" | "Message"; | ||
type: ApplicationCommandType.User | ApplicationCommandType.Message; | ||
/** | ||
@@ -91,4 +91,4 @@ * The category of this context menu command. | ||
*/ | ||
type: "User" | "Message"; | ||
type: ApplicationCommandType.User | ApplicationCommandType.Message; | ||
} | ||
//# sourceMappingURL=ContextMenuCommand.d.ts.map |
{ | ||
"name": "@notenoughupdates/discord-akairo", | ||
"version": "9.0.10-dev.1642805126.3369dbe", | ||
"version": "9.0.10-dev.1642853858.d99b3b4", | ||
"description": "A highly customizable bot framework for Discord.js.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -49,3 +49,2 @@ import "source-map-support/register"; | ||
IgnoreCheckPredicate, | ||
InteractionArgs, | ||
MentionPrefixPredicate, | ||
@@ -173,3 +172,2 @@ ParsedComponentData, | ||
InhibitorOptions, | ||
InteractionArgs, | ||
KeySupplier, | ||
@@ -176,0 +174,0 @@ ListenerHandlerEvents, |
import { | ||
ApplicationCommand, | ||
ApplicationCommandData, | ||
ApplicationCommandOptionData, | ||
ApplicationCommandOptionType, | ||
ApplicationCommandPermissionType, | ||
ApplicationCommandType, | ||
AutocompleteInteraction, | ||
@@ -365,20 +367,4 @@ Awaitable, | ||
this.client.emit("akairoDebug", `[registerInteractionCommands] Started registering interaction commands...`); | ||
const parsedSlashCommands: { | ||
name: string; | ||
description?: string; | ||
options?: ApplicationCommandOptionData[]; | ||
guilds: Snowflake[]; | ||
defaultPermission: boolean; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[] = []; | ||
const guildSlashCommandsParsed: Collection< | ||
Snowflake, | ||
{ | ||
name: string; | ||
description: string; | ||
options: ApplicationCommandOptionData[]; | ||
defaultPermission: boolean; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[] | ||
> = new Collection(); | ||
const parsedSlashCommands: (ApplicationCommandData & { guilds: Snowflake[] })[] = []; | ||
const guildSlashCommandsParsed: Collection<Snowflake, ApplicationCommandData[]> = new Collection(); | ||
const parseDescriptionCommand = (description: { content: () => any }) => { | ||
@@ -398,4 +384,3 @@ if (typeof description === "object") { | ||
options: data.slashOptions?.map(o => { | ||
// this may not be necessary but im not sure | ||
const temp = Object.assign({}, o); | ||
const temp = { ...o }; | ||
delete temp.resolve; | ||
@@ -406,3 +391,3 @@ return temp as ApplicationCommandOptionData; | ||
defaultPermission: data.slashDefaultPermission, | ||
type: "ChatInput" | ||
type: ApplicationCommandType.ChatInput | ||
}); | ||
@@ -432,8 +417,8 @@ } | ||
.filter(({ guilds }) => !guilds.length) | ||
.map(({ name, description, options, defaultPermission, type }) => ({ | ||
name, | ||
description: description ?? "", | ||
options: options ?? [], | ||
defaultPermission, | ||
type | ||
.map(options => ({ | ||
name: options.name, | ||
description: options.type === ApplicationCommandType.ChatInput ? options.description ?? "" : undefined, | ||
options: options.type === ApplicationCommandType.ChatInput ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
type: options.type | ||
})) | ||
@@ -444,3 +429,3 @@ .sort((a, b) => { | ||
return 0; | ||
}); | ||
}) as ApplicationCommandData[]; | ||
const currentGlobalCommands = (await this.client.application?.commands.fetch())! | ||
@@ -458,3 +443,3 @@ .map(value1 => ({ | ||
return 0; | ||
}); | ||
}) as ApplicationCommandData[]; | ||
@@ -472,7 +457,13 @@ if (!Util.deepEquals(currentGlobalCommands, slashCommandsApp)) { | ||
/* Guilds */ | ||
for (const { name, description, options, guilds, defaultPermission, type } of parsedSlashCommands) { | ||
for (const guildId of guilds) { | ||
for (const options of parsedSlashCommands) { | ||
for (const guildId of options.guilds) { | ||
guildSlashCommandsParsed.set(guildId, [ | ||
...(guildSlashCommandsParsed.get(guildId) ?? []), | ||
{ name, description: description!, options: options!, defaultPermission, type } | ||
{ | ||
name: options.name, | ||
description: options.type === ApplicationCommandType.ChatInput ? options.description ?? "" : undefined, | ||
options: options.type === ApplicationCommandType.ChatInput ? options.options ?? [] : undefined, | ||
defaultPermission: options.defaultPermission, | ||
type: options.type | ||
} as ApplicationCommandData | ||
]); | ||
@@ -1622,17 +1613,9 @@ } | ||
export type InteractionArgs = { | ||
name: string; | ||
description: string; | ||
options: ApplicationCommandOptionData[]; | ||
defaultPermission: boolean; | ||
type: "ChatInput" | "Message" | "User"; | ||
}[]; | ||
export class RegisterInteractionCommandError extends Error { | ||
original: DiscordAPIError; | ||
type: "guild" | "global"; | ||
data: InteractionArgs; | ||
data: ApplicationCommandData[]; | ||
guild: Guild | null; | ||
constructor(original: DiscordAPIError, type: "guild" | "global", data: InteractionArgs, guild: Guild | null = null) { | ||
constructor(original: DiscordAPIError, type: "guild" | "global", data: ApplicationCommandData[], guild: Guild | null = null) { | ||
super("Failed to register interaction commands."); | ||
@@ -1639,0 +1622,0 @@ this.original = original; |
/* eslint-disable func-names, @typescript-eslint/no-unused-vars */ | ||
import type { ContextMenuCommandInteraction, Snowflake } from "discord.js"; | ||
import type { ApplicationCommandType, ContextMenuCommandInteraction, Snowflake } from "discord.js"; | ||
import AkairoError from "../../util/AkairoError.js"; | ||
@@ -36,3 +36,3 @@ import type Category from "../../util/Category.js"; | ||
*/ | ||
public declare type: "User" | "Message"; | ||
public declare type: ApplicationCommandType.User | ApplicationCommandType.Message; | ||
@@ -122,3 +122,3 @@ /** | ||
*/ | ||
type: "User" | "Message"; | ||
type: ApplicationCommandType.User | ApplicationCommandType.Message; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
913231
16384