Constructor
new Client(options: YAMDBFOptions, clientOptions?: ClientOptions)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
|
Object containing required client properties |
|
clientOptions |
|
<optional> |
Discord.js ClientOptions |
- Source:
Extends
Events
blacklistAdd
Emitted whenever a user is blacklisted
Parameters:
Name | Type | Description |
---|---|---|
user |
|
User who was blacklisted |
global |
|
Whether or not blacklisting is global |
- Source:
blacklistRemove
Emitted whenever a user is removed from the blacklist
Parameters:
Name | Type | Description |
---|---|---|
user |
|
User who was removed |
global |
|
Whether or not removal is global |
- Source:
clientReady
Emitted when the client is ready. Should be used instead of Discord.js'
ready
event, as this is the point that everything is set up within the
YAMDBF Client and it's all ready to go
- Source:
command
Emitted whenever a command is successfully called
Parameters:
Name | Type | Description |
---|---|---|
name |
|
Name of the called command |
args |
|
Args passed to the called command |
execTime |
|
Time command took to execute |
message |
|
Message that triggered the command |
- Source:
continue
To be emitted after the pause
event when you have finished setting
things up that should be set up before the client is ready for use
- Source:
noCommand
Emitted whenever a message is received that does not contain a command or unknown command
Parameters:
Name | Type | Description |
---|---|---|
message |
|
Message that did not contain a command or unknown command |
- Source:
pause
Emitted when the client is waiting for you to send a continue
event,
after which clientReady
will be emitted
- Source:
unknownCommand
Emitted whenever a command is called that doesn't exist
Parameters:
Name | Type | Description |
---|---|---|
name |
|
The name of the command that was attempted to be called |
args |
|
Args passed to the unknown command |
message |
|
Message that triggered the unknown command |
- Source:
Properties
.argsParser: function
The argument parsing function the framework will use to parse
command arguments from message content input. Defaults to
splitting on Command#argOpts.separator
- Source:
.buttons: object
Button shortcuts for compact mode. Defaults are
success
, fail
, and working
. These can be overwritten
via the buttons
field in YAMDBFOptions
- Source:
.commands: CommandRegistry<string, Command>
.commandsDir: string
Directory to find command class files. Optional
if client is passive.
See: Client#passive
- Source:
.compact: boolean
.defaultLang: string
.disableBase: BaseCommandName[]
Array of base command names to skip when loading commands. Base commands may only be disabled by name, not by alias
- Source:
.dmHelp: boolean
Whether or not the help command should send its output in a DM to the command caller
- Source:
.eventLoader: EventLoader
The EventLoader the client uses to load events. The client will load events
from the eventsdir
directory passed in your YAMDBFOptions
.
Can be used by plugins to register directories to load custom event handlers from
- Source:
.eventsDir: string
Directory to find Event class files. Optional
if client is passive.
See: Client#passive
- Source:
.localeDir: string
.owner: string[]
The owner/owners of the bot, represented as an array of IDs.
These IDs determine who is allowed to use commands flagged as
ownerOnly
- Source:
.passive: boolean
Whether or not this client is passive. Passive clients will not register a command dispatcher or a message listener. This allows passive clients to be created that do not respond to any commands but are able to perform actions based on whatever the framework user wants
- Source:
.pause: boolean
Whether or not the client will pause after loading Client
Storage, giving the opportunity to add/change default
settings before guild settings are created for the first
time. If this is used, you must create a listener for 'pause'
,
and call <Client>.continue()
when you have finished doing
what you need to do.
If adding new default settings is desired after guild settings
have already been generated for the first time, they should be
added after 'clientReady'
so they can be properly pushed to
the settings for all guilds
- Source:
.plugins: PluginLoader
Loads plugins and contains loaded plugins in case accessing a loaded plugin at runtime is desired
- Source:
.provider: StorageProvider
The chosen storage provider to use for the Client.
Defaults to JSONProvider
- Source:
.ratelimit: string
.rateLimitManager: RateLimitManager
A convenient instance of RateLimitManager
for use anywhere
the Client is available
- Source:
.readyText: string
Text to output when the client is ready. If not
provided nothing will be logged, giving the
opportunity to log something more dynamic
on clientReady
- Source:
.resolvers: ResolverLoader
.statusText: string
.storage: ClientStorage
Client-specific storage. Also contains a guilds
Collection property containing
all GuildStorage instances
- Source:
.tsNode: boolean
Whether or not ts-node is in use, allowing the Client to attempt to load .ts files when loading Commands
- Source:
.unknownCommandError: boolean
Whether or not a generic 'command not found' message
should be given in DMs to instruct the user to
use the help
command. true
by default
- Source:
Methods
.continue() → void
.createBotInvite() → Promise<string>
Generate a bot invite URL based on the permissions included in all of the commands the client currently has loaded.
Note: This should be run after
clientReady
to ensure no command permissions are missing from the permissions set that will be used to generate the URL
- Source:
.defaultSettingExists(key: string) → Promise<boolean>
Check if a default guild setting exists
Parameters:
Name | Type | Description |
---|---|---|
key |
|
The default settings key to check for |
- Source:
.getPrefix(guild: Guild) → Promise<string | null>
Shortcut to return the command prefix for the provided guild
Parameters:
Name | Type | Description |
---|---|---|
guild |
|
The Guild to get the prefix of |
- Source:
.isOwner(user: User) → boolean
Returns whether or not the given user is an owner of the client/bot
Parameters:
Name | Type | Description |
---|---|---|
user |
|
User to check |
- Source:
.removeDefaultSetting(key: string) → Promise<Client>
Remove a defaultGuildSettings
item. Will not remove from any current
guild settings, but will remove the item from the defaults added to
new guild settings storages upon creation
Parameters:
Name | Type | Description |
---|---|---|
key |
|
The key to use in settings storage |
- Source:
.setDefaultSetting(key: string, value: any) → Promise<Client>
Set the value of a default setting key and push it to all guild setting storages. Will not overwrite a setting in guild settings storage if there is already an existing key with the given value
Parameters:
Name | Type | Description |
---|---|---|
key |
|
The key to use in settings storage |
value |
|
The value to use in settings storage |
- Source:
.start() → Client
.sweepStorages() → Promise<void>
.use(func: MiddlewareFunction) → Client
Adds a middleware function to be used when any command is called to make modifications to args, determine if the command can be run, or anything else you want to do every time any command is called.
See MiddlewareFunction
for information on how a middleware
function should be represented
Usage example:
<Client>.use((message, args) => [message, args.map(a => a.toUpperCase())]);
This will add a middleware function to all commands that will attempt to transform all args to uppercase. This will of course fail if any of the args are not a string.
Note: Middleware functions should only be added to the client one time each and thus should not be added within any sort of event or loop. Multiple separate middleware functions can be added to the via multiple separate calls to this method
Warning: Do not use middleware for overriding the default argument splitting. Use
YAMDBFOptions.argsParser
instead. Otherwise you will see inconsistent results when using Command shortcuts, as argument splitting for shortcut interpolation always happens before middleware is run
Parameters:
Name | Type | Description |
---|---|---|
func |
|
The middleware function to use |
- Source: