Socket
Socket
Sign inDemoInstall

@notenoughupdates/discord-akairo

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@notenoughupdates/discord-akairo - npm Package Compare versions

Comparing version 9.0.10-dev.1638045263.139fb9b to 9.0.10-dev.1639356088.96444cd

143

dist/package.json
{
"name": "@notenoughupdates/discord-akairo",
"version": "9.0.10-dev.1638045263.139fb9b",
"version": "9.0.10-dev.1639356088.96444cd",
"description": "A highly customizable bot framework for Discord.js.",

@@ -37,3 +37,2 @@ "main": "./dist/src/index.js",

"dependencies": {
"lodash": "^4.17.21",
"source-map-support": "^0.5.21"

@@ -44,17 +43,14 @@ },

"@favware/npm-deprecate": "^1.0.4",
"@types/lodash": "^4.14.177",
"@types/node": "^16.11.10",
"@types/node": "^16.11.12",
"@types/source-map-support": "^0.5.4",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"discord-api-types": "0.24.0",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"discord-api-types": "0.25.2",
"discord.js": "npm:@notenoughupdates/discord.js@dev",
"discord.js-docgen": "discordjs/docgen",
"eslint": "^8.3.0",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"jsdoc": "^3.6.7",
"prettier": "^2.5.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"typedoc": "^0.22.10",
"typescript": "^4.5.2"
"typescript": "^4.5.3"
},

@@ -74,126 +70,3 @@ "prettier": {

]
},
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"ignorePatterns": [
"dist"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"project": "./tsconfig-eslint.json"
},
"env": {
"es2021": true,
"node": true
},
"rules": {
"no-await-in-loop": "off",
"no-template-curly-in-string": "error",
"no-unsafe-negation": "error",
"accessor-pairs": "warn",
"array-callback-return": "error",
"complexity": [
"warn",
25
],
"consistent-return": "error",
"eqeqeq": [
"error",
"smart"
],
"no-console": "warn",
"no-empty-function": "off",
"no-implied-eval": "error",
"no-lone-blocks": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "warn",
"require-await": "warn",
"yoda": "error",
"no-label-var": "error",
"no-undef-init": "error",
"callback-return": "error",
"handle-callback-err": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"consistent-this": [
"error",
"$this"
],
"func-names": "error",
"func-name-matching": "error",
"func-style": [
"error",
"declaration",
{
"allowArrowFunctions": true
}
],
"max-depth": [
"error",
7
],
"max-nested-callbacks": [
"error",
{
"max": 4
}
],
"max-statements-per-line": [
"error",
{
"max": 2
}
],
"new-cap": "error",
"no-array-constructor": "error",
"no-inline-comments": "off",
"no-lonely-if": "error",
"no-new-object": "error",
"no-spaced-func": "error",
"no-unneeded-ternary": "error",
"operator-assignment": "error",
"spaced-comment": "error",
"no-duplicate-imports": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"prefer-const": "error",
"prefer-arrow-callback": "error",
"prefer-numeric-literals": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"no-throw-literal": "off",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
}

6

dist/src/index.d.ts

@@ -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, MentionPrefixPredicate, ParsedComponentData, PrefixSupplier, SlashResolveTypes } from "./struct/commands/CommandHandler";
import CommandHandler, { CommandHandlerOptions, CooldownData, IgnoreCheckPredicate, InteractionArgs, MentionPrefixPredicate, ParsedComponentData, PrefixSupplier, RegisterInteractionCommandError, SlashResolveTypes } from "./struct/commands/CommandHandler";
import CommandUtil from "./struct/commands/CommandUtil";

@@ -42,4 +42,4 @@ 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, 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_, ArgumentTypeCaster, BaseArgumentType, BeforeAction, CommandHandlerEvents, CommandHandlerOptions, CommandOptions, ContentParserOptions, ContextMenuCommandHandlerEvents, ContextMenuCommandOptions, CooldownData, DefaultArgumentOptions, DefaultValueSupplier, ExecutionPredicate, ExtractedFlags, FailureData, GuildTextBasedChannels, IgnoreCheckPredicate, InhibitorHandlerEvents, InhibitorOptions, KeySupplier, ListenerHandlerEvents, ListenerOptions, ListenerType, LoadPredicate, MentionPrefixPredicate, MissingPermissionSupplier, OtherwiseContentModifier, OtherwiseContentSupplier, ParsedComponentData, ParsedValuePredicate, PrefixSupplier, PromptContentSupplier, RegexSupplier, SlashOption, SlashPermissionsSupplier, SlashResolveTypes, StringData, TaskHandlerEvents, TaskOptions };
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_, ArgumentTypeCaster, BaseArgumentType, BeforeAction, CommandHandlerEvents, CommandHandlerOptions, CommandOptions, ContentParserOptions, ContextMenuCommandHandlerEvents, ContextMenuCommandOptions, CooldownData, DefaultArgumentOptions, DefaultValueSupplier, ExecutionPredicate, ExtractedFlags, FailureData, GuildTextBasedChannels, IgnoreCheckPredicate, InhibitorHandlerEvents, InhibitorOptions, InteractionArgs, 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

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.version = exports.Util = exports.TypeResolver = exports.TaskHandler = exports.Task = exports.ListenerHandler = exports.Listener = exports.InhibitorHandler = exports.Inhibitor = exports.Flag = exports.ContextMenuCommandHandler = exports.ContextMenuCommand = exports.ContentParser = exports.Constants = exports.CommandUtil = exports.CommandHandler = exports.Command = exports.ClientUtil = exports.Category = exports.ArgumentRunner = exports.Argument = exports.AkairoModule = exports.AkairoMessage = exports.AkairoHandler = exports.AkairoError = exports.AkairoClient = void 0;
exports.version = exports.Util = exports.TypeResolver = exports.TaskHandler = exports.Task = exports.RegisterInteractionCommandError = exports.ListenerHandler = exports.Listener = exports.InhibitorHandler = exports.Inhibitor = exports.Flag = exports.ContextMenuCommandHandler = exports.ContextMenuCommand = exports.ContentParser = exports.Constants = exports.CommandUtil = exports.CommandHandler = exports.Command = exports.ClientUtil = exports.Category = exports.ArgumentRunner = exports.Argument = exports.AkairoModule = exports.AkairoMessage = exports.AkairoHandler = exports.AkairoError = exports.AkairoClient = void 0;
require("source-map-support/register");

@@ -45,4 +45,5 @@ const package_json_1 = __importDefault(require("../package.json"));

exports.Command = Command_1.default;
const CommandHandler_1 = __importDefault(require("./struct/commands/CommandHandler"));
const CommandHandler_1 = __importStar(require("./struct/commands/CommandHandler"));
exports.CommandHandler = CommandHandler_1.default;
Object.defineProperty(exports, "RegisterInteractionCommandError", { enumerable: true, get: function () { return CommandHandler_1.RegisterInteractionCommandError; } });
const CommandUtil_1 = __importDefault(require("./struct/commands/CommandUtil"));

@@ -49,0 +50,0 @@ exports.CommandUtil = CommandUtil_1.default;

@@ -13,8 +13,6 @@ "use strict";

constructor(options, clientOptions) {
Object.assign(options, clientOptions);
super(options);
const { ownerID = "" } = options;
const { superUserID = "" } = options;
this.ownerID = ownerID;
this.superUserID = superUserID;
const combinedOptions = { ...options, ...clientOptions };
super(combinedOptions);
this.ownerID = combinedOptions.ownerID ?? [];
this.superUserID = combinedOptions.superUserID ?? [];
this.util = new ClientUtil_js_1.default(this);

@@ -21,0 +19,0 @@ }

@@ -50,3 +50,3 @@ /// <reference types="node" />

*/
constructor(client: AkairoClient, { directory, classToHandle, extensions, automateCategories, loadFilter }: AkairoHandlerOptions);
constructor(client: AkairoClient, options?: AkairoHandlerOptions);
/**

@@ -53,0 +53,0 @@ * Deregisters a module.

@@ -23,3 +23,4 @@ "use strict";

*/
constructor(client, { directory, classToHandle = AkairoModule_js_1.default, extensions = [".js", ".json", ".ts"], automateCategories = false, loadFilter = () => true }) {
constructor(client, options) {
const { directory, classToHandle = AkairoModule_js_1.default, extensions = [".js", ".json", ".ts"], automateCategories = false, loadFilter = () => true } = options ?? {};
super();

@@ -26,0 +27,0 @@ this.client = client;

@@ -36,3 +36,3 @@ import type Category from "../util/Category.js";

*/
constructor(id: string, { category }?: AkairoModuleOptions);
constructor(id: string, options?: AkairoModuleOptions);
/**

@@ -39,0 +39,0 @@ * Reloads the module.

@@ -11,3 +11,4 @@ "use strict";

*/
constructor(id, { category = "default" } = {}) {
constructor(id, options) {
const { category = "default" } = options ?? {};
this.id = id;

@@ -14,0 +15,0 @@ this.categoryID = category;

/// <reference types="node" />
import { BaseGuildVoiceChannel, BufferResolvable, Collection, Emoji, Guild, GuildMember, MessageAttachment, MessageEmbed, MessageEmbedOptions, Role, Snowflake, User } from "discord.js";
import { BaseGuildVoiceChannel, BufferResolvable, Collection, Emoji, Guild, GuildMember, MessageAttachment, MessageEmbed, MessageEmbedOptions, PermissionString, Role, Snowflake, User } from "discord.js";
import type { Stream } from "stream";

@@ -99,3 +99,3 @@ import type { GuildTextBasedChannels } from "../typings/guildTextBasedChannels.js";

*/
permissionNames(): string[];
permissionNames(): PermissionString[];
/**

@@ -102,0 +102,0 @@ * Resolves a channel from a string, such as an ID, a name, or a mention.

@@ -193,6 +193,9 @@ "use strict";

const handlerDefs = this.handler.argumentDefaults;
const optional = Util_js_1.default.choice(typeof this.prompt === "object" && this.prompt && this.prompt.optional, commandDefs.prompt && commandDefs.prompt.optional, handlerDefs.prompt && handlerDefs.prompt.optional);
const optional = (typeof this.prompt === "object" && this.prompt && this.prompt.optional) ??
(commandDefs.prompt && commandDefs.prompt.optional) ??
(handlerDefs.prompt && handlerDefs.prompt.optional) ??
null;
const doOtherwise = async (failure) => {
const otherwise = Util_js_1.default.choice(this.otherwise, commandDefs.otherwise, handlerDefs.otherwise);
const modifyOtherwise = Util_js_1.default.choice(this.modifyOtherwise, commandDefs.modifyOtherwise, handlerDefs.modifyOtherwise);
const otherwise = this.otherwise ?? commandDefs.otherwise ?? handlerDefs.otherwise ?? null;
const modifyOtherwise = this.modifyOtherwise ?? commandDefs.modifyOtherwise ?? handlerDefs.modifyOtherwise ?? null;
let text = await Util_js_1.default.intoCallable(otherwise).call(this, message, {

@@ -199,0 +202,0 @@ phrase,

@@ -28,3 +28,3 @@ "use strict";

addBuiltInTypes() {
const builtins = {
const builtIns = {
[Constants_js_1.ArgumentTypes.STRING]: (_message, phrase) => {

@@ -498,3 +498,3 @@ return phrase || null;

};
for (const [key, value] of Object.entries(builtins)) {
for (const [key, value] of Object.entries(builtIns)) {
this.types.set(key, value);

@@ -501,0 +501,0 @@ }

@@ -19,5 +19,5 @@ "use strict";

*/
constructor(id, options = {}) {
constructor(id, options) {
super(id, { category: options?.category });
const { aliases = [], args = this._args || this.args || [], argumentDefaults = {}, before = this.before || (() => undefined), channel = null, clientPermissions = this.clientPermissions, condition = this.condition || (() => false), cooldown = null, description = "", editable = true, flags = [], ignoreCooldown, ignorePermissions, lock, onlyNsfw = false, optionFlags = [], ownerOnly = false, prefix = this.prefix, quoted = true, ratelimit = 1, regex = this.regex, separator, slash = false, slashDefaultPermission, slashEphemeral = false, slashGuilds = [], slashOnly = false, slashOptions, slashPermissions, superUserOnly = false, typing = false, userPermissions = this.userPermissions } = options;
const { aliases = [], args = this._args || this.args || [], argumentDefaults = {}, before = this.before || (() => undefined), channel = null, clientPermissions = this.clientPermissions, condition = this.condition || (() => false), cooldown = null, description = "", editable = true, flags = [], ignoreCooldown, ignorePermissions, lock, onlyNsfw = false, optionFlags = [], ownerOnly = false, prefix = this.prefix, quoted = true, ratelimit = 1, regex = this.regex, separator, slash = false, slashDefaultPermission, slashEphemeral = false, slashGuilds = [], slashOnly = false, slashOptions, slashPermissions, superUserOnly = false, typing = false, userPermissions = this.userPermissions } = options ?? {};
this.aliases = aliases;

@@ -24,0 +24,0 @@ const { flagWords, optionFlagWords } = Array.isArray(args)

/// <reference types="node" />
import { AutocompleteInteraction, Awaitable, Collection, CommandInteraction, Message, Snowflake, TextBasedChannels, User } from "discord.js";
import { ApplicationCommandOptionData, AutocompleteInteraction, Awaitable, Collection, CommandInteraction, DiscordAPIError, Guild, Message, Snowflake, TextBasedChannels, User } from "discord.js";
import type { CommandHandlerEvents as CommandHandlerEventsType } from "../../typings/events";

@@ -197,2 +197,6 @@ import AkairoMessage from "../../util/AkairoMessage.js";

handleSlash(interaction: CommandInteraction): Promise<boolean | null>;
/**
* Handles autocomplete interactions.
* @param interaction The interaction to handle.
*/
handleAutocomplete(interaction: AutocompleteInteraction): void;

@@ -374,2 +378,16 @@ /**

}
export declare type InteractionArgs = {
name: string;
description: string;
options: ApplicationCommandOptionData[];
defaultPermission: boolean;
type: "CHAT_INPUT" | "MESSAGE" | "USER";
}[];
export declare class RegisterInteractionCommandError extends Error {
original: DiscordAPIError;
type: "guild" | "global";
data: InteractionArgs;
guild: Guild | null;
constructor(original: DiscordAPIError, type: "guild" | "global", data: InteractionArgs, guild?: Guild | null);
}
export interface CommandHandlerOptions extends AkairoHandlerOptions {

@@ -376,0 +394,0 @@ /**

@@ -6,4 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RegisterInteractionCommandError = void 0;
const discord_js_1 = require("discord.js");
const lodash_1 = __importDefault(require("lodash"));
const AkairoError_js_1 = __importDefault(require("../../util/AkairoError.js"));

@@ -27,4 +27,4 @@ const AkairoMessage_js_1 = __importDefault(require("../../util/AkairoMessage.js"));

*/
constructor(client, options = {}) {
const { directory, classToHandle = Command_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter, blockClient = true, blockBots = true, fetchMembers = false, handleEdits = false, storeMessages = false, commandUtil, commandUtilLifetime = 3e5, commandUtilSweepInterval = 3e5, defaultCooldown = 0, ignoreCooldown = client.ownerID, ignorePermissions = [], argumentDefaults = {}, prefix = "!", allowMention = true, aliasReplacement, autoDefer = false, typing = false, autoRegisterSlashCommands = false, execSlash = false, skipBuiltInPostInhibitors = false, useSlashPermissions = false } = options;
constructor(client, options) {
const { directory, classToHandle = Command_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter, blockClient = true, blockBots = true, fetchMembers = false, handleEdits = false, storeMessages = false, commandUtil, commandUtilLifetime = 3e5, commandUtilSweepInterval = 3e5, defaultCooldown = 0, ignoreCooldown = client.ownerID, ignorePermissions = [], argumentDefaults = {}, prefix = "!", allowMention = true, aliasReplacement, autoDefer = false, typing = false, autoRegisterSlashCommands = false, execSlash = false, skipBuiltInPostInhibitors = false, useSlashPermissions = false } = options ?? {};
if (!(classToHandle.prototype instanceof Command_1.default || classToHandle === Command_1.default)) {

@@ -178,5 +178,9 @@ throw new AkairoError_js_1.default("INVALID_CLASS_TO_HANDLE", classToHandle.name, Command_1.default.name);

.filter(({ guilds }) => !guilds.length)
.map(({ name, description, options, defaultPermission, type }) => {
return { name, description, options, defaultPermission, type };
});
.map(({ name, description, options, defaultPermission, type }) => ({
name,
description: description,
options: options,
defaultPermission,
type
}));
const currentGlobalCommands = (await this.client.application?.commands.fetch()).map(value1 => ({

@@ -189,4 +193,9 @@ name: value1.name,

}));
if (!lodash_1.default.isEqual(currentGlobalCommands, slashCommandsApp)) {
await this.client.application?.commands.set(slashCommandsApp);
if (!Util_js_1.default.deepEquals(currentGlobalCommands, slashCommandsApp)) {
await this.client.application?.commands.set(slashCommandsApp).catch(error => {
if (error instanceof discord_js_1.DiscordAPIError)
throw new RegisterInteractionCommandError(error, "global", slashCommandsApp);
else
throw error;
});
}

@@ -214,4 +223,9 @@ /* Guilds */

}));
if (!lodash_1.default.isEqual(currentGuildCommands, value)) {
await guild.commands.set(value);
if (!Util_js_1.default.deepEquals(currentGuildCommands, value)) {
await guild.commands.set(value).catch(error => {
if (error instanceof discord_js_1.DiscordAPIError)
throw new RegisterInteractionCommandError(error, "guild", value, guild);
else
throw error;
});
}

@@ -478,4 +492,5 @@ });

const originalOption = commandModule.slashOptions?.find(o => o.name === option.name);
convertedOptions[option.name] = interaction.options[lodash_1.default.camelCase(`GET_${originalOption?.resolve ?? option.type}`)](option.name, false);
convertedOptions[option.name] = interaction.options[Util_js_1.default.snakeToCamelCase(`GET_${originalOption?.resolve ?? option.type}`)](option.name, false);
}
// Makes options that are not found to be null so that it matches the behavior normal commands.
(() => {

@@ -579,2 +594,6 @@ if (convertedOptions.subcommand || convertedOptions.subcommandGroup) {

}
/**
* Handles autocomplete interactions.
* @param interaction The interaction to handle.
*/
handleAutocomplete(interaction) {

@@ -957,8 +976,18 @@ const commandModule = this.findCommand(interaction.commandName);

}
let typing;
if (command.typing || this.typing) {
message.channel.sendTyping();
typing = setInterval(() => {
if (command.typing || this.typing)
message.channel.sendTyping();
}, 9000);
}
this.emit(Constants_js_1.CommandHandlerEvents.COMMAND_STARTED, message, command, args);
const ret = await command.exec(message, args);
this.emit(Constants_js_1.CommandHandlerEvents.COMMAND_FINISHED, message, command, args, ret);
try {
this.emit(Constants_js_1.CommandHandlerEvents.COMMAND_STARTED, message, command, args);
const ret = await command.exec(message, args);
this.emit(Constants_js_1.CommandHandlerEvents.COMMAND_FINISHED, message, command, args, ret);
}
finally {
if (typing)
clearInterval(typing);
}
}

@@ -991,3 +1020,3 @@ /**

});
const pairs = Util_js_1.default.flatMap(await Promise.all(promises), (x) => x);
const pairs = (await Promise.all(promises)).flat(1);
pairs.sort(([a], [b]) => Util_js_1.default.prefixCompare(a, b));

@@ -1151,2 +1180,12 @@ return this.parseMultiplePrefixes(message, pairs);

exports.default = CommandHandler;
class RegisterInteractionCommandError extends Error {
constructor(original, type, data, guild = null) {
super("Failed to register interaction commands.");
this.original = original;
this.type = type;
this.data = data;
this.guild = guild;
}
}
exports.RegisterInteractionCommandError = RegisterInteractionCommandError;
/**

@@ -1153,0 +1192,0 @@ * @typedef {CommandInteractionOptionResolver} VSCodePleaseStopRemovingMyImports

@@ -18,4 +18,4 @@ "use strict";

*/
constructor(client, options = {}) {
const { directory, classToHandle = ContextMenuCommand_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter } = options;
constructor(client, options) {
const { directory, classToHandle = ContextMenuCommand_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter } = options ?? {};
if (!(classToHandle.prototype instanceof ContextMenuCommand_js_1.default || classToHandle === ContextMenuCommand_js_1.default)) {

@@ -22,0 +22,0 @@ throw new AkairoError_js_1.default("INVALID_CLASS_TO_HANDLE", classToHandle.name, ContextMenuCommand_js_1.default.name);

@@ -16,4 +16,4 @@ "use strict";

*/
constructor(id, options = {}) {
const { category, reason = "", type = "post", priority = 0 } = options;
constructor(id, options) {
const { category, reason = "", type = "post", priority = 0 } = options ?? {};
super(id, { category });

@@ -20,0 +20,0 @@ this.reason = reason;

@@ -18,4 +18,4 @@ "use strict";

*/
constructor(client, options = {}) {
const { directory, classToHandle = Inhibitor_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter } = options;
constructor(client, options) {
const { directory, classToHandle = Inhibitor_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter } = options ?? {};
if (!(classToHandle.prototype instanceof Inhibitor_js_1.default || classToHandle === Inhibitor_js_1.default)) {

@@ -22,0 +22,0 @@ throw new AkairoError_js_1.default("INVALID_CLASS_TO_HANDLE", classToHandle.name, Inhibitor_js_1.default.name);

@@ -19,4 +19,4 @@ "use strict";

*/
constructor(client, options = {}) {
const { directory, classToHandle = Listener_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter } = options;
constructor(client, options) {
const { directory, classToHandle = Listener_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter } = options ?? {};
if (!(classToHandle.prototype instanceof Listener_js_1.default || classToHandle === Listener_js_1.default)) {

@@ -23,0 +23,0 @@ throw new AkairoError_js_1.default("INVALID_CLASS_TO_HANDLE", classToHandle.name, Listener_js_1.default.name);

@@ -17,4 +17,4 @@ "use strict";

*/
constructor(id, options = {}) {
const { category, delay, runOnStart = false } = options;
constructor(id, options) {
const { category, delay, runOnStart = false } = options ?? {};
super(id, { category });

@@ -21,0 +21,0 @@ this.delay = delay;

@@ -35,3 +35,3 @@ import type { Awaitable, Collection } from "discord.js";

*/
constructor(client: AkairoClient, { directory, classToHandle, extensions, automateCategories, loadFilter }: AkairoHandlerOptions);
constructor(client: AkairoClient, options?: AkairoHandlerOptions);
/**

@@ -38,0 +38,0 @@ * Start all tasks.

@@ -17,3 +17,4 @@ "use strict";

*/
constructor(client, { directory, classToHandle = Task_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter }) {
constructor(client, options) {
const { directory, classToHandle = Task_js_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter } = options ?? {};
if (!(classToHandle.prototype instanceof Task_js_1.default || classToHandle === Task_js_1.default)) {

@@ -20,0 +21,0 @@ throw new AkairoError_js_1.default("INVALID_CLASS_TO_HANDLE", classToHandle.name, Task_js_1.default.name);

declare const Messages: {
FILE_NOT_FOUND: (filename: any) => string;
MODULE_NOT_FOUND: (constructor: any, id: any) => string;
ALREADY_LOADED: (constructor: any, id: any) => string;
NOT_RELOADABLE: (constructor: any, id: any) => string;
INVALID_CLASS_TO_HANDLE: (given: any, expected: any) => string;
ALIAS_CONFLICT: (alias: any, id: any, conflict: any) => string;
FILE_NOT_FOUND: (filename: string) => string;
MODULE_NOT_FOUND: (constructor: string, id: string) => string;
ALREADY_LOADED: (constructor: string, id: string) => string;
NOT_RELOADABLE: (constructor: string, id: string) => string;
INVALID_CLASS_TO_HANDLE: (given: string, expected: string) => string;
ALIAS_CONFLICT: (alias: string, id: string, conflict: string) => string;
COMMAND_UTIL_EXPLICIT: string;
UNKNOWN_MATCH_TYPE: (match: any) => string;
NOT_INSTANTIABLE: (constructor: any) => string;
NOT_IMPLEMENTED: (constructor: any, method: any) => string;
INVALID_TYPE: (name: any, expected: any, vowel?: boolean) => string;
UNKNOWN_MATCH_TYPE: (match: string) => string;
NOT_INSTANTIABLE: (constructor: string) => string;
NOT_IMPLEMENTED: (constructor: string, method: string) => string;
INVALID_TYPE: (name: string, expected: string, vowel?: boolean) => string;
};
interface MessageArgs {
FILE_NOT_FOUND: [filename: string];
MODULE_NOT_FOUND: [constructor: string, id: string];
ALREADY_LOADED: [constructor: string, id: string];
NOT_RELOADABLE: [constructor: string, id: string];
INVALID_CLASS_TO_HANDLE: [given: string, expected: string];
ALIAS_CONFLICT: [alias: string, id: string, conflict: string];
COMMAND_UTIL_EXPLICIT: [];
UNKNOWN_MATCH_TYPE: [match: string];
NOT_INSTANTIABLE: [constructor: string];
NOT_IMPLEMENTED: [constructor: string, method: string];
INVALID_TYPE: [name: string, expected: string, vowel: boolean];
}
/**
* Represents an error for Akairo.
*/
export default class AkairoError extends Error {
export default class AkairoError<K extends keyof typeof Messages> extends Error {
/**

@@ -26,3 +39,3 @@ * The error code.

*/
constructor(key: keyof typeof Messages, ...args: (string | boolean)[]);
constructor(key: K, ...args: MessageArgs[K]);
/**

@@ -29,0 +42,0 @@ * The error name.

@@ -24,18 +24,19 @@ "use strict";

this.partial = false;
const options = interaction.options;
if (interaction.command?.type === "CHAT_INPUT") {
if (interaction.options["_group"])
this.content += `group: ${interaction.options["_group"]}`;
if (interaction.options["_subcommand"])
this.content += `subcommand: ${interaction.options["_subcommand"]}`;
for (const option of interaction.options["_hoistedOptions"]) {
if (options["_group"])
this.content += `group: ${options["_group"]}`;
if (options["_subcommand"])
this.content += `subcommand: ${options["_subcommand"]}`;
for (const option of options["_hoistedOptions"]) {
if (["SUB_COMMAND", "SUB_COMMAND_GROUP"].includes(option.type))
continue;
this.content += ` ${option.name}: ${interaction.options.get(option.name, false)?.value}`;
this.content += ` ${option.name}: ${options.get(option.name, false)?.value}`;
}
}
else if (interaction.command?.type === "MESSAGE") {
this.content += ` message: ${interaction.options.getMessage("message").id}`;
this.content += ` message: ${options.getMessage("message").id}`;
}
else if (interaction.command?.type === "USER") {
this.content += ` message: ${interaction.options.getUser("user").id}`;
this.content += ` message: ${options.getUser("user").id}`;
}

@@ -42,0 +43,0 @@ }

@@ -8,7 +8,2 @@ /// <reference types="node" />

/**
* Choose the first non-null element in an array
* @param xs
*/
static choice<T>(...xs: T[]): T | null;
/**
* Deep assign properties to an object.

@@ -53,3 +48,15 @@ * @param target

static prefixCompare(aKey: string | ((...args: any[]) => any), bKey: string | ((...args: any[]) => any)): number;
/**
* Compares each property of two objects to determine if they are equal.
* @param a - First value.
* @param b - Second value.
* @returns Whether the two values are equal.
*/
static deepEquals(a: any, b: any): boolean;
/**
* Converts a string in snake_case to camelCase.
* @param str The string to convert.
*/
static snakeToCamelCase(str: string): string;
}
//# sourceMappingURL=Util.d.ts.map

@@ -8,14 +8,2 @@ "use strict";

/**
* Choose the first non-null element in an array
* @param xs
*/
static choice(...xs) {
for (const x of xs) {
if (x != null) {
return x;
}
}
return null;
}
/**
* Deep assign properties to an object.

@@ -108,4 +96,42 @@ * @param target

}
/**
* Compares each property of two objects to determine if they are equal.
* @param a - First value.
* @param b - Second value.
* @returns Whether the two values are equal.
*/
static deepEquals(a, b) {
if (a === b)
return true;
if (typeof a !== "object" || typeof b !== "object")
throw new TypeError("Not objects");
for (const key in a) {
if (!(key in b))
return false;
if (typeof a[key] === "object" && typeof b[key] === "object") {
if (!Util.deepEquals(a[key], b[key]))
return false;
}
else if (a[key] !== b[key])
return false;
}
return true;
}
/**
* Converts a string in snake_case to camelCase.
* @param str The string to convert.
*/
static snakeToCamelCase(str) {
return str
.toUpperCase()
.split("_")
.map((word, index) => {
if (index !== 1)
return word.charAt(0).toUpperCase() + word.slice(1);
return word;
})
.join("");
}
}
exports.default = Util;
//# sourceMappingURL=Util.js.map
{
"name": "@notenoughupdates/discord-akairo",
"version": "9.0.10-dev.1638045263.139fb9b",
"version": "9.0.10-dev.1639356088.96444cd",
"description": "A highly customizable bot framework for Discord.js.",

@@ -37,3 +37,2 @@ "main": "./dist/src/index.js",

"dependencies": {
"lodash": "^4.17.21",
"source-map-support": "^0.5.21"

@@ -44,17 +43,14 @@ },

"@favware/npm-deprecate": "^1.0.4",
"@types/lodash": "^4.14.177",
"@types/node": "^16.11.10",
"@types/node": "^16.11.12",
"@types/source-map-support": "^0.5.4",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"discord-api-types": "0.24.0",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"discord-api-types": "0.25.2",
"discord.js": "npm:@notenoughupdates/discord.js@dev",
"discord.js-docgen": "discordjs/docgen",
"eslint": "^8.3.0",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"jsdoc": "^3.6.7",
"prettier": "^2.5.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"typedoc": "^0.22.10",
"typescript": "^4.5.2"
"typescript": "^4.5.3"
},

@@ -74,126 +70,3 @@ "prettier": {

]
},
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"ignorePatterns": [
"dist"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"project": "./tsconfig-eslint.json"
},
"env": {
"es2021": true,
"node": true
},
"rules": {
"no-await-in-loop": "off",
"no-template-curly-in-string": "error",
"no-unsafe-negation": "error",
"accessor-pairs": "warn",
"array-callback-return": "error",
"complexity": [
"warn",
25
],
"consistent-return": "error",
"eqeqeq": [
"error",
"smart"
],
"no-console": "warn",
"no-empty-function": "off",
"no-implied-eval": "error",
"no-lone-blocks": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-unmodified-loop-condition": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": "warn",
"require-await": "warn",
"yoda": "error",
"no-label-var": "error",
"no-undef-init": "error",
"callback-return": "error",
"handle-callback-err": "error",
"no-mixed-requires": "error",
"no-new-require": "error",
"no-path-concat": "error",
"consistent-this": [
"error",
"$this"
],
"func-names": "error",
"func-name-matching": "error",
"func-style": [
"error",
"declaration",
{
"allowArrowFunctions": true
}
],
"max-depth": [
"error",
7
],
"max-nested-callbacks": [
"error",
{
"max": 4
}
],
"max-statements-per-line": [
"error",
{
"max": 2
}
],
"new-cap": "error",
"no-array-constructor": "error",
"no-inline-comments": "off",
"no-lonely-if": "error",
"no-new-object": "error",
"no-spaced-func": "error",
"no-unneeded-ternary": "error",
"operator-assignment": "error",
"spaced-comment": "error",
"no-duplicate-imports": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"prefer-const": "error",
"prefer-arrow-callback": "error",
"prefer-numeric-literals": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"no-throw-literal": "off",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
}

@@ -50,5 +50,7 @@ import "source-map-support/register";

IgnoreCheckPredicate,
InteractionArgs,
MentionPrefixPredicate,
ParsedComponentData,
PrefixSupplier,
RegisterInteractionCommandError,
SlashResolveTypes

@@ -128,2 +130,3 @@ } from "./struct/commands/CommandHandler";

PromptContentModifier,
RegisterInteractionCommandError,
Task,

@@ -175,2 +178,3 @@ TaskHandler,

InhibitorOptions,
InteractionArgs,
KeySupplier,

@@ -177,0 +181,0 @@ ListenerHandlerEvents,

@@ -31,8 +31,6 @@ import { Awaitable, Client, ClientOptions, Snowflake, UserResolvable } from "discord.js";

public constructor(options: (AkairoOptions & ClientOptions) | AkairoOptions, clientOptions?: ClientOptions) {
Object.assign(options, clientOptions);
super(options as AkairoOptions & ClientOptions);
const { ownerID = "" } = options;
const { superUserID = "" } = options;
this.ownerID = ownerID;
this.superUserID = superUserID;
const combinedOptions = { ...options, ...clientOptions };
super(combinedOptions as AkairoOptions & ClientOptions);
this.ownerID = combinedOptions.ownerID ?? [];
this.superUserID = combinedOptions.superUserID ?? [];
this.util = new ClientUtil(this);

@@ -39,0 +37,0 @@ }

@@ -62,5 +62,4 @@ import { Collection } from "discord.js";

*/
public constructor(
client: AkairoClient,
{
public constructor(client: AkairoClient, options?: AkairoHandlerOptions) {
const {
directory,

@@ -71,4 +70,3 @@ classToHandle = AkairoModule,

loadFilter = () => true
}: AkairoHandlerOptions
) {
} = options ?? {};
super();

@@ -75,0 +73,0 @@

@@ -43,3 +43,5 @@ import type Category from "../util/Category.js";

*/
public constructor(id: string, { category = "default" }: AkairoModuleOptions = {}) {
public constructor(id: string, options?: AkairoModuleOptions) {
const { category = "default" } = options ?? {};
this.id = id;

@@ -46,0 +48,0 @@ this.categoryID = category;

@@ -12,2 +12,3 @@ import {

Permissions,
PermissionString,
Role,

@@ -250,4 +251,4 @@ Snowflake,

*/
public permissionNames(): string[] {
return Object.keys(Permissions.FLAGS);
public permissionNames(): PermissionString[] {
return Object.keys(Permissions.FLAGS) as (keyof typeof Permissions.FLAGS)[];
}

@@ -254,0 +255,0 @@

@@ -306,16 +306,13 @@ import type { Message, MessageOptions, MessagePayload } from "discord.js";

const handlerDefs = this.handler.argumentDefaults;
const optional = Util.choice(
typeof this.prompt === "object" && this.prompt && this.prompt.optional,
commandDefs.prompt && commandDefs.prompt.optional,
handlerDefs.prompt && handlerDefs.prompt.optional
);
const optional =
(typeof this.prompt === "object" && this.prompt && this.prompt.optional) ??
(commandDefs.prompt && commandDefs.prompt.optional) ??
(handlerDefs.prompt && handlerDefs.prompt.optional) ??
null;
const doOtherwise = async (failure: (Flag & { value: any }) | null | undefined) => {
const otherwise = Util.choice(this.otherwise, commandDefs.otherwise, handlerDefs.otherwise);
const otherwise = this.otherwise ?? commandDefs.otherwise ?? handlerDefs.otherwise ?? null;
const modifyOtherwise = Util.choice(
this.modifyOtherwise,
commandDefs.modifyOtherwise,
handlerDefs.modifyOtherwise
);
const modifyOtherwise =
this.modifyOtherwise ?? commandDefs.modifyOtherwise ?? handlerDefs.modifyOtherwise ?? null;

@@ -322,0 +319,0 @@ let text = await Util.intoCallable(otherwise).call(this, message, {

@@ -81,3 +81,3 @@ import {

public addBuiltInTypes(): void {
const builtins = {
const builtIns = {
[ArgumentTypes.STRING]: (_message: Message, phrase: string) => {

@@ -569,3 +569,3 @@ return phrase || null;

for (const [key, value] of Object.entries(builtins)) {
for (const [key, value] of Object.entries(builtIns)) {
this.types.set(key, value);

@@ -572,0 +572,0 @@ }

@@ -218,3 +218,3 @@ /* eslint-disable func-names, @typescript-eslint/no-unused-vars */

*/
constructor(id: string, options: CommandOptions = {}) {
constructor(id: string, options?: CommandOptions) {
super(id, { category: options?.category });

@@ -255,3 +255,3 @@

userPermissions = this.userPermissions
} = options;
} = options ?? {};
this.aliases = aliases;

@@ -258,0 +258,0 @@ const { flagWords, optionFlagWords } = Array.isArray(args)

@@ -10,2 +10,3 @@ import {

CommandInteractionOptionResolver,
DiscordAPIError,
Guild,

@@ -21,3 +22,2 @@ GuildApplicationCommandPermissionData,

import { ApplicationCommandOptionTypes } from "discord.js/typings/enums";
import _ from "lodash";
import type { CommandHandlerEvents as CommandHandlerEventsType } from "../../typings/events";

@@ -226,3 +226,3 @@ import AkairoError from "../../util/AkairoError.js";

*/
public constructor(client: AkairoClient, options: CommandHandlerOptions = {}) {
public constructor(client: AkairoClient, options?: CommandHandlerOptions) {
const {

@@ -255,3 +255,3 @@ directory,

useSlashPermissions = false
} = options;
} = options ?? {};

@@ -427,5 +427,9 @@ if (!(classToHandle.prototype instanceof Command || classToHandle === Command)) {

.filter(({ guilds }) => !guilds.length)
.map(({ name, description, options, defaultPermission, type }) => {
return { name, description, options, defaultPermission, type };
});
.map(({ name, description, options, defaultPermission, type }) => ({
name,
description: description!,
options: options!,
defaultPermission,
type
}));
const currentGlobalCommands = (await this.client.application?.commands.fetch())!.map(value1 => ({

@@ -439,12 +443,8 @@ name: value1.name,

if (!_.isEqual(currentGlobalCommands, slashCommandsApp)) {
await this.client.application?.commands.set(
slashCommandsApp as {
name: string;
description: string;
options: ApplicationCommandOptionData[] | undefined;
defaultPermission: boolean;
type: "CHAT_INPUT" | "MESSAGE" | "USER";
}[]
);
if (!Util.deepEquals(currentGlobalCommands, slashCommandsApp)) {
await this.client.application?.commands.set(slashCommandsApp).catch(error => {
if (error instanceof DiscordAPIError)
throw new RegisterInteractionCommandError(error, "global", slashCommandsApp);
else throw error;
});
}

@@ -474,4 +474,8 @@

if (!_.isEqual(currentGuildCommands, value)) {
await guild.commands.set(value);
if (!Util.deepEquals(currentGuildCommands, value)) {
await guild.commands.set(value).catch(error => {
if (error instanceof DiscordAPIError)
throw new RegisterInteractionCommandError(error, "guild", value, guild);
else throw error;
});
}

@@ -772,6 +776,7 @@ });

convertedOptions[option.name] = interaction.options[
_.camelCase(`GET_${originalOption?.resolve ?? option.type}`) as GetFunctions
Util.snakeToCamelCase(`GET_${originalOption?.resolve ?? option.type}`) as GetFunctions
](option.name, false);
}
// Makes options that are not found to be null so that it matches the behavior normal commands.
(() => {

@@ -882,2 +887,6 @@ type SubCommand = AkairoApplicationCommandSubCommandData;

/**
* Handles autocomplete interactions.
* @param interaction The interaction to handle.
*/
public handleAutocomplete(interaction: AutocompleteInteraction): void {

@@ -1304,9 +1313,16 @@ const commandModule = this.findCommand(interaction.commandName);

}
let typing;
if (command.typing || this.typing) {
message.channel.sendTyping();
typing = setInterval(() => {
if (command.typing || this.typing) message.channel.sendTyping();
}, 9000);
}
this.emit(CommandHandlerEvents.COMMAND_STARTED, message, command, args);
const ret = await command.exec(message, args);
this.emit(CommandHandlerEvents.COMMAND_FINISHED, message, command, args, ret);
try {
this.emit(CommandHandlerEvents.COMMAND_STARTED, message, command, args);
const ret = await command.exec(message, args);
this.emit(CommandHandlerEvents.COMMAND_FINISHED, message, command, args, ret);
} finally {
if (typing) clearInterval(typing);
}
}

@@ -1347,3 +1363,3 @@

const pairs = Util.flatMap(await Promise.all(promises), (x: any) => x);
const pairs = (await Promise.all(promises)).flat(1);
pairs.sort(([a]: any, [b]: any) => Util.prefixCompare(a, b));

@@ -1575,2 +1591,25 @@ return this.parseMultiplePrefixes(message, pairs as [string, Set<string>][]);

export type InteractionArgs = {
name: string;
description: string;
options: ApplicationCommandOptionData[];
defaultPermission: boolean;
type: "CHAT_INPUT" | "MESSAGE" | "USER";
}[];
export class RegisterInteractionCommandError extends Error {
original: DiscordAPIError;
type: "guild" | "global";
data: InteractionArgs;
guild: Guild | null;
constructor(original: DiscordAPIError, type: "guild" | "global", data: InteractionArgs, guild: Guild | null = null) {
super("Failed to register interaction commands.");
this.original = original;
this.type = type;
this.data = data;
this.guild = guild;
}
}
export interface CommandHandlerOptions extends AkairoHandlerOptions {

@@ -1577,0 +1616,0 @@ /**

@@ -50,3 +50,3 @@ import type { Awaitable, Collection, ContextMenuInteraction } from "discord.js";

*/
public constructor(client: AkairoClient, options: AkairoHandlerOptions = {}) {
public constructor(client: AkairoClient, options?: AkairoHandlerOptions) {
const {

@@ -58,3 +58,3 @@ directory,

loadFilter
} = options;
} = options ?? {};

@@ -61,0 +61,0 @@ if (!(classToHandle.prototype instanceof ContextMenuCommand || classToHandle === ContextMenuCommand)) {

@@ -59,4 +59,4 @@ /* eslint-disable @typescript-eslint/no-unused-vars */

*/
public constructor(id: string, options: InhibitorOptions = {}) {
const { category, reason = "", type = "post", priority = 0 } = options;
public constructor(id: string, options?: InhibitorOptions) {
const { category, reason = "", type = "post", priority = 0 } = options ?? {};

@@ -63,0 +63,0 @@ super(id, { category });

@@ -45,3 +45,3 @@ import type { Awaitable, Collection, Message } from "discord.js";

*/
public constructor(client: AkairoClient, options: AkairoHandlerOptions = {}) {
public constructor(client: AkairoClient, options?: AkairoHandlerOptions) {
const {

@@ -53,3 +53,3 @@ directory,

loadFilter
} = options;
} = options ?? {};

@@ -56,0 +56,0 @@ if (!(classToHandle.prototype instanceof Inhibitor || classToHandle === Inhibitor)) {

@@ -50,3 +50,3 @@ import { Awaitable, Collection } from "discord.js";

*/
public constructor(client: AkairoClient, options: AkairoHandlerOptions = {}) {
public constructor(client: AkairoClient, options?: AkairoHandlerOptions) {
const {

@@ -58,3 +58,3 @@ directory,

loadFilter
} = options;
} = options ?? {};

@@ -61,0 +61,0 @@ if (!(classToHandle.prototype instanceof Listener || classToHandle === Listener)) {

@@ -46,4 +46,4 @@ /* eslint-disable func-names, @typescript-eslint/no-unused-vars */

*/
public constructor(id: string, options: TaskOptions = {}) {
const { category, delay, runOnStart = false } = options;
public constructor(id: string, options?: TaskOptions) {
const { category, delay, runOnStart = false } = options ?? {};

@@ -50,0 +50,0 @@ super(id, { category });

@@ -42,5 +42,4 @@ import type { Awaitable, Collection } from "discord.js";

*/
public constructor(
client: AkairoClient,
{
public constructor(client: AkairoClient, options?: AkairoHandlerOptions) {
const {
directory,

@@ -51,4 +50,4 @@ classToHandle = Task,

loadFilter
}: AkairoHandlerOptions
) {
} = options ?? {};
if (!(classToHandle.prototype instanceof Task || classToHandle === Task)) {

@@ -55,0 +54,0 @@ throw new AkairoError("INVALID_CLASS_TO_HANDLE", classToHandle.name, Task.name);

const Messages = {
// Module-related
FILE_NOT_FOUND: (filename: any) => `File '${filename}' not found`,
MODULE_NOT_FOUND: (constructor: any, id: any) => `${constructor} '${id}' does not exist`,
ALREADY_LOADED: (constructor: any, id: any) => `${constructor} '${id}' is already loaded`,
NOT_RELOADABLE: (constructor: any, id: any) => `${constructor} '${id}' is not reloadable`,
INVALID_CLASS_TO_HANDLE: (given: any, expected: any) => `Class to handle ${given} is not a subclass of ${expected}`,
FILE_NOT_FOUND: (filename: string) => `File '${filename}' not found`,
MODULE_NOT_FOUND: (constructor: string, id: string) => `${constructor} '${id}' does not exist`,
ALREADY_LOADED: (constructor: string, id: string) => `${constructor} '${id}' is already loaded`,
NOT_RELOADABLE: (constructor: string, id: string) => `${constructor} '${id}' is not reloadable`,
INVALID_CLASS_TO_HANDLE: (given: string, expected: string) =>
`Class to handle ${given} is not a subclass of ${expected}`,
// Command-related
ALIAS_CONFLICT: (alias: any, id: any, conflict: any) => `Alias '${alias}' of '${id}' already exists on '${conflict}'`,
ALIAS_CONFLICT: (alias: string, id: string, conflict: string) =>
`Alias '${alias}' of '${id}' already exists on '${conflict}'`,

@@ -15,15 +17,29 @@ // Options-related

"The command handler options `handleEdits` and `storeMessages` require the `commandUtil` option to be true",
UNKNOWN_MATCH_TYPE: (match: any) => `Unknown match type '${match}'`,
UNKNOWN_MATCH_TYPE: (match: string) => `Unknown match type '${match}'`,
// Generic errors
NOT_INSTANTIABLE: (constructor: any) => `${constructor} is not instantiable`,
NOT_IMPLEMENTED: (constructor: any, method: any) => `${constructor}#${method} has not been implemented`,
INVALID_TYPE: (name: any, expected: any, vowel = false) =>
NOT_INSTANTIABLE: (constructor: string) => `${constructor} is not instantiable`,
NOT_IMPLEMENTED: (constructor: string, method: string) => `${constructor}#${method} has not been implemented`,
INVALID_TYPE: (name: string, expected: string, vowel = false) =>
`Value of '${name}' was not ${vowel ? "an" : "a"} ${expected}`
};
interface MessageArgs {
FILE_NOT_FOUND: [filename: string];
MODULE_NOT_FOUND: [constructor: string, id: string];
ALREADY_LOADED: [constructor: string, id: string];
NOT_RELOADABLE: [constructor: string, id: string];
INVALID_CLASS_TO_HANDLE: [given: string, expected: string];
ALIAS_CONFLICT: [alias: string, id: string, conflict: string];
COMMAND_UTIL_EXPLICIT: [];
UNKNOWN_MATCH_TYPE: [match: string];
NOT_INSTANTIABLE: [constructor: string];
NOT_IMPLEMENTED: [constructor: string, method: string];
INVALID_TYPE: [name: string, expected: string, vowel: boolean];
}
/**
* Represents an error for Akairo.
*/
export default class AkairoError extends Error {
export default class AkairoError<K extends keyof typeof Messages> extends Error {
/**

@@ -38,3 +54,3 @@ * The error code.

*/
public constructor(key: keyof typeof Messages, ...args: (string | boolean)[]) {
public constructor(key: K, ...args: MessageArgs[K]) {
if (Messages[key] == null) throw new TypeError(`Error key '${key}' does not exist`);

@@ -41,0 +57,0 @@ const message =

@@ -99,17 +99,14 @@ import type { APIInteractionGuildMember, APIMessage } from "discord-api-types/v9";

const options = interaction.options as CommandInteractionOptionResolver;
if (interaction.command?.type === "CHAT_INPUT") {
if ((interaction.options as CommandInteractionOptionResolver)["_group"])
this.content += `group: ${(interaction.options as CommandInteractionOptionResolver)["_group"]}`;
if ((interaction.options as CommandInteractionOptionResolver)["_subcommand"])
this.content += `subcommand: ${(interaction.options as CommandInteractionOptionResolver)["_subcommand"]}`;
for (const option of (interaction.options as CommandInteractionOptionResolver)["_hoistedOptions"]) {
if (options["_group"]) this.content += `group: ${options["_group"]}`;
if (options["_subcommand"]) this.content += `subcommand: ${options["_subcommand"]}`;
for (const option of options["_hoistedOptions"]) {
if (["SUB_COMMAND", "SUB_COMMAND_GROUP"].includes(option.type)) continue;
this.content += ` ${option.name}: ${interaction.options.get(option.name, false)?.value}`;
this.content += ` ${option.name}: ${options.get(option.name, false)?.value}`;
}
} else if (interaction.command?.type === "MESSAGE") {
this.content += ` message: ${
(interaction.options as CommandInteractionOptionResolver).getMessage("message")!.id
}`;
this.content += ` message: ${options.getMessage("message")!.id}`;
} else if (interaction.command?.type === "USER") {
this.content += ` message: ${interaction.options.getUser("user")!.id}`;
this.content += ` message: ${options.getUser("user")!.id}`;
}

@@ -116,0 +113,0 @@ }

@@ -0,1 +1,2 @@

/* eslint-disable @typescript-eslint/ban-types */
import type EventEmitter from "events";

@@ -8,16 +9,2 @@

/**
* Choose the first non-null element in an array
* @param xs
*/
public static choice<T>(...xs: T[]): T | null {
for (const x of xs) {
if (x != null) {
return x;
}
}
return null;
}
/**
* Deep assign properties to an object.

@@ -121,2 +108,35 @@ * @param target

}
/**
* Compares each property of two objects to determine if they are equal.
* @param a - First value.
* @param b - Second value.
* @returns Whether the two values are equal.
*/
public static deepEquals(a: any, b: any): boolean {
if (a === b) return true;
if (typeof a !== "object" || typeof b !== "object") throw new TypeError("Not objects");
for (const key in a) {
if (!(key in b)) return false;
if (typeof a[key] === "object" && typeof b[key] === "object") {
if (!Util.deepEquals(a[key], b[key])) return false;
} else if (a[key] !== b[key]) return false;
}
return true;
}
/**
* Converts a string in snake_case to camelCase.
* @param str The string to convert.
*/
public static snakeToCamelCase(str: string): string {
return str
.toUpperCase()
.split("_")
.map((word, index) => {
if (index !== 1) return word.charAt(0).toUpperCase() + word.slice(1);
return word;
})
.join("");
}
}

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

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

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

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc