Archived
more detailed jsdoc documentation (partial commands)
This commit is contained in:
1 parent
5aff535029
commit
95ba89e602
10 files changed
+119
-26
No files matched your search
+41
-15
@@ -12,50 +12,71 @@ import { applicationState } from "../state.js";
|
|||||||
import { InputManager } from "../structures/InputManager.js";
|
import { InputManager } from "../structures/InputManager.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class A representation of CHAT_INPUT command (also known as a slash command)
|
* A representation of CHAT_INPUT command (also known as a slash command)
|
||||||
|
* @class
|
||||||
|
* @extends {PermissionGuildCommand}
|
||||||
*/
|
*/
|
||||||
export class ChatCommand extends PermissionGuildCommand {
|
export class ChatCommand extends PermissionGuildCommand {
|
||||||
|
/**
|
||||||
|
* Subcommands and groups of this command
|
||||||
|
* @type {Array<ChildCommandResolvable>}
|
||||||
|
* @private
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
private readonly _children: ChildCommandResolvable[] = [];
|
private readonly _children: ChildCommandResolvable[] = [];
|
||||||
/**
|
/**
|
||||||
* List of parameters that can passed to this command
|
* List of parameters that can passed to this command
|
||||||
* @type {Array<Parameter<any>>}
|
* @type {Array<Parameter<any>>}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly parameters: Parameter<any>[];
|
public readonly parameters: Parameter<any>[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of different names that can be used to invoke a command (when using prefix interactions)
|
* List of different names that can be used to invoke a command (when using prefix interactions)
|
||||||
* @type {Array<string>}
|
* @type {Array<string>}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly aliases?: string[];
|
public readonly aliases?: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command description displayed in the help message or in slash commands menu (Default description: "No description")
|
* Command description displayed in the help message or in slash commands menu (Default description: "No description")
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly description: string;
|
public readonly description: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command usage displayed in the help message
|
* Command usage displayed in the help message
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly usage?: string;
|
public readonly usage?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this command is visible in the help message (default: true)
|
* Whether this command is visible in the help message (default: true)
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly visible: boolean;
|
public readonly visible: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this command should be registered as a slash command (default: true)
|
* Whether this command should be registered as a slash command (default: true)
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly slash: boolean;
|
public readonly slash: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor ChatCommand constructor
|
* ChatCommand constructor
|
||||||
* @param manager - a manager that this command belongs to
|
* @constructor
|
||||||
* @param options - {@link ChatCommandInit} object containing all options needed to create a {@link ChatCommand}
|
* @param {CommandManager} manager - a manager that this command belongs to
|
||||||
|
* @param {ChatCommandInit} options - {@link ChatCommandInit} object containing all options needed to create a {@link ChatCommand}
|
||||||
*/
|
*/
|
||||||
constructor(manager: CommandManager, options: ChatCommandInit) {
|
constructor(manager: CommandManager, options: ChatCommandInit) {
|
||||||
super(manager, "CHAT", {
|
super(manager, "CHAT", {
|
||||||
@@ -114,7 +135,10 @@ export class ChatCommand extends PermissionGuildCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke the command
|
* Invoke the command
|
||||||
* @param input - input data manager
|
* @param {InputManager} input - input data manager
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
* @public
|
||||||
|
* @async
|
||||||
*/
|
*/
|
||||||
public async start(input: InputManager): Promise<void> {
|
public async start(input: InputManager): Promise<void> {
|
||||||
if (!this.slash && input.interaction instanceof Interaction) {
|
if (!this.slash && input.interaction instanceof Interaction) {
|
||||||
@@ -125,9 +149,10 @@ export class ChatCommand extends PermissionGuildCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches subcommand or subcommand group to this ChatCommand (this makes the base command usable only via prefix interactions)
|
* Attaches subcommand or subcommand group to this ChatCommand (this makes the base command usable only via prefix interactions)
|
||||||
* @param type - subcommand type
|
* @param {T} type - subcommand type
|
||||||
* @param options - initialization options
|
* @param {ChildCommandInit<T>} options - initialization options
|
||||||
* @returns A computed subcommand object
|
* @returns {ChildCommands<T>} A computed subcommand object
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
public append<T extends ChildCommandType>(type: T, options: ChildCommandInit<T>): ChildCommands<T> {
|
public append<T extends ChildCommandType>(type: T, options: ChildCommandInit<T>): ChildCommands<T> {
|
||||||
const command =
|
const command =
|
||||||
@@ -149,9 +174,10 @@ export class ChatCommand extends PermissionGuildCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param options - parameter options
|
* @param {Array<CommandInteractionOption>} options - parameter options
|
||||||
* @param interaction - Discord interaction
|
* @param {Interaction | Message} interaction - Discord interaction
|
||||||
* @returns an {@link InputManager} containing all interaction-related data or *null*
|
* @returns {InputManager} an {@link InputManager} containing all interaction-related data or *null*
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
public fetchSubcommand(options: CommandInteractionOption[], interaction: Interaction | Message): InputManager | null {
|
public fetchSubcommand(options: CommandInteractionOption[], interaction: Interaction | Message): InputManager | null {
|
||||||
if (!this.hasSubCommands) return null;
|
if (!this.hasSubCommands) return null;
|
||||||
@@ -208,9 +234,9 @@ export class ChatCommand extends PermissionGuildCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param name - subcommand name
|
* @param {string} name - subcommand name
|
||||||
* @param group - name of the group (if any)
|
* @param {string} [group] - name of the group (if any)
|
||||||
* @returns a {@link SubCommand} object or *null*
|
* @returns {SubCommand} a {@link SubCommand} object or *null*
|
||||||
*/
|
*/
|
||||||
public getSubcommand(name: string, group?: string): SubCommand | null {
|
public getSubcommand(name: string, group?: string): SubCommand | null {
|
||||||
if (!this.hasSubCommands) return null;
|
if (!this.hasSubCommands) return null;
|
||||||
@@ -228,7 +254,7 @@ export class ChatCommand extends PermissionGuildCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts {@link ChatCommand} instance to object that is recognized by the Discord API
|
* Converts {@link ChatCommand} instance to object that is recognized by the Discord API
|
||||||
* @returns Discord API object
|
* @returns {ChatCommandObject} Discord API object
|
||||||
*/
|
*/
|
||||||
public toObject(): ChatCommandObject {
|
public toObject(): ChatCommandObject {
|
||||||
const obj: ChatCommandObject = {
|
const obj: ChatCommandObject = {
|
||||||
|
|||||||
@@ -17,24 +17,32 @@ export class Command {
|
|||||||
/**
|
/**
|
||||||
* Manager in which this command is registered
|
* Manager in which this command is registered
|
||||||
* @type {CommandManager}
|
* @type {CommandManager}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly manager: CommandManager;
|
public readonly manager: CommandManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command name
|
* Command name
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly name: string;
|
public readonly name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CommandBot's internal command type
|
* CommandBot's internal command type
|
||||||
* @type {CommandType}
|
* @type {CommandType}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly type: CommandType;
|
public readonly type: CommandType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discord API default_permission
|
* Discord API default_permission
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly default_permission: boolean;
|
public readonly default_permission: boolean;
|
||||||
|
|
||||||
@@ -62,6 +70,7 @@ export class Command {
|
|||||||
/**
|
/**
|
||||||
* Converts a command instance to an {@link APICommandObject}
|
* Converts a command instance to an {@link APICommandObject}
|
||||||
* @returns {APICommandObject} An object that is accepted by the Discord API
|
* @returns {APICommandObject} An object that is accepted by the Discord API
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
public toObject(): APICommandObject {
|
public toObject(): APICommandObject {
|
||||||
return {
|
return {
|
||||||
@@ -74,6 +83,7 @@ export class Command {
|
|||||||
* Check base command type
|
* Check base command type
|
||||||
* @param {BaseCommandType} type - base command type
|
* @param {BaseCommandType} type - base command type
|
||||||
* @returns {boolean} Whether this command can be used as the given type
|
* @returns {boolean} Whether this command can be used as the given type
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
public isBaseCommandType<T extends BaseCommandType>(type: T): this is BaseCommands<T> {
|
public isBaseCommandType<T extends BaseCommandType>(type: T): this is BaseCommands<T> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -113,6 +123,7 @@ export class Command {
|
|||||||
* Checks command type
|
* Checks command type
|
||||||
* @param {CommandType} type - command type
|
* @param {CommandType} type - command type
|
||||||
* @returns {boolean} Whether this command can be used as the given type
|
* @returns {boolean} Whether this command can be used as the given type
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
public isCommandType<T extends CommandType>(type: T): this is Commands<T> {
|
public isCommandType<T extends CommandType>(type: T): this is Commands<T> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -139,6 +150,7 @@ export class Command {
|
|||||||
* Check child command type
|
* Check child command type
|
||||||
* @param {ChildCommandType} type - child command type
|
* @param {ChildCommandType} type - child command type
|
||||||
* @returns {boolean} Whether this command can be used as a child command of the given type
|
* @returns {boolean} Whether this command can be used as a child command of the given type
|
||||||
|
* @public
|
||||||
*/
|
*/
|
||||||
public isChildCommandType<T extends ChildCommandType>(type: T): this is ChildCommands<T> {
|
public isChildCommandType<T extends ChildCommandType>(type: T): this is ChildCommands<T> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -9,16 +9,21 @@ import { InputManager } from "../../structures/InputManager.js";
|
|||||||
/**
|
/**
|
||||||
* Function (executable) command
|
* Function (executable) command
|
||||||
* @class
|
* @class
|
||||||
|
* @extends {Command}
|
||||||
*/
|
*/
|
||||||
export class FunctionCommand extends Command {
|
export class FunctionCommand extends Command {
|
||||||
/**
|
/**
|
||||||
* Command function (called on command execution)
|
* Command function (called on command execution)
|
||||||
* @type {CommandFunction}
|
* @type {CommandFunction}
|
||||||
|
* @private
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
private readonly _function: CommandFunction;
|
private readonly _function: CommandFunction;
|
||||||
/**
|
/**
|
||||||
* Whether a SUCCESS message should be sent after executing the command function (when there is no other reply)
|
* Whether a SUCCESS message should be sent after executing the command function (when there is no other reply)
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly announceSuccess: boolean;
|
public readonly announceSuccess: boolean;
|
||||||
|
|
||||||
@@ -48,6 +53,8 @@ export class FunctionCommand extends Command {
|
|||||||
* Invoke the command
|
* Invoke the command
|
||||||
* @param {InputManager} input - input data manager
|
* @param {InputManager} input - input data manager
|
||||||
* @returns {Promise<void>} A *Promise* that resolves after the function command is completed
|
* @returns {Promise<void>} A *Promise* that resolves after the function command is completed
|
||||||
|
* @public
|
||||||
|
* @async
|
||||||
*/
|
*/
|
||||||
public async start(input: InputManager): Promise<void> {
|
public async start(input: InputManager): Promise<void> {
|
||||||
if (input.interaction instanceof Interaction && !input.interaction.isCommand() && !input.interaction.isContextMenu()) throw new TypeError(`Interaction not recognized`);
|
if (input.interaction instanceof Interaction && !input.interaction.isCommand() && !input.interaction.isContextMenu()) throw new TypeError(`Interaction not recognized`);
|
||||||
@@ -59,6 +66,9 @@ export class FunctionCommand extends Command {
|
|||||||
* Reply handler
|
* Reply handler
|
||||||
* @param {Message | Interaction} interaction - Discord interaction object
|
* @param {Message | Interaction} interaction - Discord interaction object
|
||||||
* @param {void | string | MessageEmbed | ReplyMessageOptions} result - result of command function execution
|
* @param {void | string | MessageEmbed | ReplyMessageOptions} result - result of command function execution
|
||||||
|
* @return {Promise<void>}
|
||||||
|
* @private
|
||||||
|
* @async
|
||||||
*/
|
*/
|
||||||
private async handleReply(interaction: Message | Interaction, result: void | string | MessageEmbed | ReplyMessageOptions) {
|
private async handleReply(interaction: Message | Interaction, result: void | string | MessageEmbed | ReplyMessageOptions) {
|
||||||
if (interaction instanceof Interaction && !interaction.isCommand() && !interaction.isContextMenu()) throw new TypeError(`Interaction not recognized`);
|
if (interaction instanceof Interaction && !interaction.isCommand() && !interaction.isContextMenu()) throw new TypeError(`Interaction not recognized`);
|
||||||
|
|||||||
@@ -7,17 +7,22 @@ import { InputManager } from "../../structures/InputManager.js";
|
|||||||
/**
|
/**
|
||||||
* Guild-scoped executable command
|
* Guild-scoped executable command
|
||||||
* @class
|
* @class
|
||||||
|
* @extends {FunctionCommand}
|
||||||
*/
|
*/
|
||||||
export class GuildCommand extends FunctionCommand {
|
export class GuildCommand extends FunctionCommand {
|
||||||
/**
|
/**
|
||||||
* List of Discord guild (server) IDs in which this command can be used
|
* List of Discord guild (server) IDs in which this command can be used
|
||||||
* @type {Array<string>}
|
* @type {Array<string>}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly guilds?: string[];
|
public readonly guilds?: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to *false*, all interactions that get invoked from private/direct conversations (outside a guild) will result a PermissionError
|
* If set to *false*, all interactions that get invoked from private/direct conversations (outside a guild) will result a PermissionError
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly dm: boolean;
|
public readonly dm: boolean;
|
||||||
|
|
||||||
@@ -43,6 +48,9 @@ export class GuildCommand extends FunctionCommand {
|
|||||||
/**
|
/**
|
||||||
* Invoke the command
|
* Invoke the command
|
||||||
* @param {InputManager} input - input data
|
* @param {InputManager} input - input data
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
* @public
|
||||||
|
* @async
|
||||||
*/
|
*/
|
||||||
public async start(input: InputManager): Promise<void> {
|
public async start(input: InputManager): Promise<void> {
|
||||||
if (!input.interaction.guild && !this.dm) throw new Error(`Command "${this.name}" is only available inside a guild.`);
|
if (!input.interaction.guild && !this.dm) throw new Error(`Command "${this.name}" is only available inside a guild.`);
|
||||||
|
|||||||
@@ -9,11 +9,14 @@ import { InputManager } from "../../structures/InputManager.js";
|
|||||||
/**
|
/**
|
||||||
* Executable command with attached permission system
|
* Executable command with attached permission system
|
||||||
* @class
|
* @class
|
||||||
|
* @extends {FunctionCommand}
|
||||||
*/
|
*/
|
||||||
export class PermissionCommand extends FunctionCommand {
|
export class PermissionCommand extends FunctionCommand {
|
||||||
/**
|
/**
|
||||||
* Object containing check functions and permission bitfields
|
* Object containing check functions and permission bitfields
|
||||||
* @type {CommandPermissions}
|
* @type {CommandPermissions}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly permissions: CommandPermissions;
|
public readonly permissions: CommandPermissions;
|
||||||
|
|
||||||
@@ -38,6 +41,9 @@ export class PermissionCommand extends FunctionCommand {
|
|||||||
/**
|
/**
|
||||||
* Invoke the command
|
* Invoke the command
|
||||||
* @param {InputManager} input - input data
|
* @param {InputManager} input - input data
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
* @public
|
||||||
|
* @async
|
||||||
*/
|
*/
|
||||||
public async start(input: InputManager): Promise<void> {
|
public async start(input: InputManager): Promise<void> {
|
||||||
if (this.permissions.check(input.interaction)) {
|
if (this.permissions.check(input.interaction)) {
|
||||||
|
|||||||
@@ -8,17 +8,23 @@ import { InputManager } from "../../structures/InputManager.js";
|
|||||||
/**
|
/**
|
||||||
* Guild-scoped executable command with permissions attached
|
* Guild-scoped executable command with permissions attached
|
||||||
* @class
|
* @class
|
||||||
|
* @extends {PermissionCommand}
|
||||||
|
* @implements {GuildCommand}
|
||||||
*/
|
*/
|
||||||
export class PermissionGuildCommand extends PermissionCommand implements GuildCommand {
|
export class PermissionGuildCommand extends PermissionCommand implements GuildCommand {
|
||||||
/**
|
/**
|
||||||
* List of Discord guild (server) IDs in which this command can be used
|
* List of Discord guild (server) IDs in which this command can be used
|
||||||
* @type {Array<string>}
|
* @type {Array<string>}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly guilds?: string[];
|
public readonly guilds?: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to *false*, all interactions that get invoked from private/direct conversations (outside a guild) will result a PermissionError
|
* If set to *false*, all interactions that get invoked from private/direct conversations (outside a guild) will result a PermissionError
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
* @public
|
||||||
|
* @readonly
|
||||||
*/
|
*/
|
||||||
public readonly dm: boolean;
|
public readonly dm: boolean;
|
||||||
|
|
||||||
@@ -45,6 +51,9 @@ export class PermissionGuildCommand extends PermissionCommand implements GuildCo
|
|||||||
/**
|
/**
|
||||||
* Invoke the command
|
* Invoke the command
|
||||||
* @param {InputManager} input - input data
|
* @param {InputManager} input - input data
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
* @public
|
||||||
|
* @async
|
||||||
*/
|
*/
|
||||||
public async start(input: InputManager): Promise<void> {
|
public async start(input: InputManager): Promise<void> {
|
||||||
if (!input.interaction.guild && !this.dm) throw new Error(`Command "${this.name}" is only available inside a guild.`);
|
if (!input.interaction.guild && !this.dm) throw new Error(`Command "${this.name}" is only available inside a guild.`);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ColorResolvable } from "discord.js";
|
import { ColorResolvable } from "discord.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* All properties used to customize the appearance of a help message
|
* All properties used to customize the appearance of a help message
|
||||||
|
* @interface
|
||||||
*/
|
*/
|
||||||
export interface HelpMessageParams {
|
export interface HelpMessageParams {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { CommandPermissionsInit } from "./permissions.js";
|
|||||||
import { CommandFunction, ContextType } from "./commands.js";
|
import { CommandFunction, ContextType } from "./commands.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Initialization options of core {@link Command} object
|
* Initialization options of core {@link Command} object
|
||||||
|
* @interface
|
||||||
*/
|
*/
|
||||||
export interface APICommandInit {
|
export interface APICommandInit {
|
||||||
/**
|
/**
|
||||||
@@ -20,8 +20,8 @@ export interface APICommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Initialization options of base executable command
|
* Initialization options of base executable command
|
||||||
|
* @interface
|
||||||
* @extends {APICommandInit}
|
* @extends {APICommandInit}
|
||||||
*/
|
*/
|
||||||
export interface FunctionCommandInit extends APICommandInit {
|
export interface FunctionCommandInit extends APICommandInit {
|
||||||
@@ -38,8 +38,8 @@ export interface FunctionCommandInit extends APICommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Initialization options of base guild-scoped command
|
* Initialization options of base guild-scoped command
|
||||||
|
* @interface
|
||||||
* @extends {FunctionCommandInit}
|
* @extends {FunctionCommandInit}
|
||||||
*/
|
*/
|
||||||
export interface GuildCommandInit extends FunctionCommandInit {
|
export interface GuildCommandInit extends FunctionCommandInit {
|
||||||
@@ -56,8 +56,8 @@ export interface GuildCommandInit extends FunctionCommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Initialization options of base command with attached permissions
|
* Initialization options of base command with attached permissions
|
||||||
|
* @interface
|
||||||
* @extends {FunctionCommandInit}
|
* @extends {FunctionCommandInit}
|
||||||
*/
|
*/
|
||||||
export interface PermissionCommandInit extends FunctionCommandInit {
|
export interface PermissionCommandInit extends FunctionCommandInit {
|
||||||
@@ -69,8 +69,8 @@ export interface PermissionCommandInit extends FunctionCommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Initialization options of base guild-scoped command with attached permisisions
|
* Initialization options of base guild-scoped command with attached permisisions
|
||||||
|
* @interface
|
||||||
* @extends {PermissionCommandInit}
|
* @extends {PermissionCommandInit}
|
||||||
*/
|
*/
|
||||||
export interface PermissionGuildCommandInit extends PermissionCommandInit {
|
export interface PermissionGuildCommandInit extends PermissionCommandInit {
|
||||||
@@ -87,8 +87,8 @@ export interface PermissionGuildCommandInit extends PermissionCommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Intialization options of chat command
|
* Intialization options of chat command
|
||||||
|
* @interface
|
||||||
* @extends {PermissionGuildCommandInit}
|
* @extends {PermissionGuildCommandInit}
|
||||||
*/
|
*/
|
||||||
export interface ChatCommandInit extends PermissionGuildCommandInit {
|
export interface ChatCommandInit extends PermissionGuildCommandInit {
|
||||||
@@ -125,8 +125,8 @@ export interface ChatCommandInit extends PermissionGuildCommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Initialization options of context menu interactions
|
* Initialization options of context menu interactions
|
||||||
|
* @interface
|
||||||
* @extends {PermissionGuildCommandInit}
|
* @extends {PermissionGuildCommandInit}
|
||||||
*/
|
*/
|
||||||
export interface ContextMenuCommandInit extends PermissionGuildCommandInit {
|
export interface ContextMenuCommandInit extends PermissionGuildCommandInit {
|
||||||
@@ -138,8 +138,8 @@ export interface ContextMenuCommandInit extends PermissionGuildCommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Subcommand initialization options
|
* Subcommand initialization options
|
||||||
|
* @interface
|
||||||
* @extends {PermissionCommandInit}
|
* @extends {PermissionCommandInit}
|
||||||
*/
|
*/
|
||||||
export interface SubCommandInit extends PermissionCommandInit {
|
export interface SubCommandInit extends PermissionCommandInit {
|
||||||
@@ -161,8 +161,8 @@ export interface SubCommandInit extends PermissionCommandInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Intialization options of subcommand group
|
* Intialization options of subcommand group
|
||||||
|
* @interface
|
||||||
* @extends {APICommandInit}
|
* @extends {APICommandInit}
|
||||||
*/
|
*/
|
||||||
export interface SubCommandGroupInit extends APICommandInit {
|
export interface SubCommandGroupInit extends APICommandInit {
|
||||||
|
|||||||
@@ -23,21 +23,25 @@ import { InputManager } from "../../structures/InputManager.js";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Types of command bases
|
* Types of command bases
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type BaseCommandType = "BASE" | "FUNCTION" | "GUILD" | "PERMISSION" | "PERMISSIONGUILD";
|
export type BaseCommandType = "BASE" | "FUNCTION" | "GUILD" | "PERMISSION" | "PERMISSIONGUILD";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command types
|
* Command types
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type CommandType = "CHAT" | "CONTEXT";
|
export type CommandType = "CHAT" | "CONTEXT";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Child command types
|
* Child command types
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type ChildCommandType = "COMMAND" | "GROUP";
|
export type ChildCommandType = "COMMAND" | "GROUP";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base command type selector
|
* Base command type selector
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type BaseCommands<T extends BaseCommandType> = T extends "BASE"
|
export type BaseCommands<T extends BaseCommandType> = T extends "BASE"
|
||||||
? Command
|
? Command
|
||||||
@@ -53,16 +57,19 @@ export type BaseCommands<T extends BaseCommandType> = T extends "BASE"
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Command type selector
|
* Command type selector
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type Commands<T extends CommandType> = T extends "CHAT" ? ChatCommand : T extends "CONTEXT" ? ContextMenuCommand : never;
|
export type Commands<T extends CommandType> = T extends "CHAT" ? ChatCommand : T extends "CONTEXT" ? ContextMenuCommand : never;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Child command type selector
|
* Child command type selector
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type ChildCommands<T extends ChildCommandType> = T extends "COMMAND" ? SubCommand : T extends "GROUP" ? SubCommandGroup : never;
|
export type ChildCommands<T extends ChildCommandType> = T extends "COMMAND" ? SubCommand : T extends "GROUP" ? SubCommandGroup : never;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base command initializer selector
|
* Base command initializer selector
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type BaseCommandInit<T extends BaseCommandType> = T extends "BASE"
|
export type BaseCommandInit<T extends BaseCommandType> = T extends "BASE"
|
||||||
? APICommandInit
|
? APICommandInit
|
||||||
@@ -78,46 +85,59 @@ export type BaseCommandInit<T extends BaseCommandType> = T extends "BASE"
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Command initializer selector
|
* Command initializer selector
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type CommandInit<T extends CommandType> = T extends "CHAT" ? ChatCommandInit : T extends "CONTEXT" ? ContextMenuCommandInit : never;
|
export type CommandInit<T extends CommandType> = T extends "CHAT" ? ChatCommandInit : T extends "CONTEXT" ? ContextMenuCommandInit : never;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Child command initializer selector
|
* Child command initializer selector
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type ChildCommandInit<T extends ChildCommandType> = T extends "COMMAND" ? SubCommandInit : T extends "GROUP" ? SubCommandGroupInit : never;
|
export type ChildCommandInit<T extends ChildCommandType> = T extends "COMMAND" ? SubCommandInit : T extends "GROUP" ? SubCommandGroupInit : never;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base command resolvables
|
* Base command resolvables
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type BaseCommandResolvable = Command | FunctionCommand | GuildCommand | PermissionCommand | PermissionGuildCommand;
|
export type BaseCommandResolvable = Command | FunctionCommand | GuildCommand | PermissionCommand | PermissionGuildCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command resolvables
|
* Command resolvables
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type CommandResolvable = ChatCommand | ContextMenuCommand;
|
export type CommandResolvable = ChatCommand | ContextMenuCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Child command resolvables
|
* Child command resolvables
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type ChildCommandResolvable = SubCommandGroup | SubCommand;
|
export type ChildCommandResolvable = SubCommandGroup | SubCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context menu command types
|
* Context menu command types
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type ContextType = "USER" | "MESSAGE";
|
export type ContextType = "USER" | "MESSAGE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All types that can be returned from a command function
|
* All types that can be returned from a command function
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type CommandFunctionReturnTypes = void | string | MessageEmbed | ReplyMessageOptions | Promise<void | string | MessageEmbed | ReplyMessageOptions>;
|
export type CommandFunctionReturnTypes = void | string | MessageEmbed | ReplyMessageOptions | Promise<void | string | MessageEmbed | ReplyMessageOptions>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command function definition
|
* Command function definition
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type CommandFunction = (input: InputManager) => CommandFunctionReturnTypes;
|
export type CommandFunction = (input: InputManager) => CommandFunctionReturnTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regular expressions used globally to perform name checking
|
* Regular expressions used globally to perform name checking
|
||||||
|
* @property {RegExp} baseName - base command name (used for context menu)
|
||||||
|
* @property {RegExp} chatName - chat command name
|
||||||
|
* @property {RegExp} chatDescription - chat command description
|
||||||
|
* @property {RegExp} separator - argument and command separators
|
||||||
|
* @property {RegExp} prefix - global and guild-scoped prefixes
|
||||||
*/
|
*/
|
||||||
export const CommandRegExps = {
|
export const CommandRegExps = {
|
||||||
baseName: /^.{1,32}$/,
|
baseName: /^.{1,32}$/,
|
||||||
|
|||||||
@@ -2,17 +2,19 @@ import { PermissionResolvable, Message, Interaction } from "discord.js";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Permission checking methods
|
* Permission checking methods
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type PermissionCheckTypes = "ALL" | "ANY";
|
export type PermissionCheckTypes = "ALL" | "ANY";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Definition of permission function
|
* Definition of permission function
|
||||||
|
* @type
|
||||||
*/
|
*/
|
||||||
export type PermissionFunction = (i: Interaction | Message) => boolean;
|
export type PermissionFunction = (i: Interaction | Message) => boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
|
||||||
* Command permissions initialization object
|
* Command permissions initialization object
|
||||||
|
* @interface
|
||||||
*/
|
*/
|
||||||
export interface CommandPermissionsInit {
|
export interface CommandPermissionsInit {
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user