A powerful and flexible library for modularizing Discord.js clients.
Constructor.
Name | Type | Description | |
---|---|---|---|
options |
ClientOptions
|
|
|
options.prefix |
PrefixType
|
|
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
filter |
Function
|
|
Void
Tests a message and determines if it passes the filter.
Name | Type | Description | |
---|---|---|---|
message |
Message
|
|
boolean
RegExp
Returns false
if the message does not pass the filter, else a RegExp
which represents a prefix to test against the
message.
Constructor.
Name | Type | Description | |
---|---|---|---|
options |
Object
|
|
|
options.client |
Ghastly
|
|
|
options.prefix |
PrefixType
|
|
Void
The prefix filter constructed from the raw prefix.
Void
Resolves a given response value to a type.
Name | Type | Description | |
---|---|---|---|
response |
|
string
The type of the response, or null
if not recognized.
Generates a prefix filter.
Name | Type | Description | |
---|---|---|---|
prefix |
PrefixType
|
|
PrefixFilter
The prefix filter.
Determines if a message event should be filtered from the handler.
Name | Type | Description | |
---|---|---|---|
message |
Message
|
|
|
newMessage |
Message
|
|
Optional |
boolean
true
if the message should be filtered, else false
.
Determines if a message should be filtered from the handler based on the given prefix.
Name | Type | Description | |
---|---|---|---|
prefix |
RegExp
|
|
|
message |
Message
|
|
boolean
true
if the message should be filtered, else false
.
Constructor.
Name | Type | Description | |
---|---|---|---|
filter |
|
Void
Tests a message and determines if it passes the filter.
Name | Type | Description | |
---|---|---|---|
message |
Message
|
|
boolean
true
if the message passes the filter, else false
.
Constructor.
Name | Type | Description | |
---|---|---|---|
filter |
RegExp
|
|
Void
Tests a message and determines if it passes the filter.
Name | Type | Description | |
---|---|---|---|
message |
Message
|
|
boolean
true
if the message passes the filter, else false
.
Constructor.
Name | Type | Description | |
---|---|---|---|
aliases |
Array.<string>
|
|
|
builder |
Function
|
|
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
aliases |
Array.<string>
|
|
|
instance |
|
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
options |
Object
|
|
|
options.aliases= |
Array.<string>
|
|
Optional |
options.builder=null |
Function
|
|
Optional |
options.instance=null |
|
Optional |
Void
The service builder. Only applicable to constructed and singleton services.
Void
The service instance. Only applicable to singleton and instance services.
Void
Returns an iterator containing the main service bindings that have been registered.
Void
Binds a service to the container which is rebuilt each time it is fetched.
Name | Type | Description | |
---|---|---|---|
identifier |
string
Array.<string>
|
|
|
builder |
Function
|
|
ServiceContainer
The instance this method was called on.
Binds a service to the container which is built once and cached for subsequent fetches.
Name | Type | Description | |
---|---|---|---|
identifier |
string
Array.<string>
|
|
|
builder |
Function
|
|
ServiceContainer
The instance this method was called on.
Binds a service to the container which is returned as a value each time it is fetched.
Name | Type | Description | |
---|---|---|---|
identifier |
string
Array.<string>
|
|
|
value |
|
ServiceContainer
The instance this method was called on.
Binds services to the service container via service providers.
Name | Type | Description | |
---|---|---|---|
providers |
serviceProvider
|
|
Dispatcher
The instance this method was called on.
Removes a binding from the container, along with its aliases.
Name | Type | Description | |
---|---|---|---|
identifier |
string
|
|
ServiceContainer
The instance this method was called on.
Determines if an identifier has been bound in the container.
Name | Type | Description | |
---|---|---|---|
identifier |
string
|
|
boolean
True if the identifier was bound.
Fetches a service from the container, constructing it if necessary.
Name | Type | Description | |
---|---|---|---|
identifier |
string
|
|
The service requested, or null
if no service was bound under that identifier.
Returns the main bound identifier for an alias. If the alias is already a main bound identifier, that identifier is returned directly.
Name | Type | Description | |
---|---|---|---|
alias |
string
|
|
string
The main bound identifier for the given alias, or undefined
if this alias was not previously bound.
Adds a service to the container.
Name | Type | Description | |
---|---|---|---|
type |
string
|
|
|
identifier |
string
Array.<string>
|
|
|
service |
|
ServiceContainer
The instance this method was called on.
Constructor.
Name | Type | Description | |
---|---|---|---|
aliases |
Array.<string>
|
|
|
builder |
Function
|
|
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
name |
string
|
|
Void
Adds a command to the group.
Name | Type | Description | |
---|---|---|---|
command |
CommandObject
|
|
CommandGroup
The instance this method was called on.
Adds the given middleware to the current group middleware layers.
Name | Type | Description | |
---|---|---|---|
layers |
middlewareLayer
|
|
CommandGroup
The instance this method was called on.
Constructor.
Name | Type | Description | |
---|---|---|---|
configuration |
CommandConfiguration
|
|
Void
A mapping between service names and the context names they should be injected under for the command handler.
Void
The command handler function with middleware applied to it.
Void
Applies middleware to a command handler and returns the resulting handler function.
Name | Type | Description | |
---|---|---|---|
handler |
Function
|
|
|
middleware |
Array.<middlewareLayer>
|
|
Function
The command handler with middleware applied to it.
Executes the command handler.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
Promise.<Object>
Promise resolving to the response object.
Subscribes to updates from a command group.
Name | Type | Description | |
---|---|---|---|
commandGroup |
CommandGroup
|
|
Void
Adds the given commands to the registry.
Name | Type | Description | |
---|---|---|---|
configurators |
commandConfigurator
|
|
CommandRegistry
The instance this method was called on.
Gets a command from the registry.
Name | Type | Description | |
---|---|---|---|
identifier |
string
|
|
CommandObject
The CommandObject
in the registry, or null
if it couldn't be found.
Applies middleware to a command group.
Name | Type | Description | |
---|---|---|---|
group |
string
|
|
|
middleware |
Array.<middlewareLayer>
|
|
CommandRegistry
The instance this method was called on.
Adds a command to the registry.
Name | Type | Description | |
---|---|---|---|
command |
CommandObject
|
|
CommandRegistry
The instance this method was called on.
Returns the main name associated with an identifier.
Name | Type | Description | |
---|---|---|---|
identifier |
string
|
|
string
The main name associated with this identifier, or undefined
if none exists.
Adds command aliases to the registry.
Name | Type | Description | |
---|---|---|---|
name |
string
|
|
|
aliases |
Array.<string>
|
|
CommandRegistry
The instance this method was called on.
Parses an array of arguments for a command call.
Name | Type | Description | |
---|---|---|---|
rules |
Array.<ParsedParameter>
|
|
|
args |
string
|
|
Object
The parsed arguments given in a mapping between argument names and values.
Converts an argument to the given type, ignoring string arguments.
Name | Type | Description | |
---|---|---|---|
type |
string
|
|
|
argument |
string
|
|
ParameterType
The converted argument.
Parses the given message for a command.
Name | Type | Description | |
---|---|---|---|
message |
Message
|
|
|
prefix |
RegExp
|
|
ParsedCommand
Data parsed from the message content.
Validates a set of parameters.
Name | Type | Description | |
---|---|---|---|
parameters |
ParameterDefinition
string
|
|
Array.<ParsedParameter>
The validated parameters.
Parses a set of parameters into ParsedParameter
objects.
Name | Type | Description | |
---|---|---|---|
parameters |
ParameterDefinition
string
|
|
Array.<ParsedParameter>
The parsed parameters.
Parses the given command parameter definition and returns an object containing data on it.
Name | Type | Description | |
---|---|---|---|
parameter |
String
|
|
ParameterDefinition
Object containing data on the command parameter.
Parses the definition portion of a parameter string.
Name | Type | Description | |
---|---|---|---|
definition |
string
|
|
Object
An object containing data on the parsed parameter definition.
Constructor.
Name | Type | Description | |
---|---|---|---|
values |
Object
|
|
|
values.raw |
string
|
|
|
values.trimmed |
string
|
|
|
values.identifier |
string
|
|
|
values.args |
Array.<string>
|
|
|
values.rawArgs |
string
|
|
Void
The raw message content with any command prefix trimmed from the start.
Void
A space-delimited array of arguments that were given as part of the command.
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
values |
ParameterDefinition
|
|
Void
Whether or not the parameter accepts a variable number of input arguments.
Void
Whether or no the parameter is a literal string, i.e. takes the value of the input as given. Can only be applied to string parameters.
Void
The default value of the parameter. This is non-null only if the parameter is optional. The default value for a repeatable parameter will be an array of values while non-repeatable parameters store a single primitive as a default value. The types of these values are determined by the parameters's type declaration defaulting to strings.
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
|
input |
string
|
|
|
options={} |
StreamOptions
|
|
Optional |
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
|
broadcast |
VoiceBroadcast
|
|
|
options={} |
StreamOptions
|
|
Optional |
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
|
stream |
ReadableStream
|
|
|
options={} |
StreamOptions
|
|
Optional |
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
|
file |
string
|
|
|
options={} |
StreamOptions
|
|
Optional |
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
|
stream |
ReadableStream
|
|
|
options={} |
StreamOptions
|
|
Optional |
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
executor |
Function
|
|
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
|
stream |
ReadableStream
|
|
|
options={} |
StreamOptions
|
|
Optional |
Void
Constructor.
Name | Type | Description | |
---|---|---|---|
context |
Object
|
|
|
inputMethod |
VoiceInputMethod
|
|
|
payload |
|
||
options={} |
StreamOptions
|
|
Optional |
Void
Composes a set of functions into a chain of middleware. The last function
acts as the innermost part of the middleware chain. For instance,
compose(f, g)
returns a function with contract (...args) => f(g, ...args)
.
Name | Type | Description | |
---|---|---|---|
functions |
Function
|
|
Function
The composed chain of middleware.
Takes a set of middleware functions and returns a function which consumes a single command handler function and produces a new handler function with the given middleware applied to it.
Name | Type | Description | |
---|---|---|---|
middleware |
middlewareLayer
|
|
Function
Function consuming a single command handler function and returns a new handler function with the given middleware applied to it.
Properties which are automatically handled when using object configurations.
Void
Provides a bridge to provide configuration data for command configurators.
Consumes a config object containing the configuration data and produces a
function. This function consumes a configurator and returns another configurator
with the given configuration applied to it.
Several configure()
calls can be made successively on the returned configurator,
with the outer config objects overwriting the keys in the innermost configs.
Name | Type | Description | |
---|---|---|---|
configuration |
Object
|
|
Function
A function consuming a configurator and producing another configurator with the provided config applied to it.
Middleware which filters out messages not received in a DM context.
middlewareLayer
The layer which filters the messages.
Middleware which filters out messages not received in a group DM context.
middlewareLayer
The layer which filters the messages.
Middleware which filters out messages not received in a guild context.
middlewareLayer
The layer which filters the messages.
Middleware which filters out messages based on user permissions. Members must possess all of the given permissions to pass the filter. Only filters out messages if in a guild context.
Name | Type | Description | |
---|---|---|---|
permissions |
PermissionResolvable
|
|
expectPermissions(
'MUTE_MEMBERS',
'DEAFEN_MEMBERS',
);
middlewareLayer
The layer which filters the messages.
Middleware which filters out messages based on user role IDs or names. Only filters out messages if in a guild context.
Name | Type | Description | |
---|---|---|---|
identifiers |
string
|
|
expectRole(
'750315226641451132',
'Batman',
);
middlewareLayer
The layer which filters the messages.
Middleware which filters out messages based on user IDs or usernames and discriminators.
Name | Type | Description | |
---|---|---|---|
identifiers |
string
|
|
expectUser(
'275532051244111663',
'LiamNeeson#5364',
);
middlewareLayer
The layer which filters the messages.
Middleware which filters out messages based on the channel type.
Name | Type | Description | |
---|---|---|---|
type |
string
|
|
middlewareLayer
The layer which filters the messages.
Validates the given options object and returns a promise.
Name | Type | Description | |
---|---|---|---|
options={} |
Object
|
|
Optional |
Object
Custom version of krachot/options-resolver that supports synchronous resolution.
Object
Formats a string as italic text.
Name | Type | Description | |
---|---|---|---|
text |
string
|
|
string
The formatted Markdown string.
Formats a string as bold text.
Name | Type | Description | |
---|---|---|---|
text |
string
|
|
string
The formatted Markdown string.
Formats a string as strikeout text.
Name | Type | Description | |
---|---|---|---|
text |
string
|
|
string
The formatted Markdown string.
Formats a string as underlined text.
Name | Type | Description | |
---|---|---|---|
text |
string
|
|
string
The formatted Markdown string.
Formats a string as inline code.
Name | Type | Description | |
---|---|---|---|
text |
string
|
|
string
The formatted Markdown string.
Formats a string as multi-line code.
Name | Type | Description | |
---|---|---|---|
text |
string
|
|
|
syntax='' |
string
|
|
Optional |
string
The formatted Markdown string.
Constructor.
Name | Type | Description | |
---|---|---|---|
iterable |
|
Void
Removes a key from the map.
Name | Type | Description | |
---|---|---|---|
key |
string
|
|
boolean
True if an element is removed, else false.
Returns a value from the map.
Name | Type | Description | |
---|---|---|---|
key |
string
|
|
The returned value if found, else undefined
.
Checks if a key exists in the map.
Name | Type | Description | |
---|---|---|---|
key |
string
|
|
boolean
True if the key is found, else false.
Sets a value in the map.
Name | Type | Description | |
---|---|---|---|
key |
string
|
|
|
value |
|
StringMap
The instance this method was called on.