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:
pause
Emitted when the client is waiting for you to send a continue
event,
after which clientReady
will be emitted
- Source:
Properties
.commands: CommandRegistry<string, Command>
.commandsDir: string
Directory to find command class files. Optional
if client is passive.
See: Client#passive
- Source:
.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:
.localeDir
Directory to find custom localization files
- Source:
.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 emit '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:
.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:
.selfbot: boolean
.statusText: string
.storage: ClientStorage
Client-specific storage. Also contains a guilds
Collection property containing
all GuildStorage instances
- Source:
.unknownCommandError: string
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
.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:
.loadCommand(command: string) → void
Loads/reloads all/specific commands
Parameters:
Name | Type | Description |
---|---|---|
command |
|
The name of a command to reload, or 'all' to load all commands |
- 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() → void
Clean out any guild storage/settings that no longer have an associated guild
- Source:
.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
Parameters:
Name | Type | Description |
---|---|---|
func |
|
The middleware function to use |
- Source: