Decorators
deprecatedClass(message?: string) → ClassDecorator
Logs a deprecation warning for the decorated class if an instance is created
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
|
<optional> |
Class deprecation message |
deprecatedMethod(message?: string) → MethodDecorator
Logs a deprecation warning for the decorated class method if it is called within the current process
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
|
<optional> |
Method deprecation message |
logger
Property decorator that will automatically assign the Logger singleton instance to the decorated class property
Example:
class Foo {
@logger private readonly logger: Logger;
...
Note: This is a Typescript feature. If using the logger is desired in Javascript you should simply retrieve the singleton instance via
Logger.instance()
Type Definitions
ArgOpts
Object containing options for controlling how command arguments will be parsed
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
separator |
|
<optional> |
' '
|
The charactor to separate args by |
- Source:
BaseResolverType
Valid argument resolver types
for use with resolve
and
expect
. Can be one of
the following string literals:
'String'
| 'Number'
| 'Boolean'
| 'Duration'
| 'User'
| 'Member'
| 'BannedUser'
| 'Channel'
| 'Role'
| 'Command'
| 'CommandGroup'
| 'Any'
or an Array of possible string literal values
BaseStrings
Enum containing all base framework localization string keys
CommandInfo
Object containing required Command
properties
to be passed to a Command on construction
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
|
See: |
||
desc |
|
See: |
||
usage |
|
See: |
||
info |
|
<optional> |
See: |
|
group |
|
<optional> |
'base'
|
See: |
aliases |
|
<optional> |
[]
|
See: |
guildOnly |
|
<optional> |
false
|
See: |
hidden |
|
<optional> |
false
|
See: |
argOpts |
|
<optional> |
See: |
|
callerPermissions |
|
<optional> |
[]
|
|
clientPermissions |
|
<optional> |
[]
|
|
roles |
|
<optional> |
[]
|
See: |
ownerOnly |
|
<optional> |
false
|
See: |
ratelimit |
|
<optional> |
Sets a rate limit on calls to this command for every user |
|
lockTimeout |
|
<optional> |
30000
|
The time until command locks will expire automatically |
- Source:
DefaultGuildSettings
The default settings to apply to new guilds.
Stored under the key 'defaultGuildSettings'
in Client#storage
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
prefix |
|
'/'
|
Prefix denoting a command call |
|
disabledGroups |
|
<optional> |
[]
|
Command groups to ignore |
Difference
Represents a difference between two given valid Unix time signatures
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
raw |
|
Total number of MS difference |
|
days |
|
<nullable> |
Number of days spanned |
hours |
|
<nullable> |
Number of hours spanned after higher units are subtracted |
minutes |
|
<nullable> |
Number of minutes spanned after higher units are subtracted |
secs |
|
<nullable> |
Number of seconds spanned after higher units are subtracted |
ms |
|
Number of ms spanned after higher units are subtracted |
|
toString() |
|
Returns duration formatted as |
|
toSimplifiedString() |
|
Returns duration formatted as |
- Source:
LocalizedCommandInfo
Represents an object
containing localization overrides for a command's desc
,
info
, and usage
fields
LogData
Represents an object passed from the Logger
to the TransportFunction
of any Transport
s given to it
Properties:
Name | Type | Description |
---|---|---|
timestamp |
|
Holds the time/date for this log |
type |
|
The log type. Will be one of:
|
tag |
|
The tag given for this log |
text |
|
The text content of this log |
- Source:
LogLevel
Enum containing the different levels of
potential logger output. Each level represents itself and everything
above it in the enum. The default logger log level is LogLevel.LOG
enum LogLevel
{
NONE,
LOG,
INFO,
WARN,
ERROR.
DEBUG
}
- Source:
MiddlewareFunction
A function that takes a Message
object and an array of args, does anything with them, and returns a
Tuple
where the first item is the Message object and the
second item is the array of args
(Message, any[]) => [Message, any[]]
Can be async as long as the returned promise resolves with the tuple containing the message object and the args array as expected.
If a middleware function returns a string, or throws a string/error, it will be sent to the calling channel as a message and the Command execution will be aborted. If a middleware function does not return anything or returns something other than an array or string, the Command will fail silently.
Note: The command dispatcher will attempt to bind the Command instance to the middleware function when called, so
this
within a middleware function (if it is not an arrow function) will be the Command instance at runtime
PluginConstructor
Any class that extends and
implements Plugin
. Not to be confused with an instance
of a Plugin.
ResolverConstructor
Any class that extends and
implements Resolver
. Not to be confused with an instance
of a Resolver.
ResourceLoader
Represents a function assigned to
a specific language that takes a string key and an optional
TemplateData
object and returns a localized string for
that language if it exists
- Deprecated:
- ResourceLoader functions have been replaced with
ResourceProxy
- ResourceLoader functions have been replaced with
- Source:
ResourceProxy
A Proxy where calling functions will treat the function name as a Lang string key and act as a ResourceLoader, requiring only the strings TemplateData (or nothing for non-dynamic strings)
TypeScript users can pass a generic type parameter to the ResourceProxy type which will append all the keys of the passed type to the valid keys on the ResourceProxy itself. This makes it easier to get type hinting for custom localization strings. Example:
type C = { FOO: any; BAR: any; }; ... let r: ResourceProxy<C> = Lang.createResourceProxy('en_us'); return r.FOO(); // `FOO` will be of type `(data?: TemplateData) => string` // so this returns a string
- Source:
RespondOptions
Object consisting of MessageOptions
and
an optional button
string field for compact mode support
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
button |
|
<optional> |
Unicode emoji string, custom enoji ID, or a key from the
Client's |
- Source:
StorageProviderConstructor
Any class that extends and
implements StorageProvider
and provides an interface with a storage
medium allowing data to be stored, retrieved, and manipulated. Not
to be confused with an instance of a storage provider.
TemplateData
Represents an object mapping template
keys to values, where the template keys will be replaced with
the provided values in the source string when given to a Lang resource
function/proxy like Lang.res()
- Source:
Transport
Represents a transport object for the Logger
.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
transport |
|
The transport function to use for this transport |
|
level |
|
<optional> |
The log level for this transport. Will default dynamically to the Logger's log level if none is provided |
- Source:
TransportFunction(data: LogData)
Represents a function to be included
in a Transport
object. This function will be given a LogData
object at runtime whenever a logger method is called. What is done with that
log data is entirely up to you as the developer, but logging to a file.
to a database, or even to a Discord channel would be some good examples
Parameters:
Name | Type | Description |
---|---|---|
data |
|
The data received from the logger |
Tuple
Represents an array of fixed length where the the item in the specified position is of the specified type.
Example:
['foo', 10] === [string, number] === Tuple<string, number>
- Source:
YAMDBFOptions
Object containing required Client
properties to be
passed to a Client on construction
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
token |
|
<optional> |
Token needed to connect the Client to Discord |
|
owner |
|
<optional> |
[]
|
Can also be a single string |
provider |
|
<optional> |
See: |
|
commandsDir |
|
<optional> |
See: |
|
eventsDir |
|
<optional> |
See: |
|
localeDir |
|
<optional> |
See: |
|
defaultLang |
|
<optional> |
See: |
|
statusText |
|
<optional> |
null
|
See: |
readyText |
|
<optional> |
'Client ready!'
|
See: |
unknownCommandError |
|
<optional> |
true
|
|
dmHelp |
|
<optional> |
true
|
See: |
passive |
|
<optional> |
false
|
See: |
pause |
|
<optional> |
false
|
See: |
disableBase |
|
<optional> |
[]
|
See: |
ratelimit |
|
<optional> |
Sets a global rate limit on command calls for every user |
|
logLevel |
|
<optional> |
Sets the logging level for the logger. Defaults to |
|
plugins |
|
<optional> |
[]
|
An array of Plugin classes (not instances) or plugin package name strings to be loaded and used |
customResolvers |
|
<optional> |
[]
|
An array of Resolver classes (not instances) |
argsParser |
|
<optional> |
Function taking an input string, an optional |
|
buttons |
|
<optional> |
Object mapping keys for easy access to unicode emoji strings or custom
emoji id strings. To be used by the Client when compact mode is active |
|
compact |
|
<optional> |
false
|
Whether or not compact mode should be used |
tsNode |
|
<optional> |
false
|
Whether or not ts-node is being used, allowing the CommandLoader to attempt to load .ts files when loading Commands |
- Source: