diff --git a/src/errors.ts b/src/errors.ts index 48a106a..05b7111 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -10,12 +10,15 @@ import { ParameterType } from "./types/Parameter.js"; */ export class PermissionsError extends Error { private readonly command: BaseCommand; + private readonly user: GuildMember | null; + constructor(command: BaseCommand, user?: GuildMember | null) { super(); this.command = command; this.user = user || null; } + public toString() { return `User ${this.user?.user.tag} doesn't have enough permissions to run "${this.command.name}" command`; } @@ -28,12 +31,15 @@ export class PermissionsError extends Error { */ export class ParameterTypeError extends TypeError { private readonly stringContent: string; + private readonly type: ParameterType; + constructor(s: string, type: ParameterType) { super(); this.stringContent = s; this.type = type; } + public toString() { return `Parameter "${this.stringContent}" cannot be converted to ${this.type}`; } @@ -46,10 +52,12 @@ export class ParameterTypeError extends TypeError { */ export class MissingParameterError extends ReferenceError { private readonly argument: Parameter; + constructor(a: Parameter) { super(); this.argument = a; } + public toString() { return `Your request is missing a "${this.argument.name}" parameter which is not optional`; } @@ -61,6 +69,7 @@ export class MissingParameterError extends ReferenceError { */ export class OperationSuccess { public readonly command: BaseCommand; + constructor(c: BaseCommand) { this.command = c; } diff --git a/src/managers/CommandManager.ts b/src/managers/CommandManager.ts index a264cdd..be99581 100644 --- a/src/managers/CommandManager.ts +++ b/src/managers/CommandManager.ts @@ -12,13 +12,17 @@ import { MessageCommand } from "../structures/MessageCommand.js"; */ export class CommandManager { private readonly _textCommandsList: TextCommand[] = []; + private readonly _messagesCommandsList: BaseCommand[] = []; + private readonly _userCommandsList: BaseCommand[] = []; + /** * Prefix used as a way to trigger the bot using messages * @type {string} */ public readonly prefix?: string; + /** * Separator used to split user input to a list of {@link InputParameter}s (applies to prefix interactions) * @type {string} diff --git a/src/managers/SystemMessage.ts b/src/managers/SystemMessage.ts index a9b9dd4..cb06c10 100644 --- a/src/managers/SystemMessage.ts +++ b/src/managers/SystemMessage.ts @@ -7,21 +7,25 @@ export class SystemMessageManager { * @type {SystemMessageAppearance} */ public PERMISSION: SystemMessageAppearance; + /** * Error message * @type {SystemMessageAppearance} */ public ERROR: SystemMessageAppearance; + /** * "Command not found" message * @type {SystemMessageAppearance} */ public NOT_FOUND: SystemMessageAppearance; + /** * "Task completed successfully" message * @type {SystemMessageAppearance} */ public SUCCESS: SystemMessageAppearance; + /** * Global time (in ms) after a message gets deleted * @type {number} diff --git a/src/structures/Bot.ts b/src/structures/Bot.ts index 06951ea..fb2a375 100644 --- a/src/structures/Bot.ts +++ b/src/structures/Bot.ts @@ -30,26 +30,31 @@ export class Bot extends EventEmitter { * @type {string} */ public readonly name: string; + /** * Discord.js {@link Client} instance * @type {Client} */ public readonly client: Client; + /** * Instance command manager * @type {CommandManager} */ public readonly commands: CommandManager; + /** * Discord bot token * @type {string} */ public readonly token: string; + /** * Discord API application ID * @type {string} */ public readonly applicationId: string; + /** * Built-in messages configuration * @type {Object} diff --git a/src/structures/Parameter.ts b/src/structures/Parameter.ts index 4abd287..0bcbe16 100644 --- a/src/structures/Parameter.ts +++ b/src/structures/Parameter.ts @@ -11,21 +11,25 @@ export class Parameter { * @type {string} */ public readonly name: string; + /** * Parameter description * @type {string} */ public readonly description: string; + /** * Whether this parameter is optional * @type {boolean} */ public readonly optional: boolean; + /** * Parameter input type * @type {ParameterType} */ public readonly type: ParameterType; + /** * List of value choices (available only when type is set to "STRING") */ @@ -129,9 +133,11 @@ export class ObjectParameter extends InputParameter { export class ObjectID { public readonly id: string; + constructor(id: string) { this.id = id.replace(">", "").replace("<@!", "").replace("<#!", ""); } + public async toObject( guild: Guild, type: "channel" | "user" | "role" diff --git a/src/types/Bot.ts b/src/types/Bot.ts index ff3294f..cc40d7b 100644 --- a/src/types/Bot.ts +++ b/src/types/Bot.ts @@ -10,26 +10,31 @@ export interface InitOptions { * @type {string} */ name: string; + /** * Prefix used as a way to trigger the bot using messages * @type {string} */ prefix?: string; + /** * Separator used to split user input to a list of {@link InputParameter}s (applies to prefix interactions) * @type {string} */ parameterSeparator?: string; + /** * Additional {@link ClientOptions} for Discord.js {@link Client} object * @type {ClientOptions} */ clientOptions?: ClientOptions; + /** * Discord bot token * @type {string} */ token: string; + /** * Discord API application ID * @type {string} diff --git a/src/types/HelpMessage.ts b/src/types/HelpMessage.ts index 6b76efc..299cebb 100644 --- a/src/types/HelpMessage.ts +++ b/src/types/HelpMessage.ts @@ -6,31 +6,37 @@ export interface HelpMessageParams { * @type {boolean} */ enabled: boolean; + /** * Title field * @type {string} */ title: string; + /** * Text below the title * @type {string} */ bottomText: string; + /** * Color of a message * @type {ColorResolvable} */ color: ColorResolvable; + /** * Description of the "help" command * @type {string} */ description: string; + /** * Usage of the "help" command * @type {string} */ usage: string; + /** * Whether the "help" command should be visible in the help message * @type {boolean} diff --git a/src/types/Parameter.ts b/src/types/Parameter.ts index 04af67b..d9b59aa 100644 --- a/src/types/Parameter.ts +++ b/src/types/Parameter.ts @@ -15,11 +15,13 @@ export interface ParameterSchema { * @type {string} */ name: string; + /** * Parameter description * @type {string} */ description?: string; + /** * Whether this parameter is optional * @type {boolean} @@ -27,6 +29,7 @@ export interface ParameterSchema { optional: boolean; type: ParameterType; + /** * List of value choices (available only when type is set to "STRING") */ diff --git a/src/types/SystemMessage.ts b/src/types/SystemMessage.ts index 3ec86a7..9c4b1fe 100644 --- a/src/types/SystemMessage.ts +++ b/src/types/SystemMessage.ts @@ -17,36 +17,43 @@ export interface SystemMessageAppearance { * @type {boolean} */ enabled: boolean; + /** * Title field * @type {string} */ title: string; + /** * Text below the title * @type {string} */ bottomText?: string; + /** * Color of a message * @type {ColorResolvable} */ accentColor?: ColorResolvable; + /** * Whether to display detailed informations in the message * @type {boolean} */ displayDetails?: boolean; + /** * Whether to show current time and date in a footer * @type {boolean} */ showTimestamp?: boolean; + /** * Footer text * @type {string} */ footer?: string; + /** * Time (in ms) after a message of this type gets deleted (set to *Infinity* to not delete the message) * @type {number} @@ -64,16 +71,19 @@ export interface SystemMessageData { * @type {TextCommand} */ command?: TextCommand; + /** * Phrase received from a Discord channel * @type {string} */ phrase?: string; + /** * User who used the bot * @type {GuildMember | User} */ user?: GuildMember | User; + /** * Error object * @type {Error | PermissionsError | string}