js-cord

1.1.0

Represents a client connection to the Discord API and Gateway.

Client

Extends Emitter

Parameters
options (object?) The options to use for the client.
Name Description
options.allowedMentions object? The default allowed mentions to use when sending messages.
options.intents Intents? The intents to use when connecting to the gateway.
options.apiVersion number? The REST API version to use for requests.
options.gatewayVersion number? The gateway version to use for interacting with Discord's gateway.
options.shard boolean? Whether or not to shard the bot. Must be explicitly enabled for large bots.
options.shardCount number? The amount of shards to connect to. This should usually never be used.
Instance Members
cache
sharded
allowedMentions
intents
loggedIn
http
ws
user
shards
id
apiVersion
gatewayVersion
latency
latencies
start(token)
login(token)
getUser(id)
getGuild(id)
getChannel(id)
getRole(id)
users
channels
guilds
roles
fetchGuild(id)
createGuild(name)
onSlashCommand(command, callback)
createSlashCommand(command, guilds, callback)

The base class that emits events and manages their callbacks. Client extends this class.

Emitter
Instance Members
on(event, callback)
once(event, callback)
listen(event, callback)
emit(event, parameters)
collect(event, options)
waitFor(event, options)

A sequentializing utility class used to efficiently manage promises.

Queue
Instance Members
count
wait()
shift()

Discord enumerations.

enums

Represents a row of components.

ActionRow

Extends Component

Instance Members
components
addComponent(component)
toJSON()
length

Represents a button component.

Button

Extends Component

Instance Members
style
label
url
disabled
callback
emoji
toJSON()
stop()

The base class that represents a Discord message component.

Component
Static Members
fromJSON(data)
Instance Members
type
id
toJSON()

Represents the entire components of a message.

Components
Instance Members
copy()
addRow(components)
addComponent(component)
addButton(options, callback)
components()
componentAt(index)
disableButtonAt(indices)
length
toJSON()

Represents a slash command.

SlashCommand
Parameters
name (string) The name of the slash command.
options (object?) The options to use when creating the command.
Static Members
fromJSON(options)
Instance Members
setName(name)
setDescription(description)
addOption(option)
toJSON()

Represents a slash command option.

SlashCommandOption
Instance Members
addChoice(name, value)
addOption(option)
toJSON()
optional

Represents the context for a slash command interaction.

SlashContext
Instance Members
respond(content, options)
send(content, options)

Utility constants to aid in providing allowed mentions for messages.

AllowedMentions
Static Members
all()
none()
default()

Represents a Discord asset or image.

Asset
Instance Members
hash
animated
defaultFormat
url
urlAs(options)

The base class that represents a bitfield.

Bitfield
Static Members
fromObject(object, mapping)
Instance Members
value

Represents a general Discord channel. This could be a text channel, DM channel, voice channel, etc.

Channel

Extends DiscordObject

Instance Members
type

Represents the client as a user. Because the client has accesse to it's own information, it will have access to more properties than any other user.

ClientUser

Extends User

Instance Members
mfaEnabled
locale
verified

Represents a color.

Color
Parameters
value (number?) The decimal representation of this color.

Represents a Discord object with a snowflake.

DiscordObject
Instance Members
createdAt
id

Represents embedded content of a Discord message. You can also construct this class to send your own embeds.

Embed
Parameters
data (object?) The raw JSON data, usually from Discord, to construct this embed with.
Instance Members
type
footer
author
thumbnail
image
video
provider
fields
title
description
url
timestamp
color
colour
setTitle(title, url)
setDescription(description)
appendDescription(description)
setURL(url)
setColor(color)
setColour(colour)
setTimestamp(timestamp)
addField(name, value, inline)
removeField(index)
setField(index, name, value, inline)
spliceField(index, remove, name, value, inline)
insertField(index, name, value, inline)
clearFields()
popField()
shiftField()
swapField(index, otherIndex)
findField(name)
setFooter(text, iconURL)
setAuthor(name, iconURL, url)
setThumbnail(url)
setImage(url)
toJSON()

Represents a Discord server. In Discord's API, servers are referred to as "guilds".

Guild

Extends DiscordObject

Instance Members
name
region
icon
splash
members
channel
roles
fillMembers()
getMember(id)
getMemberNamed(query, options)
getRole(id)
createSlashCommand(command, callback)

Represents a channel that's present in a guild.

GuildChannel

Extends Channel

Instance Members
guild
position
name

Represents an interaction with a user. This is sent when a slash command is invoked, or a component was pressed.

Interaction

Extends DiscordObject

Instance Members
token
version
applicationID
type
data
channel
guild
message
author
respond(content, options, __overwrites)

Represents a guild member.

Member

Extends User

Instance Members
toUser()
nick
joinedAt

Represents a Discord message.

Message

Extends DiscordObject

Instance Members
author
tts
content
mentionsEveryone
pinned
type
editedAt
channel
guild
edit(content, options)
reply(content, options)
delete(delay)
addReaction(emoji)

Builds a raw message object out of the given content and options.

MessageBuilder
Parameters
destination (any) The destination of the message.
content (string?) The contents of the message.
options (object?) The message options, such as embeds and files.
type (string?) The type of message to send.
extra (...any) Extra data to use when building the message.
Instance Members
destinationID
referenceID
options
context
payload
files
type
build()
send()

Represents any emoji with minimal information.

PartialEmoji
Instance Members
id
name
requireColons
managed
animated
available
unicode
image
toString()
toJSON()

Represents a reaction on a Discord message.

Reaction
Instance Members
emoji
count
me
message
channel
guild
users(options)

Represents a Discord role.

Role

Extends DiscordObject

Instance Members
guild
name
color
hoist
position
permissions
managed
mentionable
premium
botID
integrationID
colour
members

Represents a map of snowflakes to their DiscordObjects (ones that have parameter id). This ensures that only one copy of any snowflake is present in this map.

SnowflakeSet

Extends Map

Instance Members
push(objects)
filter(predicate)
find(predicate)

Represents a text channel in a guild.

TextChannel

Extends GuildChannel

Instance Members
topic
nsfw
lastMessage
getMessage(id)
send(content, options)

Represents a Discord user.

User

Extends DiscordObject

Instance Members
name
discriminator
avatar
bot
system
tag
mention
displayName
avatarAnimated
defaultFormat
avatarURL
avatarUrlAs(options)

Represents a bot using the commands plugin. This class extends Client.

Bot

Extends Client

Instance Members
addDefaultListeners()
getPrefix(message)
getCommand(query)
getContext(message)
invoke(ctx)
command(options, callback)
getFlagPrefix(message)
getShortFlagPrefix(message)

Represents a bot command.

Command
Instance Members
name
aliases
cooldowns
checks
args
flags
parent
qualifiedName
parents
commands
command(options, callback)
getSignature(options)
signature
usage
getArguments(ctx, content)
_parseArguments(ctx, content)
_parseFlags(ctx, content, flagPrefix, shortPrefix)
invoke(ctx, args, flags)

On mobile, -- is usually replaced by an em dash. Here we reverse this.

content(content: string): string
Parameters
content (string) The content to replace long dashes.
Returns
string: The replaced content.

Represents the context of a command. This contains things such as the message, channel, and command the author invoked.

Context
Instance Members
cleanPrefix
now
unix
invoke(command, args, flags)
reinvoke()
send(content, options)
reply(content, options)

The base converter class for the commands plugin.

Converter
Instance Members
convert(ctx, argument)

A utility class that helps parse words out of a string.

new StringView(text: any, quotes: any)
Parameters
text (any)
quotes (any = defaultQuotes)
Instance Members
text
quotes
index
previous
end
eof
buffer
getChar()
rollback()
getRest()
skipSpace()
getWord(options)

BasicReverseStringView

js-cord/plugins/commands/View.js

Represents a reversed StringView.

No support for quotes here, this was primarily made to get a command from a string.

new BasicReverseStringView(text: any)
Parameters
text (any)

General utility functions and classes.

utils
Static Members
BasePaginator
Paginator
sum
sleep(milliseconds)
urandom(bits)
maybePromise(func, args)
parseEmoji(emoji)
parseSnowflake(snowflake)
index(object, value)
isSubclass(cls, checks)
range(start, stop, step)
enumerate(gen, start)
regexEscape(literalString)
time
randint(min, max)