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.1642853858.d99b3b4 to 9.0.10-dev.1642902587.27cb93d

2

dist/package.json
{
"name": "@notenoughupdates/discord-akairo",
"version": "9.0.10-dev.1642853858.d99b3b4",
"version": "9.0.10-dev.1642902587.27cb93d",
"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, MentionPrefixPredicate, ParsedComponentData, PrefixSupplier, RegisterInteractionCommandError, SlashResolveTypes } from "./struct/commands/CommandHandler";
import CommandHandler, { CommandHandlerOptions, CooldownData, IgnoreCheckPredicate, MentionPrefixPredicate, ParsedComponentData, PrefixSupplier, RegisterInteractionCommandError, SlashResolveType } 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, 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, SlashResolveType as SlashResolveTypes, StringData, TaskHandlerEvents, TaskOptions };
//# sourceMappingURL=index.d.ts.map

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

const Constants_js_1 = require("../util/Constants.js");
const Util_js_1 = __importDefault(require("../util/Util.js"));
const AkairoModule_js_1 = __importDefault(require("./AkairoModule.js"));

@@ -26,2 +27,12 @@ /**

const { directory, classToHandle = AkairoModule_js_1.default, extensions = [".js", ".json", ".ts"], automateCategories = false, loadFilter = () => true } = options ?? {};
if (typeof directory !== "string")
throw new TypeError("options.directory must be a string.");
if (classToHandle !== AkairoModule_js_1.default && !(classToHandle.prototype instanceof AkairoModule_js_1.default))
throw new TypeError("options.classToHandle must be a class that extends AkairoModule.");
if (!(extensions instanceof Set) && !Util_js_1.default.isArrayOf(extensions, "string"))
throw new TypeError("options.extensions must be an array of strings or a Set.");
if (typeof automateCategories !== "boolean")
throw new TypeError("options.automateCategories must be a boolean.");
if (typeof loadFilter !== "function")
throw new TypeError("options.loadFilter must be a function.");
super();

@@ -28,0 +39,0 @@ this.client = client;

@@ -13,2 +13,4 @@ "use strict";

const { category = "default" } = options ?? {};
if (typeof category !== "string")
throw new TypeError("options.category must be a string.");
this.id = id;

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

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

*/
index?: number;
index: number | null;
/**

@@ -77,3 +77,3 @@ * The amount of phrases to match for rest, separate, content, or text match.

*/
modifyOtherwise: OtherwiseContentModifier;
modifyOtherwise: OtherwiseContentModifier | null;
/**

@@ -86,7 +86,7 @@ * Whether to process multiple option flags instead of just the first.

*/
otherwise?: string | MessagePayload | MessageOptions | OtherwiseContentSupplier;
otherwise: string | MessagePayload | MessageOptions | OtherwiseContentSupplier | null;
/**
* The prompt options.
*/
prompt?: ArgumentPromptOptions | boolean;
prompt: ArgumentPromptOptions | boolean | null;
/**

@@ -93,0 +93,0 @@ * The type to cast to or a function to use to cast.

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,3 +26,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const Constants_js_1 = require("../../../util/Constants.js");
const Util_js_1 = __importDefault(require("../../../util/Util.js"));
const Util_js_1 = __importStar(require("../../../util/Util.js"));
const Flag_js_1 = __importDefault(require("../Flag.js"));

@@ -20,2 +39,22 @@ /**

const { match = Constants_js_1.ArgumentMatches.PHRASE, type = Constants_js_1.ArgumentTypes.STRING, flag = null, multipleFlags = false, index = null, unordered = false, limit = Infinity, prompt = null, default: defaultValue = null, otherwise = null, modifyOtherwise = null } = options;
if (!Object.values(Constants_js_1.ArgumentMatches).includes(match))
throw new TypeError(`options.match must one of ${Object.values(Constants_js_1.ArgumentMatches)
.map(v => `"${v}"`)
.join(", ")}.`);
if (flag !== null && !(0, Util_js_1.isStringArrayStringOrFunc)(Util_js_1.isStringArrayStringOrFunc))
throw new TypeError("options.flag must be a null, a string, or an array of strings.");
if (typeof multipleFlags !== "boolean")
throw new TypeError("options.multipleFlags must be a boolean.");
if (index !== null && typeof index !== "number")
throw new TypeError("options.index must be a number or null.");
if (typeof unordered !== "boolean" && typeof unordered !== "number" && !Util_js_1.default.isArrayOf(unordered, "number"))
throw new TypeError("options.unordered must be a boolean, number, or array of numbers.");
if (typeof limit !== "number")
throw new TypeError("options.limit must be a number.");
if (prompt !== null && typeof prompt !== "boolean" && typeof prompt !== "object")
throw new TypeError("options.prompt must be a boolean, object, or null.");
if (otherwise !== null && typeof otherwise !== "string" && typeof otherwise !== "function" && typeof otherwise !== "object")
throw new TypeError("options.otherwise must be a string, function, object, or null.");
if (modifyOtherwise !== null && typeof modifyOtherwise !== "function")
throw new TypeError("options.modifyOtherwise must be a function or null.");
this.command = command;

@@ -22,0 +61,0 @@ this.match = match;

@@ -8,3 +8,3 @@ import { ApplicationCommandAutocompleteOption, ApplicationCommandChannelOptionData, ApplicationCommandChoicesData, ApplicationCommandNonOptionsData, ApplicationCommandNumericOptionData, ApplicationCommandPermissionData, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, AutocompleteInteraction, Guild, Message, PermissionResolvable, Snowflake } from "discord.js";

import ArgumentRunner, { ArgumentRunnerState } from "./arguments/ArgumentRunner.js";
import CommandHandler, { IgnoreCheckPredicate, PrefixSupplier, SlashResolveTypes } from "./CommandHandler.js";
import CommandHandler, { IgnoreCheckPredicate, PrefixSupplier, SlashResolveType } from "./CommandHandler.js";
import ContentParser, { ContentParserResult } from "./ContentParser.js";

@@ -432,5 +432,5 @@ import type Flag from "./Flag.js";

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -441,5 +441,5 @@ export interface AkairoApplicationCommandAutocompleteOption extends ApplicationCommandAutocompleteOption {

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -450,5 +450,5 @@ export interface AkairoApplicationCommandNumericOptionData extends ApplicationCommandNumericOptionData {

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -459,5 +459,5 @@ export interface AkairoApplicationCommandNonOptionsData extends ApplicationCommandNonOptionsData {

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -468,5 +468,5 @@ export interface AkairoApplicationCommandChannelOptionData extends ApplicationCommandChannelOptionData {

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -478,6 +478,10 @@ export declare type AkairoApplicationCommandOptionData = AkairoApplicationCommandSubGroupData | AkairoApplicationCommandNonOptionsData | AkairoApplicationCommandChannelOptionData | AkairoApplicationCommandChoicesData | AkairoApplicationCommandAutocompleteOption | AkairoApplicationCommandNumericOptionData | AkairoApplicationCommandSubCommandData;

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
};
/**
* @typedef {ApplicationCommandOptionType} VSCodePleaseStopRemovingMyImports
* @internal
*/
//# sourceMappingURL=Command.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,2 +26,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const AkairoError_js_1 = __importDefault(require("../../util/AkairoError.js"));
const Util_js_1 = __importStar(require("../../util/Util.js"));
const AkairoModule_js_1 = __importDefault(require("../AkairoModule.js"));

@@ -20,5 +40,64 @@ const Argument_js_1 = __importDefault(require("./arguments/Argument.js"));

*/
// eslint-disable-next-line complexity
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 ?? {};
if (!Util_js_1.default.isArrayOf(aliases, "string"))
throw new TypeError("options.aliases must be an array of strings.");
if (typeof args !== "function" && !Util_js_1.default.isArrayOf(args, "object"))
throw new TypeError("options.args must be an array of argument objects or a function.");
if (typeof argumentDefaults !== "object")
throw new TypeError("options.argumentDefaults must be an object.");
if (typeof before !== "function")
throw new TypeError("options.before must be a function.");
if (!["guild", "dm", null].includes(channel))
throw new TypeError('options.channel must be either "guild" or "dm" or null.');
if (typeof condition !== "function")
throw new TypeError("options.condition must be a function.");
if (typeof cooldown !== "number" && cooldown !== null)
throw new TypeError("options.cooldown must be a number or null.");
if (typeof editable !== "boolean")
throw new TypeError("options.editable must be a boolean.");
if (!Util_js_1.default.isArrayOf(flags, "string"))
throw new TypeError("options.flags must be an array of strings.");
if (ignoreCooldown !== undefined && !(0, Util_js_1.isStringArrayStringOrFunc)(ignoreCooldown))
throw new TypeError("options.ignoreCooldown must be a string, function, or array of strings.");
if (ignorePermissions !== undefined && !(0, Util_js_1.isStringArrayStringOrFunc)(ignorePermissions))
throw new TypeError("options.ignorePermissions must be a string, function, or array of strings.");
if (lock !== undefined && typeof lock !== "function" && !["channel", "guild", "user"].includes(lock))
throw new TypeError("options.lock must be a function or a string with a value of 'channel', 'guild', or 'user'.");
if (typeof onlyNsfw !== "boolean")
throw new TypeError("options.onlyNsfw must be a boolean.");
if (!Util_js_1.default.isArrayOf(optionFlags, "string"))
throw new TypeError("options.optionFlags must be an array of strings.");
if (typeof ownerOnly !== "boolean")
throw new TypeError("options.ownerOnly must be a boolean.");
if (prefix !== undefined && !(0, Util_js_1.isStringArrayStringOrFunc)(prefix))
throw new TypeError("options.prefix must be a string, function, or array of strings.");
if (typeof quoted !== "boolean")
throw new TypeError("options.quoted must be a boolean.");
if (typeof ratelimit !== "number")
throw new TypeError("options.ratelimit must be a number.");
if (regex !== undefined && typeof regex !== "function" && !(regex instanceof RegExp))
throw new TypeError("options.regex must be a function or a RegExp.");
if (separator !== undefined && typeof separator !== "string")
throw new TypeError("options.separator must be a string.");
if (typeof slash !== "boolean")
throw new TypeError("options.slash must be a boolean.");
if (slashDefaultPermission && typeof slashDefaultPermission !== "boolean")
throw new TypeError("options.slashDefaultPermission must be a boolean.");
if (typeof slashEphemeral !== "boolean")
throw new TypeError("options.slashEphemeral must be a boolean.");
if (!Util_js_1.default.isArrayOf(slashGuilds, "string"))
throw new TypeError("options.slashGuilds must be an array of strings.");
if (typeof slashOnly !== "boolean")
throw new TypeError("options.slashOnly must be a boolean.");
if (slashOptions !== undefined && !Util_js_1.default.isArrayOf(slashOptions, "object"))
throw new TypeError("options.slashOptions must be an array of objects.");
if (slashPermissions !== undefined && typeof slashPermissions !== "function" && !Util_js_1.default.isArrayOf(slashPermissions, "object"))
throw new TypeError("options.slashPermissions must be an array of objects or a function.");
if (typeof superUserOnly !== "boolean")
throw new TypeError("options.superUserOnly must be a boolean.");
if (typeof typing !== "boolean")
throw new TypeError("options.typing must be a boolean.");
this.aliases = aliases;

@@ -120,2 +199,6 @@ const { flagWords, optionFlagWords } = Array.isArray(args)

exports.default = Command;
/**
* @typedef {ApplicationCommandOptionType} VSCodePleaseStopRemovingMyImports
* @internal
*/
//# sourceMappingURL=Command.js.map

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

* Whether or not to assign `message.util`.
* @default false
*/

@@ -555,3 +556,4 @@ commandUtil?: boolean;

*/
export declare type SlashResolveTypes = "Boolean" | "Channel" | "String" | "Integer" | "Number" | "User" | "Member" | "Role" | "Mentionable" | "Message";
declare const slashResolvable: readonly ["Boolean", "Channel", "String", "Integer", "Number", "User", "Member", "Role", "Mentionable"];
export declare type SlashResolveType = typeof slashResolvable[number];
export {};

@@ -558,0 +560,0 @@ /**

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -11,3 +30,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const Constants_js_1 = require("../../util/Constants.js");
const Util_js_1 = __importDefault(require("../../util/Util.js"));
const Util_js_1 = __importStar(require("../../util/Util.js"));
const AkairoHandler_js_1 = __importDefault(require("../AkairoHandler.js"));

@@ -27,7 +46,50 @@ const ContextMenuCommandHandler_js_1 = __importDefault(require("../contextMenuCommands/ContextMenuCommandHandler.js"));

*/
// eslint-disable-next-line complexity
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 ?? {};
const { directory, classToHandle = Command_1.default, extensions = [".js", ".ts"], automateCategories, loadFilter, blockClient = true, blockBots = true, fetchMembers = false, handleEdits = false, storeMessages = false, commandUtil = false, 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)) {
throw new AkairoError_js_1.default("INVALID_CLASS_TO_HANDLE", classToHandle.name, Command_1.default.name);
}
if (typeof blockClient !== "boolean")
throw new TypeError("options.blockClient must be a boolean.");
if (typeof blockBots !== "boolean")
throw new TypeError("options.blockBots must be a boolean.");
if (typeof fetchMembers !== "boolean")
throw new TypeError("options.fetchMembers must be a boolean.");
if (typeof handleEdits !== "boolean")
throw new TypeError("options.handleEdits must be a boolean.");
if (typeof storeMessages !== "boolean")
throw new TypeError("options.storeMessages must be a boolean.");
if (typeof commandUtil !== "boolean")
throw new TypeError("options.commandUtil must be a boolean.");
if (typeof commandUtilLifetime !== "number")
throw new TypeError("options.commandUtilLifetime must be a number.");
if (typeof commandUtilSweepInterval !== "number")
throw new TypeError("options.commandUtilSweepInterval must be a number.");
if (typeof defaultCooldown !== "number")
throw new TypeError("options.defaultCooldown must be a number.");
if (!(0, Util_js_1.isStringArrayStringOrFunc)(ignoreCooldown))
throw new TypeError("options.ignoreCooldown must be a string, an array of strings, or a function.");
if (!(0, Util_js_1.isStringArrayStringOrFunc)(ignorePermissions))
throw new TypeError("options.ignorePermissions must be a string, an array of strings, or a function.");
if (typeof argumentDefaults !== "object")
throw new TypeError("options.argumentDefaults must be an object.");
if (!(0, Util_js_1.isStringArrayStringOrFunc)(prefix))
throw new TypeError("options.prefix must be a string, an array of strings, or a function.");
if (typeof allowMention !== "boolean" && typeof allowMention !== "function")
throw new TypeError("options.allowMention must be a boolean.");
if (aliasReplacement !== undefined && !(aliasReplacement instanceof RegExp))
throw new TypeError("options.aliasReplacement must be a RegExp.");
if (typeof autoDefer !== "boolean")
throw new TypeError("options.autoDefer must be a boolean.");
if (typeof typing !== "boolean")
throw new TypeError("options.typing must be a boolean.");
if (typeof autoRegisterSlashCommands !== "boolean")
throw new TypeError("options.autoRegisterSlashCommands must be a boolean.");
if (typeof execSlash !== "boolean")
throw new TypeError("options.execSlash must be a boolean.");
if (typeof skipBuiltInPostInhibitors !== "boolean")
throw new TypeError("options.skipBuiltInPostInhibitors must be a boolean.");
if (typeof useSlashPermissions !== "boolean")
throw new TypeError("options.useSlashPermissions must be a boolean.");
super(client, {

@@ -47,8 +109,8 @@ directory,

this.prefixes = new discord_js_1.Collection();
this.blockClient = Boolean(blockClient);
this.blockBots = Boolean(blockBots);
this.fetchMembers = Boolean(fetchMembers);
this.handleEdits = Boolean(handleEdits);
this.storeMessages = Boolean(storeMessages);
this.commandUtil = Boolean(commandUtil);
this.blockClient = blockClient;
this.blockBots = blockBots;
this.fetchMembers = fetchMembers;
this.handleEdits = handleEdits;
this.storeMessages = storeMessages;
this.commandUtil = commandUtil;
if ((this.handleEdits || this.storeMessages) && !this.commandUtil)

@@ -537,3 +599,15 @@ throw new AkairoError_js_1.default("COMMAND_UTIL_EXPLICIT");

const originalOption = commandModule.slashOptions?.find(o => o.name === option.name);
const func = Util_js_1.default.pascalToCamelCase(`Get${originalOption?.resolve ?? option.type}`);
const func = `get${originalOption?.resolve ?? AkairoApplicationCommandOptionType[option.type]}`;
if (![
"getBoolean",
"getChannel",
"getString",
"getInteger",
"getNumber",
"getUser",
"getMember",
"getRole",
"getMentionable"
].includes(func))
throw new Error(` ${option.type}`);
convertedOptions[option.name] = interaction.options[func](option.name, false);

@@ -1234,2 +1308,24 @@ }

/**
* Calls the corresponding get function on the {@link CommandInteractionOptionResolver}
*/
const slashResolvable = ["Boolean", "Channel", "String", "Integer", "Number", "User", "Member", "Role", "Mentionable"];
/**
* Used for reverse mapping since discord exports its enums as const enums.
* @internal
*/
var AkairoApplicationCommandOptionType;
(function (AkairoApplicationCommandOptionType) {
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Subcommand"] = 1] = "Subcommand";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["SubcommandGroup"] = 2] = "SubcommandGroup";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["String"] = 3] = "String";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Integer"] = 4] = "Integer";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Boolean"] = 5] = "Boolean";
// eslint-disable-next-line @typescript-eslint/no-shadow
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["User"] = 6] = "User";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Channel"] = 7] = "Channel";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Role"] = 8] = "Role";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Mentionable"] = 9] = "Mentionable";
AkairoApplicationCommandOptionType[AkairoApplicationCommandOptionType["Number"] = 10] = "Number";
})(AkairoApplicationCommandOptionType || (AkairoApplicationCommandOptionType = {}));
/**
* @typedef {CommandInteractionOptionResolver} VSCodePleaseStopRemovingMyImports

@@ -1236,0 +1332,0 @@ * @internal

import type { ArgumentOptions } from "./arguments/Argument.js";
export interface ParserOptions {
separated: boolean;
}
/**

@@ -15,3 +18,4 @@ * Parses content.

/**
* Whether to parse quotes. Defaults to `true`.
* Whether to parse quotes.
* @default true
*/

@@ -26,3 +30,3 @@ quoted: boolean;

*/
constructor({ flagWords, optionFlagWords, quoted, separator }?: ContentParserOptions);
constructor(options?: ContentParserOptions);
/**

@@ -29,0 +33,0 @@ * Parses content.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Constants_js_1 = require("../../util/Constants.js");
const Util_js_1 = __importDefault(require("../../util/Util.js"));
/*

@@ -57,4 +61,4 @@ * Grammar:

class Tokenizer {
constructor(content, options) {
const { flagWords = [], optionFlagWords = [], quoted = true, separator } = options ?? {};
constructor(content, options = {}) {
const { flagWords = [], optionFlagWords = [], quoted = true, separator } = options;
this.content = content;

@@ -66,4 +70,3 @@ this.flagWords = flagWords;

this.position = 0;
// 0 -> Default, 1 -> Quotes (""), 2 -> Special Quotes (“”)
this.state = 0;
this.state = 0 /* Default */;
this.tokens = [];

@@ -104,3 +107,3 @@ }

runFlags() {
if (this.state === 0) {
if (this.state === 0 /* Default */) {
for (const word of this.flagWords) {

@@ -117,3 +120,3 @@ if (this.startsWith(word)) {

runOptionFlags() {
if (this.state === 0) {
if (this.state === 0 /* Default */) {
for (const word of this.optionFlagWords) {

@@ -131,7 +134,7 @@ if (this.startsWith(word)) {

if (this.separator == null && this.quoted && this.startsWith('"')) {
if (this.state === 1) {
this.state = 0;
if (this.state === 1 /* Quotes */) {
this.state = 0 /* Default */;
}
else if (this.state === 0) {
this.state = 1;
else if (this.state === 0 /* Default */) {
this.state = 1 /* Quotes */;
}

@@ -146,4 +149,4 @@ this.addToken("Quote", '"');

if (this.separator == null && this.quoted && this.startsWith('"')) {
if (this.state === 0) {
this.state = 2;
if (this.state === 0 /* Default */) {
this.state = 1 /* SpecialQuotes */;
}

@@ -158,4 +161,4 @@ this.addToken("OpenQuote", '"');

if (this.separator == null && this.quoted && this.startsWith("”")) {
if (this.state === 2) {
this.state = 0;
if (this.state === 1 /* SpecialQuotes */) {
this.state = 0 /* Default */;
}

@@ -177,3 +180,3 @@ this.addToken("EndQuote", "”");

runWord() {
const wordRegex = this.state === 0 ? /^\S+/ : this.state === 1 ? /^[^\s"]+/ : /^[^\s”]+/;
const wordRegex = this.state === 0 /* Default */ ? /^\S+/ : this.state === 1 /* Quotes */ ? /^[^\s"]+/ : /^[^\s”]+/;
const wordMatch = this.match(wordRegex);

@@ -213,3 +216,4 @@ if (wordMatch) {

class Parser {
constructor(tokens, { separated }) {
constructor(tokens, options) {
const { separated } = options;
this.tokens = tokens;

@@ -367,3 +371,12 @@ this.separated = separated;

*/
constructor({ flagWords = [], optionFlagWords = [], quoted = true, separator } = {}) {
constructor(options = {}) {
const { flagWords = [], optionFlagWords = [], quoted = true, separator } = options;
if (!Util_js_1.default.isArrayOf(flagWords, "string"))
throw new TypeError("options.flagWords must be an array of strings.");
if (!Util_js_1.default.isArrayOf(optionFlagWords, "string"))
throw new TypeError("options.optionFlagWords must be an array of strings.");
if (typeof quoted !== "boolean")
throw new TypeError("options.quoted must be a boolean.");
if (separator !== undefined && typeof separator !== "string")
throw new TypeError("options.separator must be a string.");
this.flagWords = flagWords;

@@ -370,0 +383,0 @@ this.flagWords.sort((a, b) => b.length - a.length);

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

import type { ApplicationCommandType, ContextMenuCommandInteraction, Snowflake } from "discord.js";
import { ApplicationCommandType, type ContextMenuCommandInteraction, type Snowflake } from "discord.js";
import type Category from "../../util/Category.js";

@@ -3,0 +3,0 @@ import type AkairoClient from "../AkairoClient.js";

@@ -7,2 +7,3 @@ "use strict";

const AkairoError_js_1 = __importDefault(require("../../util/AkairoError.js"));
const Util_js_1 = __importDefault(require("../../util/Util.js"));
const AkairoModule_js_1 = __importDefault(require("../AkairoModule.js"));

@@ -19,2 +20,12 @@ /**

const { category, guilds, name, ownerOnly, superUserOnly, type } = options;
if (category !== undefined && typeof category !== "string")
throw new TypeError("options.category must be a string.");
if (guilds !== undefined && !Util_js_1.default.isArrayOf(guilds, "string"))
throw new TypeError("options.guilds must be an array of strings.");
if (name !== undefined && typeof name !== "string")
throw new TypeError("options.name must be a string.");
if (ownerOnly !== undefined && typeof ownerOnly !== "boolean")
throw new TypeError("options.ownerOnly must be a boolean");
if (type !== 2 /* User */ && type !== 3 /* Message */)
throw new TypeError("options.type must be either ApplicationCommandType.User or ApplicationCommandType.Message.");
super(id, { category });

@@ -21,0 +32,0 @@ this.guilds = guilds;

@@ -18,2 +18,10 @@ "use strict";

const { category, reason = "", type = "post", priority = 0 } = options ?? {};
if (reason !== undefined && typeof reason !== "string")
throw new TypeError("options.reason must be a string.");
if (typeof reason !== "string")
throw new TypeError("options.type must be a string.");
if (!["post", "all", "pre"].includes(type))
throw new TypeError('options.type must be either "post", "all" or "pre".');
if (typeof priority !== "number")
throw new TypeError("options.priority must be a number.");
super(id, { category });

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

/// <reference types="node" />
import type EventEmitter from "events";
import EventEmitter from "events";
import type Category from "../../util/Category.js";

@@ -78,3 +78,5 @@ import type AkairoClient from "../AkairoClient.js";

}
export declare type ListenerType = "on" | "once" | "prependListener" | "prependOnceListener";
declare const listenersTypes: readonly ["on", "once", "prependListener", "prependOnceListener"];
export declare type ListenerType = typeof listenersTypes[number];
export {};
//# sourceMappingURL=Listener.d.ts.map

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

Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable func-names, @typescript-eslint/no-unused-vars */
const events_1 = __importDefault(require("events"));
const AkairoError_js_1 = __importDefault(require("../../util/AkairoError.js"));

@@ -19,2 +21,8 @@ const AkairoModule_js_1 = __importDefault(require("../AkairoModule.js"));

const { category, emitter, event, type = "on" } = options;
if (typeof emitter !== "string" && !(emitter instanceof events_1.default))
throw new TypeError("options.emitter must be a string or an EventEmitter.");
if (typeof event !== "string")
throw new TypeError("options.event must be a string.");
if (!listenersTypes.includes(type))
throw new TypeError(`options.type must be one of ${listenersTypes.map(v => `"${v}"`).join(", ")}.`);
super(id, { category });

@@ -34,2 +42,3 @@ this.emitter = emitter;

exports.default = Listener;
const listenersTypes = ["on", "once", "prependListener", "prependOnceListener"];
//# sourceMappingURL=Listener.js.map

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

*/
constructor(id, options) {
const { category, delay, runOnStart = false } = options ?? {};
constructor(id, options = {}) {
const { category, delay, runOnStart = false } = options;
if (delay !== undefined && typeof delay !== "number")
throw new TypeError("options.delay must be a number.");
if (typeof runOnStart !== "boolean")
throw new TypeError("options.runOnStart must be a boolean.");
super(id, { category });

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

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

static pascalToCamelCase(str: string): string;
/**
* Checks if `array` is an array and its elements are typeof of `type`
* @param array The array to check.
* @param type The type to check the elements' type against.
* @returns Whether the array is an array and its elements are typeof of `type`.
*/
static isArrayOf<T>(array: T[], type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"): boolean;
}
/**
* Checks if a value is a string, an array of strings, or a function
* @internal
*/
export declare function isStringArrayStringOrFunc(value: any): value is string | string[] | ((...args: any[]) => any);
export interface DeepEqualsOptions {

@@ -68,0 +80,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isStringArrayStringOrFunc = void 0;
/**

@@ -138,4 +139,23 @@ * Akairo Utilities.

}
/**
* Checks if `array` is an array and its elements are typeof of `type`
* @param array The array to check.
* @param type The type to check the elements' type against.
* @returns Whether the array is an array and its elements are typeof of `type`.
*/
static isArrayOf(array, type) {
if (!Array.isArray(array))
return false;
return array.every(item => typeof item === type);
}
}
exports.default = Util;
/**
* Checks if a value is a string, an array of strings, or a function
* @internal
*/
function isStringArrayStringOrFunc(value) {
return typeof value === "string" || typeof value === "function" || Util.isArrayOf(value, "string");
}
exports.isStringArrayStringOrFunc = isStringArrayStringOrFunc;
//# sourceMappingURL=Util.js.map
{
"name": "@notenoughupdates/discord-akairo",
"version": "9.0.10-dev.1642853858.d99b3b4",
"version": "9.0.10-dev.1642902587.27cb93d",
"description": "A highly customizable bot framework for Discord.js.",

@@ -5,0 +5,0 @@ "main": "./dist/src/index.js",

@@ -53,3 +53,3 @@ import "source-map-support/register";

RegisterInteractionCommandError,
SlashResolveTypes
SlashResolveType
} from "./struct/commands/CommandHandler";

@@ -188,3 +188,3 @@ import CommandUtil from "./struct/commands/CommandUtil";

SlashPermissionsSupplier,
SlashResolveTypes,
SlashResolveType as SlashResolveTypes,
StringData,

@@ -191,0 +191,0 @@ TaskHandlerEvents,

@@ -9,2 +9,3 @@ import { Collection } from "discord.js";

import { AkairoHandlerEvents } from "../util/Constants.js";
import Util from "../util/Util.js";
import type AkairoClient from "./AkairoClient.js";

@@ -71,2 +72,11 @@ import AkairoModule from "./AkairoModule.js";

} = options ?? {};
if (typeof directory !== "string") throw new TypeError("options.directory must be a string.");
if (classToHandle !== AkairoModule && !(classToHandle.prototype instanceof AkairoModule))
throw new TypeError("options.classToHandle must be a class that extends AkairoModule.");
if (!(extensions instanceof Set) && !Util.isArrayOf(extensions, "string"))
throw new TypeError("options.extensions must be an array of strings or a Set.");
if (typeof automateCategories !== "boolean") throw new TypeError("options.automateCategories must be a boolean.");
if (typeof loadFilter !== "function") throw new TypeError("options.loadFilter must be a function.");
super();

@@ -73,0 +83,0 @@

@@ -46,2 +46,4 @@ import type Category from "../util/Category.js";

if (typeof category !== "string") throw new TypeError("options.category must be a string.");
this.id = id;

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

@@ -26,3 +26,3 @@ import type {

import { ArgumentMatches, ArgumentTypes } from "../../../util/Constants.js";
import Util from "../../../util/Util.js";
import Util, { isStringArrayStringOrFunc } from "../../../util/Util.js";
import type AkairoClient from "../../AkairoClient.js";

@@ -95,3 +95,3 @@ import ContextMenuCommand from "../../contextMenuCommands/ContextMenuCommand.js";

*/
public declare index?: number;
public declare index: number | null;

@@ -111,3 +111,3 @@ /**

*/
public declare modifyOtherwise: OtherwiseContentModifier;
public declare modifyOtherwise: OtherwiseContentModifier | null;

@@ -122,3 +122,3 @@ /**

*/
public declare otherwise?: string | MessagePayload | MessageOptions | OtherwiseContentSupplier;
public declare otherwise: string | MessagePayload | MessageOptions | OtherwiseContentSupplier | null;

@@ -128,3 +128,3 @@ /**

*/
public declare prompt?: ArgumentPromptOptions | boolean;
public declare prompt: ArgumentPromptOptions | boolean | null;

@@ -149,13 +149,33 @@ /**

type = ArgumentTypes.STRING,
flag = null!,
flag = null,
multipleFlags = false,
index = null!,
index = null,
unordered = false,
limit = Infinity,
prompt = null!,
prompt = null,
default: defaultValue = null,
otherwise = null!,
modifyOtherwise = null!
otherwise = null,
modifyOtherwise = null
} = options;
if (!Object.values(ArgumentMatches).includes(match))
throw new TypeError(
`options.match must one of ${Object.values(ArgumentMatches)
.map(v => `"${v}"`)
.join(", ")}.`
);
if (flag !== null && !isStringArrayStringOrFunc(isStringArrayStringOrFunc))
throw new TypeError("options.flag must be a null, a string, or an array of strings.");
if (typeof multipleFlags !== "boolean") throw new TypeError("options.multipleFlags must be a boolean.");
if (index !== null && typeof index !== "number") throw new TypeError("options.index must be a number or null.");
if (typeof unordered !== "boolean" && typeof unordered !== "number" && !Util.isArrayOf(unordered, "number"))
throw new TypeError("options.unordered must be a boolean, number, or array of numbers.");
if (typeof limit !== "number") throw new TypeError("options.limit must be a number.");
if (prompt !== null && typeof prompt !== "boolean" && typeof prompt !== "object")
throw new TypeError("options.prompt must be a boolean, object, or null.");
if (otherwise !== null && typeof otherwise !== "string" && typeof otherwise !== "function" && typeof otherwise !== "object")
throw new TypeError("options.otherwise must be a string, function, object, or null.");
if (modifyOtherwise !== null && typeof modifyOtherwise !== "function")
throw new TypeError("options.modifyOtherwise must be a function or null.");
this.command = command;

@@ -166,9 +186,9 @@ this.match = match;

this.multipleFlags = multipleFlags;
this.index = index!;
this.index = index;
this.unordered = unordered;
this.limit = limit;
this.prompt = prompt!;
this.prompt = prompt;
this.default = typeof defaultValue === "function" ? defaultValue.bind(this) : defaultValue;
this.otherwise = typeof otherwise === "function" ? otherwise.bind(this) : otherwise!;
this.modifyOtherwise = modifyOtherwise!;
this.otherwise = typeof otherwise === "function" ? otherwise.bind(this) : otherwise;
this.modifyOtherwise = modifyOtherwise;
}

@@ -175,0 +195,0 @@

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

ApplicationCommandNumericOptionData,
ApplicationCommandOptionType,
ApplicationCommandPermissionData,

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

import type Category from "../../util/Category.js";
import Util, { isStringArrayStringOrFunc } from "../../util/Util.js";
import type AkairoClient from "../AkairoClient.js";

@@ -26,3 +28,3 @@ import AkairoModule, { AkairoModuleOptions } from "../AkairoModule.js";

import ArgumentRunner, { ArgumentRunnerState } from "./arguments/ArgumentRunner.js";
import CommandHandler, { IgnoreCheckPredicate, PrefixSupplier, SlashResolveTypes } from "./CommandHandler.js";
import CommandHandler, { IgnoreCheckPredicate, PrefixSupplier, SlashResolveType } from "./CommandHandler.js";
import ContentParser, { ContentParserResult } from "./ContentParser.js";

@@ -221,2 +223,3 @@ import type Flag from "./Flag.js";

*/
// eslint-disable-next-line complexity
constructor(id: string, options?: CommandOptions) {

@@ -259,2 +262,43 @@ super(id, { category: options?.category });

} = options ?? {};
if (!Util.isArrayOf(aliases, "string")) throw new TypeError("options.aliases must be an array of strings.");
if (typeof args !== "function" && !Util.isArrayOf(args, "object"))
throw new TypeError("options.args must be an array of argument objects or a function.");
if (typeof argumentDefaults !== "object") throw new TypeError("options.argumentDefaults must be an object.");
if (typeof before !== "function") throw new TypeError("options.before must be a function.");
if (!(["guild", "dm", null] as const).includes(channel))
throw new TypeError('options.channel must be either "guild" or "dm" or null.');
if (typeof condition !== "function") throw new TypeError("options.condition must be a function.");
if (typeof cooldown !== "number" && cooldown !== null) throw new TypeError("options.cooldown must be a number or null.");
if (typeof editable !== "boolean") throw new TypeError("options.editable must be a boolean.");
if (!Util.isArrayOf(flags, "string")) throw new TypeError("options.flags must be an array of strings.");
if (ignoreCooldown !== undefined && !isStringArrayStringOrFunc(ignoreCooldown))
throw new TypeError("options.ignoreCooldown must be a string, function, or array of strings.");
if (ignorePermissions !== undefined && !isStringArrayStringOrFunc(ignorePermissions))
throw new TypeError("options.ignorePermissions must be a string, function, or array of strings.");
if (lock !== undefined && typeof lock !== "function" && !(["channel", "guild", "user"] as const).includes(lock))
throw new TypeError("options.lock must be a function or a string with a value of 'channel', 'guild', or 'user'.");
if (typeof onlyNsfw !== "boolean") throw new TypeError("options.onlyNsfw must be a boolean.");
if (!Util.isArrayOf(optionFlags, "string")) throw new TypeError("options.optionFlags must be an array of strings.");
if (typeof ownerOnly !== "boolean") throw new TypeError("options.ownerOnly must be a boolean.");
if (prefix !== undefined && !isStringArrayStringOrFunc(prefix))
throw new TypeError("options.prefix must be a string, function, or array of strings.");
if (typeof quoted !== "boolean") throw new TypeError("options.quoted must be a boolean.");
if (typeof ratelimit !== "number") throw new TypeError("options.ratelimit must be a number.");
if (regex !== undefined && typeof regex !== "function" && !(regex instanceof RegExp))
throw new TypeError("options.regex must be a function or a RegExp.");
if (separator !== undefined && typeof separator !== "string") throw new TypeError("options.separator must be a string.");
if (typeof slash !== "boolean") throw new TypeError("options.slash must be a boolean.");
if (slashDefaultPermission && typeof slashDefaultPermission !== "boolean")
throw new TypeError("options.slashDefaultPermission must be a boolean.");
if (typeof slashEphemeral !== "boolean") throw new TypeError("options.slashEphemeral must be a boolean.");
if (!Util.isArrayOf(slashGuilds, "string")) throw new TypeError("options.slashGuilds must be an array of strings.");
if (typeof slashOnly !== "boolean") throw new TypeError("options.slashOnly must be a boolean.");
if (slashOptions !== undefined && !Util.isArrayOf(slashOptions, "object"))
throw new TypeError("options.slashOptions must be an array of objects.");
if (slashPermissions !== undefined && typeof slashPermissions !== "function" && !Util.isArrayOf(slashPermissions, "object"))
throw new TypeError("options.slashPermissions must be an array of objects or a function.");
if (typeof superUserOnly !== "boolean") throw new TypeError("options.superUserOnly must be a boolean.");
if (typeof typing !== "boolean") throw new TypeError("options.typing must be a boolean.");
this.aliases = aliases;

@@ -647,5 +691,5 @@ const { flagWords, optionFlagWords } = Array.isArray(args)

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -657,5 +701,5 @@

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -667,5 +711,5 @@

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -677,5 +721,5 @@

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -687,5 +731,5 @@

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
}

@@ -706,5 +750,10 @@

*
* ex. get the resolved member object when the type is `USER`
* ex. get the resolved member object when the type is {@link ApplicationCommandOptionType.User}
*/
resolve?: SlashResolveTypes;
resolve?: SlashResolveType;
};
/**
* @typedef {ApplicationCommandOptionType} VSCodePleaseStopRemovingMyImports
* @internal
*/

@@ -30,3 +30,3 @@ import {

import { BuiltInReasons, CommandHandlerEvents } from "../../util/Constants.js";
import Util from "../../util/Util.js";
import Util, { isStringArrayStringOrFunc } from "../../util/Util.js";
import AkairoClient from "../AkairoClient.js";

@@ -229,2 +229,3 @@ import AkairoHandler, { AkairoHandlerOptions, LoadPredicate } from "../AkairoHandler.js";

*/
// eslint-disable-next-line complexity
public constructor(client: AkairoClient, options: CommandHandlerOptions) {

@@ -242,3 +243,3 @@ const {

storeMessages = false,
commandUtil,
commandUtil = false,
commandUtilLifetime = 3e5,

@@ -264,2 +265,30 @@ commandUtilSweepInterval = 3e5,

}
if (typeof blockClient !== "boolean") throw new TypeError("options.blockClient must be a boolean.");
if (typeof blockBots !== "boolean") throw new TypeError("options.blockBots must be a boolean.");
if (typeof fetchMembers !== "boolean") throw new TypeError("options.fetchMembers must be a boolean.");
if (typeof handleEdits !== "boolean") throw new TypeError("options.handleEdits must be a boolean.");
if (typeof storeMessages !== "boolean") throw new TypeError("options.storeMessages must be a boolean.");
if (typeof commandUtil !== "boolean") throw new TypeError("options.commandUtil must be a boolean.");
if (typeof commandUtilLifetime !== "number") throw new TypeError("options.commandUtilLifetime must be a number.");
if (typeof commandUtilSweepInterval !== "number") throw new TypeError("options.commandUtilSweepInterval must be a number.");
if (typeof defaultCooldown !== "number") throw new TypeError("options.defaultCooldown must be a number.");
if (!isStringArrayStringOrFunc(ignoreCooldown))
throw new TypeError("options.ignoreCooldown must be a string, an array of strings, or a function.");
if (!isStringArrayStringOrFunc(ignorePermissions))
throw new TypeError("options.ignorePermissions must be a string, an array of strings, or a function.");
if (typeof argumentDefaults !== "object") throw new TypeError("options.argumentDefaults must be an object.");
if (!isStringArrayStringOrFunc(prefix))
throw new TypeError("options.prefix must be a string, an array of strings, or a function.");
if (typeof allowMention !== "boolean" && typeof allowMention !== "function")
throw new TypeError("options.allowMention must be a boolean.");
if (aliasReplacement !== undefined && !(aliasReplacement instanceof RegExp))
throw new TypeError("options.aliasReplacement must be a RegExp.");
if (typeof autoDefer !== "boolean") throw new TypeError("options.autoDefer must be a boolean.");
if (typeof typing !== "boolean") throw new TypeError("options.typing must be a boolean.");
if (typeof autoRegisterSlashCommands !== "boolean")
throw new TypeError("options.autoRegisterSlashCommands must be a boolean.");
if (typeof execSlash !== "boolean") throw new TypeError("options.execSlash must be a boolean.");
if (typeof skipBuiltInPostInhibitors !== "boolean")
throw new TypeError("options.skipBuiltInPostInhibitors must be a boolean.");
if (typeof useSlashPermissions !== "boolean") throw new TypeError("options.useSlashPermissions must be a boolean.");

@@ -281,8 +310,8 @@ super(client, {

this.prefixes = new Collection();
this.blockClient = Boolean(blockClient);
this.blockBots = Boolean(blockBots);
this.fetchMembers = Boolean(fetchMembers);
this.handleEdits = Boolean(handleEdits);
this.storeMessages = Boolean(storeMessages);
this.commandUtil = Boolean(commandUtil);
this.blockClient = blockClient;
this.blockBots = blockBots;
this.fetchMembers = fetchMembers;
this.handleEdits = handleEdits;
this.storeMessages = storeMessages;
this.commandUtil = commandUtil;
if ((this.handleEdits || this.storeMessages) && !this.commandUtil) throw new AkairoError("COMMAND_UTIL_EXPLICIT");

@@ -803,4 +832,19 @@ this.commandUtilLifetime = commandUtilLifetime;

const func = Util.pascalToCamelCase(`Get${originalOption?.resolve ?? option.type}`) as GetFunctions;
const func = `get${originalOption?.resolve ?? AkairoApplicationCommandOptionType[option.type]}` as GetFunction;
if (
!(
[
"getBoolean",
"getChannel",
"getString",
"getInteger",
"getNumber",
"getUser",
"getMember",
"getRole",
"getMentionable"
] as const
).includes(func)
)
throw new Error(` ${option.type}`);
convertedOptions[option.name] = interaction.options[func](option.name, false);

@@ -1671,2 +1715,3 @@ }

* Whether or not to assign `message.util`.
* @default false
*/

@@ -1830,26 +1875,8 @@ commandUtil?: boolean;

*/
export type SlashResolveTypes =
| "Boolean"
| "Channel"
| "String"
| "Integer"
| "Number"
| "User"
| "Member"
| "Role"
| "Mentionable"
| "Message";
type GetFunctions =
| "getBoolean"
| "getChannel"
| "getString"
| "getInteger"
| "getNumber"
| "getUser"
| "getMember"
| "getRole"
| "getMentionable";
// | "getMessage";
const slashResolvable = ["Boolean", "Channel", "String", "Integer", "Number", "User", "Member", "Role", "Mentionable"] as const;
export type SlashResolveType = typeof slashResolvable[number];
type GetFunction = `get${SlashResolveType}`;
type ConvertedOptionsType = {

@@ -1870,4 +1897,22 @@ [key: string]:

/**
* Used for reverse mapping since discord exports its enums as const enums.
* @internal
*/
enum AkairoApplicationCommandOptionType {
Subcommand = ApplicationCommandOptionType.Subcommand,
SubcommandGroup = ApplicationCommandOptionType.SubcommandGroup,
String = ApplicationCommandOptionType.String,
Integer = ApplicationCommandOptionType.Integer,
Boolean = ApplicationCommandOptionType.Boolean,
// eslint-disable-next-line @typescript-eslint/no-shadow
User = ApplicationCommandOptionType.User,
Channel = ApplicationCommandOptionType.Channel,
Role = ApplicationCommandOptionType.Role,
Mentionable = ApplicationCommandOptionType.Mentionable,
Number = ApplicationCommandOptionType.Number
}
/**
* @typedef {CommandInteractionOptionResolver} VSCodePleaseStopRemovingMyImports
* @internal
*/
import { ArgumentMatches } from "../../util/Constants.js";
import Util from "../../util/Util.js";
import type { ArgumentOptions } from "./arguments/Argument.js";

@@ -64,7 +65,7 @@

public declare position: number;
public declare state: number;
public declare state: TokenizerState;
public declare tokens: any[];
public constructor(content: string, options?: ContentParserOptions) {
const { flagWords = [], optionFlagWords = [], quoted = true, separator } = options ?? {};
public constructor(content: string, options: ContentParserOptions = {}) {
const { flagWords = [], optionFlagWords = [], quoted = true, separator } = options;

@@ -77,4 +78,3 @@ this.content = content;

this.position = 0;
// 0 -> Default, 1 -> Quotes (""), 2 -> Special Quotes (“”)
this.state = 0;
this.state = TokenizerState.Default;
this.tokens = [];

@@ -134,3 +134,3 @@ }

public runFlags() {
if (this.state === 0) {
if (this.state === TokenizerState.Default) {
for (const word of this.flagWords) {

@@ -149,3 +149,3 @@ if (this.startsWith(word)) {

public runOptionFlags() {
if (this.state === 0) {
if (this.state === TokenizerState.Default) {
for (const word of this.optionFlagWords) {

@@ -165,6 +165,6 @@ if (this.startsWith(word)) {

if (this.separator == null && this.quoted && this.startsWith('"')) {
if (this.state === 1) {
this.state = 0;
} else if (this.state === 0) {
this.state = 1;
if (this.state === TokenizerState.Quotes) {
this.state = TokenizerState.Default;
} else if (this.state === TokenizerState.Default) {
this.state = TokenizerState.Quotes;
}

@@ -182,4 +182,4 @@

if (this.separator == null && this.quoted && this.startsWith('"')) {
if (this.state === 0) {
this.state = 2;
if (this.state === TokenizerState.Default) {
this.state = TokenizerState.SpecialQuotes;
}

@@ -197,4 +197,4 @@

if (this.separator == null && this.quoted && this.startsWith("”")) {
if (this.state === 2) {
this.state = 0;
if (this.state === TokenizerState.SpecialQuotes) {
this.state = TokenizerState.Default;
}

@@ -221,3 +221,4 @@

public runWord() {
const wordRegex = this.state === 0 ? /^\S+/ : this.state === 1 ? /^[^\s"]+/ : /^[^\s”]+/;
const wordRegex =
this.state === TokenizerState.Default ? /^\S+/ : this.state === TokenizerState.Quotes ? /^[^\s"]+/ : /^[^\s”]+/;

@@ -264,2 +265,10 @@ const wordMatch = this.match(wordRegex);

const enum TokenizerState {
Default = 0,
/** ("") */
Quotes = 1,
/** (“”) */
SpecialQuotes = 1
}
class Parser {

@@ -283,3 +292,5 @@ public declare tokens: any;

public constructor(tokens: any[], { separated }: { separated: boolean }) {
public constructor(tokens: any[], options: ParserOptions) {
const { separated } = options;
this.tokens = tokens;

@@ -457,2 +468,6 @@ this.separated = separated;

export interface ParserOptions {
separated: boolean;
}
/**

@@ -473,3 +488,4 @@ * Parses content.

/**
* Whether to parse quotes. Defaults to `true`.
* Whether to parse quotes.
* @default true
*/

@@ -486,3 +502,10 @@ public declare quoted: boolean;

*/
public constructor({ flagWords = [], optionFlagWords = [], quoted = true, separator }: ContentParserOptions = {}) {
public constructor(options: ContentParserOptions = {}) {
const { flagWords = [], optionFlagWords = [], quoted = true, separator } = options;
if (!Util.isArrayOf(flagWords, "string")) throw new TypeError("options.flagWords must be an array of strings.");
if (!Util.isArrayOf(optionFlagWords, "string")) throw new TypeError("options.optionFlagWords must be an array of strings.");
if (typeof quoted !== "boolean") throw new TypeError("options.quoted must be a boolean.");
if (separator !== undefined && typeof separator !== "string") throw new TypeError("options.separator must be a string.");
this.flagWords = flagWords;

@@ -489,0 +512,0 @@ this.flagWords.sort((a, b) => b.length - a.length);

/* eslint-disable func-names, @typescript-eslint/no-unused-vars */
import type { ApplicationCommandType, ContextMenuCommandInteraction, Snowflake } from "discord.js";
import { ApplicationCommandType, type ContextMenuCommandInteraction, type Snowflake } from "discord.js";
import AkairoError from "../../util/AkairoError.js";
import type Category from "../../util/Category.js";
import Util from "../../util/Util.js";
import type AkairoClient from "../AkairoClient.js";

@@ -65,3 +66,12 @@ import AkairoModule, { AkairoModuleOptions } from "../AkairoModule.js";

if (category !== undefined && typeof category !== "string") throw new TypeError("options.category must be a string.");
if (guilds !== undefined && !Util.isArrayOf(guilds, "string"))
throw new TypeError("options.guilds must be an array of strings.");
if (name !== undefined && typeof name !== "string") throw new TypeError("options.name must be a string.");
if (ownerOnly !== undefined && typeof ownerOnly !== "boolean") throw new TypeError("options.ownerOnly must be a boolean");
if (type !== ApplicationCommandType.User && type !== ApplicationCommandType.Message)
throw new TypeError("options.type must be either ApplicationCommandType.User or ApplicationCommandType.Message.");
super(id, { category });
this.guilds = guilds;

@@ -68,0 +78,0 @@ this.name = name;

@@ -62,2 +62,8 @@ /* eslint-disable @typescript-eslint/no-unused-vars */

if (reason !== undefined && typeof reason !== "string") throw new TypeError("options.reason must be a string.");
if (typeof reason !== "string") throw new TypeError("options.type must be a string.");
if (!(["post", "all", "pre"] as const).includes(type))
throw new TypeError('options.type must be either "post", "all" or "pre".');
if (typeof priority !== "number") throw new TypeError("options.priority must be a number.");
super(id, { category });

@@ -64,0 +70,0 @@

/* eslint-disable func-names, @typescript-eslint/no-unused-vars */
import type EventEmitter from "events";
import EventEmitter from "events";
import AkairoError from "../../util/AkairoError.js";

@@ -55,2 +55,8 @@ import type Category from "../../util/Category.js";

if (typeof emitter !== "string" && !(emitter instanceof EventEmitter))
throw new TypeError("options.emitter must be a string or an EventEmitter.");
if (typeof event !== "string") throw new TypeError("options.event must be a string.");
if (!listenersTypes.includes(type))
throw new TypeError(`options.type must be one of ${listenersTypes.map(v => `"${v}"`).join(", ")}.`);
super(id, { category });

@@ -104,2 +110,3 @@ this.emitter = emitter;

export type ListenerType = "on" | "once" | "prependListener" | "prependOnceListener";
const listenersTypes = ["on", "once", "prependListener", "prependOnceListener"] as const;
export type ListenerType = typeof listenersTypes[number];

@@ -46,5 +46,8 @@ /* 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;
if (delay !== undefined && typeof delay !== "number") throw new TypeError("options.delay must be a number.");
if (typeof runOnStart !== "boolean") throw new TypeError("options.runOnStart must be a boolean.");
super(id, { category });

@@ -51,0 +54,0 @@ this.delay = delay;

@@ -154,4 +154,26 @@ /* eslint-disable @typescript-eslint/ban-types */

}
/**
* Checks if `array` is an array and its elements are typeof of `type`
* @param array The array to check.
* @param type The type to check the elements' type against.
* @returns Whether the array is an array and its elements are typeof of `type`.
*/
public static isArrayOf<T>(
array: T[],
type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
): boolean {
if (!Array.isArray(array)) return false;
return array.every(item => typeof item === type);
}
}
/**
* Checks if a value is a string, an array of strings, or a function
* @internal
*/
export function isStringArrayStringOrFunc(value: any): value is string | string[] | ((...args: any[]) => any) {
return typeof value === "string" || typeof value === "function" || Util.isArrayOf(value, "string");
}
export interface DeepEqualsOptions {

@@ -158,0 +180,0 @@ /**

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