Options
All
  • Public
  • Public/Protected
  • All
Menu

node-discord

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

AvatarFormat

All avatar format enums

BaseStructWithId

BaseStructWithId: BaseStruct & { id: Snowflake | string }

A base structure with the ID field

Body

Body: Data | Data[]

The request's Body type

BotStateEvents

BotStateEvents: Ready | Close

Events that are called when all Bot shards change their state. These events take no arguments

BucketIndex

BucketIndex: string

Rate limit buckets are indexed by the Endpoint Route, Http Method, and all Major Parameters

example

[EndpointRoute.Channel, HttpMethod.Get, [channelId]].join(' ');

CommandExecuteFunction

CommandExecuteFunction<T>: (message: Message, ...args: any[]) => T

Type parameters

  • T

Type declaration

    • (message: Message, ...args: any[]): T
    • Parameters

      • message: Message
      • Rest ...args: any[]

      Returns T

Data

Data: Record<string, Serializable | undefined | null>

Dictionary type for request Params and Body

EmojiResolvable

EmojiResolvable: string | Snowflake | Emoji

Any kind of emoji. Could be its unicode name, ID or Emoji object

EventHandlers

EventHandlers: Record<GatewayEvent, (payload: Payload, bot?: Bot, socketShard?: BotSocketShard) => void | Promise<void>>

GatewayStruct

GatewayStruct: Record<string, any>

Payload data received from the Discord gateway

HandlerAttributes

HandlerAttributes<T>: { name: T }

Default handler attributes

Type parameters

  • T

Type declaration

  • name: T

HandlerFunction

HandlerFunction: (...args: any[]) => void

Default handler function

Type declaration

    • (...args: any[]): void
    • Parameters

      • Rest ...args: any[]

      Returns void

InviteCode

InviteCode: string

Nullable

Nullable<T>: {}

Turns all fields of a given type to be nullable

Type parameters

  • T

Type declaration

OptionalLibrary

OptionalLibrary: any

Params

Params: Data | Data[] | undefined

The request's Params type

PayloadData

PayloadData: any

Positions

Positions: Record<Snowflake, number | null>

New positions for a orderly listed values on Discord, such as guild channels or roles The key is the item's ID. The value is the item's new position.

The positions are in a descending order ending at 0

example

// Guild channels positions { '702476896008405005': 1, '702476896008405005': 2 }

example

// Roles positions { '706861476752785461': 2 }

RequestFile

RequestFile: { name: string; path: string } | string

Represents a file attachment sent to the API

ReturnedData

ReturnedData: Data | Array<Serializable | undefined | null>

The type of data returned from the API

RouteArgs

RouteArgs: Record<string, string>

The route's arguments type (as a parameter)

ShardId

ShardId: number

Snowflake

Snowflake: string

Discord Snowflake. More information can be found here https://discordapp.com/developers/docs/reference#snowflakes

TextBasedChannel

TextBasedChannel: GuildTextChannel | DMChannel

Text based channels of Discord

Variables

Const UnreconnectableGatewayCloseCodes

UnreconnectableGatewayCloseCodes: GatewayCloseCode[] = [GatewayCloseCode.ManualClosure,GatewayCloseCode.AuthenticationFailed,GatewayCloseCode.InvalidShard,GatewayCloseCode.ShardingRequired,GatewayCloseCode.InvalidIntent,GatewayCloseCode.DisallowedIntent,]

Const UnresumeableGatewayCloseCodes

UnresumeableGatewayCloseCodes: GatewayCloseCode[] = [GatewayCloseCode.NormalClosure,GatewayCloseCode.InvalidSeq,]

Const ValidCodes

ValidCodes: StatusCode[] = [StatusCode.OK, StatusCode.Created, StatusCode.NoContent]

Const baseURL

baseURL: string = `https://discord.com/api/v${version}`

The base URL for the Discord API

Const bodyMethods

bodyMethods: HttpMethod[] = [HttpMethod.Post, HttpMethod.Patch, HttpMethod.Put]

Const cdnBaseURL

cdnBaseURL: "https://cdn.discordapp.com" = "https://cdn.discordapp.com"

Let erlpack

erlpack: OptionalLibrary | undefined

Const majorKeys

majorKeys: string[] = ['channelId', 'guildId', 'webhookId']

Const paramsMethods

paramsMethods: HttpMethod[] = [HttpMethod.Get]

Const readFile

readFile: __promisify__ = util.promisify(fs.readFile)

Const recommendedShardTimeout

recommendedShardTimeout: 5500 = 5500

Const version

version: 6 = 6

The latest version of the Discord API

Let zlib

zlib: OptionalLibrary | undefined

Functions

RegisterCommand

  • Decorator for registering a command

    example

    ```typescript

    registercommand({

    name: 'ping' }) export class Ping extends Command { ... }

    @param {CommandAttributes} attributes The attributes for the command
    @returns {function(constructor: Command): void}

    Parameters

    Returns (Anonymous function)

RegisterCommandHandler

  • RegisterCommandHandler<THandlerName>(name: THandlerName): (Anonymous function)
  • Decorator for registering an event handler for a command

    example

    ```typescript

    registercommandhandler(handlerevent.execute)

    public main(message: Message): void { console.log('Pong!', message.content); }

    @param {THandlerName} name The name of the handler event
    @returns {Function}

    Type parameters

    Parameters

    • name: THandlerName

    Returns (Anonymous function)

RegisterEvent

  • Decorator for registering an event

    example

    ```typescript

    registercommand({

    name: BotEvent.Ready }) export class Ready extends Event { ... }

    @param {CommandAttributes} attributes The attributes for the command
    @returns {function(constructor: Event): void}

    Type parameters

    Parameters

    Returns (Anonymous function)

RegisterEventHandler

  • RegisterEventHandler<THandlerName>(name: THandlerName): (Anonymous function)
  • Decorator for registering an event handler for an event

    example

    ```typescript

    registereventhandler(handlerevent.execute)

    public main(message: Message): void { console.log(message.content); }

    @param {THandlerName} name The name of the handler event
    @returns {Function}

    Type parameters

    Parameters

    • name: THandlerName

    Returns (Anonymous function)

Object literals

Const Endpoints

Endpoints: object

All endpoints mapped by their route name

[EndpointRoute.ChannelInvites]

  • [EndpointRoute.ChannelInvites](channelId: Snowflake): string

[EndpointRoute.ChannelMessage]

[EndpointRoute.ChannelMessagesBulkDelete]

  • [EndpointRoute.ChannelMessagesBulkDelete](channelId: Snowflake): string

[EndpointRoute.ChannelMessagesReactionsEmojiUser]

  • [EndpointRoute.ChannelMessagesReactionsEmojiUser](channelId: Snowflake, messageId: Snowflake, emoji: string, userId?: Snowflake): string

[EndpointRoute.ChannelMessagesReactionsEmoji]

  • [EndpointRoute.ChannelMessagesReactionsEmoji](channelId: Snowflake, messageId: Snowflake, emoji: string): string

[EndpointRoute.ChannelMessagesReactions]

  • [EndpointRoute.ChannelMessagesReactions](channelId: Snowflake, messageId: Snowflake): string

[EndpointRoute.ChannelMessages]

  • [EndpointRoute.ChannelMessages](channelId: Snowflake): string

[EndpointRoute.ChannelPermissionsOverwrite]

  • [EndpointRoute.ChannelPermissionsOverwrite](channelId: Snowflake, overwriteId: Snowflake): string

[EndpointRoute.ChannelPinsMessage]

[EndpointRoute.ChannelPins]

  • [EndpointRoute.ChannelPins](channelId: Snowflake): string

[EndpointRoute.ChannelTyping]

  • [EndpointRoute.ChannelTyping](channelId: Snowflake): string

[EndpointRoute.ChannelWebhooks]

  • [EndpointRoute.ChannelWebhooks](channelId: Snowflake): string

[EndpointRoute.Channel]

  • [EndpointRoute.Channel](channelId: Snowflake): string

[EndpointRoute.GuildBan]

[EndpointRoute.GuildBans]

  • [EndpointRoute.GuildBans](guildId: Snowflake): string

[EndpointRoute.GuildChannels]

  • [EndpointRoute.GuildChannels](guildId: Snowflake): string

[EndpointRoute.GuildEmoji]

[EndpointRoute.GuildEmojis]

  • [EndpointRoute.GuildEmojis](guildId: Snowflake): string

[EndpointRoute.GuildIntegrationSync]

  • [EndpointRoute.GuildIntegrationSync](guildId: Snowflake, integrationId: Snowflake): string

[EndpointRoute.GuildIntegration]

[EndpointRoute.GuildIntegrations]

  • [EndpointRoute.GuildIntegrations](guildId: Snowflake): string

[EndpointRoute.GuildInvites]

  • [EndpointRoute.GuildInvites](guildId: Snowflake): string

[EndpointRoute.GuildMemberBotNick]

  • [EndpointRoute.GuildMemberBotNick](guildId: Snowflake): string

[EndpointRoute.GuildMemberRole]

[EndpointRoute.GuildMember]

[EndpointRoute.GuildMembers]

  • [EndpointRoute.GuildMembers](guildId: Snowflake): string

[EndpointRoute.GuildPreview]

  • [EndpointRoute.GuildPreview](guildId: Snowflake): string

[EndpointRoute.GuildPrune]

  • [EndpointRoute.GuildPrune](guildId: Snowflake): string

[EndpointRoute.GuildRole]

[EndpointRoute.GuildRoles]

  • [EndpointRoute.GuildRoles](guildId: Snowflake): string

[EndpointRoute.GuildVanityURL]

  • [EndpointRoute.GuildVanityURL](guildId: Snowflake): string

[EndpointRoute.GuildWebhooks]

  • [EndpointRoute.GuildWebhooks](guildId: Snowflake): string

[EndpointRoute.GuildWidget]

  • [EndpointRoute.GuildWidget](guildId: Snowflake): string

[EndpointRoute.Guild]

  • [EndpointRoute.Guild](guildId: Snowflake): string

[EndpointRoute.Invite]

  • [EndpointRoute.Invite](inviteCode: string): string

[EndpointRoute.UserBotChannels]

  • [EndpointRoute.UserBotChannels](): string

[EndpointRoute.UserBotGuild]

  • [EndpointRoute.UserBotGuild](guildId: Snowflake): string

[EndpointRoute.UserBotGuilds]

  • [EndpointRoute.UserBotGuilds](): string

[EndpointRoute.UserBot]

  • [EndpointRoute.UserBot](): string

[EndpointRoute.User]

  • [EndpointRoute.User](userId: Snowflake): string

[EndpointRoute.Webhook]

  • [EndpointRoute.Webhook](webhookId: Snowflake): string

Const botOptions

botOptions: object

The default options used to initialize a Bot instance

cache

cache: object

messagesLimit

messagesLimit: number = 100

websocket

websocket: object

v

v: number = version

Const identify

identify: object

All details that are sent in the Bot's 'IDENTIFY' request

large_threshold

large_threshold: number = 250

version

version: number

presence

presence: object

status

status: string = "online"

properties

properties: object

$browser

$browser: string = "node-discord"

$device

$device: string = "node-discord"

$os

$os: "aix" | "android" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32" | "cygwin" | "netbsd" = process.platform

Const mentionsRegexp

mentionsRegexp: object

channels

channels: RegExp = new RegExp(/<#(\d{17,19})>/g)

Generated using TypeDoc