Options
All
  • Public
  • Public/Protected
  • All
Menu

Advanced Command-Handler - v3.0.0

Index

Type aliases

AnyObject

AnyObject: Record<string, any>

ArgumentBuilder

ArgumentBuilder<T>: Partial<(DefaultValueArgument<T> | CoalescingArgument | OptionalArgument) & { description: string }>

Type parameters

  • T

ArgumentFunction

ArgumentFunction<T>: (options: ArgumentBuilder<T>) => Argument<T>

Type parameters

  • T

Type declaration

ArgumentResolved

ArgumentResolved<A>: null | CommandError | A

Type parameters

  • A

ColorResolvable

ColorResolvable: NonNullable<keyof typeof colors | keyof typeof LogType | string>

Constructor

Constructor<T>: new (...args: any[]) => T

Type parameters

  • T: {} = {}

Type declaration

    • new (...args: any[]): T
    • Parameters

      • Rest ...args: any[]

      Returns T

JSONLike

JSONLike: {} | JSONLike[]

LoggerIgnore

LoggerIgnore: [title: string, level: LogLevel | keyof typeof LogLevel]

MapArguments

MapArguments<A>: Map<string, null | CommandError | A[number]>

Type parameters

  • A: any[]

MaybeCommand

MaybeCommand: Constructor<Command> | { default: Constructor<Command> } | {}

MaybeEvent

MaybeEvent: Constructor<Event> | { default: Constructor<Event> } | {}

MaybePromise

MaybePromise<T>: Promise<T> | T

Type parameters

  • T

RunSubCommandFunction

RunSubCommandFunction: (ctx: SubCommandContext) => any | Promise<any>

Type declaration

Template

Template<V>: Partial<MessageEmbedOptions> & (V extends undefined ? {} : { values?: V })

Type parameters

Templates

Templates: typeof templates

TextChannelLike

TextChannelLike: TextChannel | NewsChannel

Variables

Const LogType

LogType: { comment: string; debug: string; error: string; event: string; info: string; log: string; warn: string } = ...

Type declaration

  • comment: string
  • debug: string
  • error: string
  • event: string
  • info: string
  • log: string
  • warn: string

Const colors

colors: { black: string; blue: string; brown: string; default: string; gold: string; green: string; grey: string; indigo: string; magenta: string; orange: string; pink: string; red: string; teal: string; violet: string; white: string; yellow: string } = ...

Type declaration

  • black: string
  • blue: string
  • brown: string
  • default: string
  • gold: string
  • green: string
  • grey: string
  • indigo: string
  • magenta: string
  • orange: string
  • pink: string
  • red: string
  • teal: string
  • violet: string
  • white: string
  • yellow: string

Const limits

limits: { author: { name: number }; description: number; fields: { name: number; size: number; value: number }; footer: { text: number }; title: number }

Type declaration

  • author: { name: number }
    • name: number
  • description: number
  • fields: { name: number; size: number; value: number }
    • name: number
    • size: number
    • value: number
  • footer: { text: number }
    • text: number
  • title: number

Const templates

templates: TemplatesValues

Functions

argError

  • A function to use when a user fail on an argument of a command.

    Parameters

    • ctx: CommandContext

      The message context where the error come from.

    • error: string

      The error.

    Returns Promise<Message>

    • The error message sent.

booleanArgument

channelArgument

choiceArgument

codeError

  • A function to use when a code error occurs in a command for example.

    remarks

    If the message author is an owner, it sends the error stack.
    Do not use for sending string as errors.

    Parameters

    • ctx: CommandContext

      The command context where the error come from.

    • error: Error

      The native error.

    Returns Promise<Message>

    • The error message sent.

commandArgument

cutIfTooLong

  • cutIfTooLong(text: string, maxLength: number, endTextIfTooLong?: string): string
  • Return the text cut if length is above maxLength arg and add endTextIfTooLong at the end.

    Parameters

    • text: string

      The text to cut if it is too long.

    • maxLength: number

      The maximum length required.

    • endTextIfTooLong: string = '...'

      The end text to add if it is too long.

    Returns string

    • The text, cut if it was too long.

emojiArgument

enumArgument

  • Creates a enum argument. You must put an enum (or a record) of the possible values. The value can be any key of the possible values and it will return the value of the entry.

    Type parameters

    • E: Record<string, V>

    • V

    Parameters

    Returns Argument<V>

    • A enum argument.

eventArgument

floatArgument

getKeyByValue

  • getKeyByValue<O>(object: O, value: O[keyof O]): keyof O | undefined
  • Get a key from a value from an Object.

    Type parameters

    • O: {}

      The object type.

    Parameters

    • object: O

      The object to get key from.

    • value: O[keyof O]

      The value.

    Returns keyof O | undefined

    • The key of the object if found, else undefined.

getThing

  • getThing(dataType: DataTypeResolver<CHANNEL>, text: string | Message): Promise<Channel | null>
  • getThing(dataType: DataTypeResolver<COMMAND>, text: string | Message): Promise<Command | null>
  • getThing(dataType: DataTypeResolver<EMOTE>, text: string | Message): Promise<Emoji | null>
  • getThing(dataType: DataTypeResolver<GUILD>, text: string | Message): Promise<Guild | null>
  • getThing(dataType: DataTypeResolver<MEMBER>, text: string | Message): Promise<GuildMember | null>
  • getThing(dataType: DataTypeResolver<MESSAGE>, text: string | Message): Promise<Message | null>
  • getThing(dataType: DataTypeResolver<ROLE>, text: string | Message): Promise<Role | null>
  • getThing(dataType: DataTypeResolver<TEXT_CHANNEL>, text: string | Message): Promise<TextChannelLike | null>
  • getThing(dataType: DataTypeResolver<USER>, text: string | Message): Promise<User | null>
  • Finds a Channel from the text, or the message content and returns null if nothing found. It can find it from ID/name/mention.

    Parameters

    • dataType: DataTypeResolver<CHANNEL>

      Channel DataType.CHANNEL.

    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<Channel | null>

    • The Channel or null if not found.
  • Finds a Command from the text, or the message content and returns null if nothing found. It can find it from the name/alias.

    Parameters

    • dataType: DataTypeResolver<COMMAND>

      Command DataType.COMMAND.

    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<Command | null>

    • The Command or null if not found.
  • Finds an Emoji from the text, or the message content and returns null if nothing found. It can find it from the name/emoji itself/ID.

    Parameters

    • dataType: DataTypeResolver<EMOTE>
    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<Emoji | null>

    • The Emoji or null if not found.
  • Finds a Guild from the text, or the message content and returns null if nothing found. It can find it from the name/ID.

    Parameters

    • dataType: DataTypeResolver<GUILD>
    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<Guild | null>

    • The Guild or null if not found.
  • Finds a GuildMember from the text, or the message content and returns null if nothing found. It can find it from the username/ID/mention/nickname.

    Parameters

    • dataType: DataTypeResolver<MEMBER>

      Member DataType.MEMBER.

    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<GuildMember | null>

    • The Guild or null if not found.
  • Finds a Message from the text, or the message content and returns null if nothing found. It can find it from the name/ID/link.

    Parameters

    • dataType: DataTypeResolver<MESSAGE>

      Message DataType.MESSAGE.

    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<Message | null>

    • The Message or null if not found.
  • Finds a Role from the text, or the message content and returns null if nothing found. It can find it from the name/ID/mention, if a message is provided, it will fetch the last 100 messages and search in it.

    Parameters

    • dataType: DataTypeResolver<ROLE>
    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<Role | null>

    • The Role or null if not found.
  • Finds a TextChannel or a NewsChannel from the text, or the message content and returns null if nothing found. It can find it from ID/name/mention.

    Parameters

    Returns Promise<TextChannelLike | null>

    • The Channel or null if not found.
  • Finds a User from the text, or the message content and returns null if nothing found.
    It can find it from the username/ID.

    Parameters

    • dataType: DataTypeResolver<USER>
    • text: string | Message

      A string or a Message to find dataType from.

    Returns Promise<User | null>

    • The User or null if not found.

guildArgument

guildMemberArgument

  • Creates a guildMember argument. The value can be an ID, mention, nickname or username of any member from the actual guild where the command was executed. If executed in DM it will always return null.

    Parameters

    Returns Argument<GuildMember>

    • A guildMember argument.

intArgument

isOwner

  • isOwner(id: Snowflake): boolean

isPermission

  • isPermission(permission: string): permission is PermissionString
  • Check if some permission is a valid permission that exists.

    Parameters

    • permission: string

      The permission to test.

    Returns permission is PermissionString

    • Is the permission is a valid permission.

isSnowflake

  • isSnowflake(value: string): value is string
  • Returns true if the value looks like a Snowflake.

    remarks

    There is no way to identify at 100% if the value is veritable snowflake of something.

    Parameters

    • value: string

    Returns value is string

    • Is the value a Snowflake.

isTextChannelLike

  • Returns true if the value is a TextChannel or a NewsChannel.

    Parameters

    • value: any

      The value you want to test.

    Returns value is TextChannelLike

    • Is the value a TextChannelLike.

messageArgument

  • Creates a message argument. The value can be any ID or URL of a message, if the value is an ID it will search in the last 100 messages of all the channels of the current guild.

    Parameters

    Returns Argument<Message>

    • A message argument.

permissionsError

  • permissionsError(ctx: CommandContext, missingPermissions: PermissionString[], fromClient?: boolean): Promise<Message>
  • A function to use when a user, or the client hasn't all the permissions needed.

    Parameters

    • ctx: CommandContext

      The command context where the permission where missing.

    • missingPermissions: PermissionString[]

      The error.

    • fromClient: boolean = false

      If the error is from the client.

    Returns Promise<Message>

    • The error message sent.

random

  • random<T>(array: T[]): T
  • Returns a random value from an array.

    Type parameters

    • T: unknown

      The array type.

    Parameters

    • array: T[]

      The array to get a random value from.

    Returns T

    • A random value from the array.

readJSON

regexArgument

saveJSON

  • saveJSON(path: string, content: JSONLike): boolean
  • Saves a JSON-Like object into a JSON file.

    Parameters

    • path: string

      The path of the JSON file.

    • content: JSONLike

      The content to save.

    Returns boolean

    • True if operation has successfully worked.

snowflakeArgument

stringArgument

textChannelArgument

userArgument

Generated using TypeDoc