Plugin

Abstract class for Client plugins to extend. Provides runtime errors for missing method implementations, and is necessary at compile-time when using TypeScript for the compiler to recognize a Plugin as valid.

Plugins will always be passed the YAMDBF Client instance when loaded. If you intend to do anything with it you must receive it in your plugin constructor which means you will need a super() call since you will be overriding the parent Plugin constructor

A plugin should be a self-contained module that provides additional functionality for a Client. A plugin could do something as simple as logging all command output to a logging channel, registering a set of custom commands for the client to use, or even providing new localization language packs.

A plugin should not attempt to register custom commands via any means other than <Client>.commands.registerExternal(), otherwise any custom commands could be unloaded if the reload command is called

Note: A plugin is expected to have two things at runtime: a name property containing the name of the plugin, and an init() method that will be called by the framework after loading the plugin.
See: IPlugin#name and IPlugin#init
Warning: Given the nature of the Plugin system, this allows you to use code from other people for your bot. Considering any plugin will have access to your Client instance and thus your Bot token, you should be absolutely certain that the plugin is not going to do anything malicious before using it

Constructor

(abstract) new Plugin(client: Client)

Parameters:
Name Type Description
client
Client

The YAMDBF Client instance. This will be passed by the plugin loader when the plugin is loaded at runtime. This will automatically be received and stored under <Plugin>.client unless you provide your own constructor implementation, in which case it must be received and passed to super()

Implements:
Source:

Methods

.init() → Promise<void> | void

Method that will be called by the Plugin loader when the Plugin is loaded. This is the only method that will be called by the framework automatically, so this should be where anything necessary should be done to make the Plugin operational.

This method can be async if desired or needed

Implements:
Source:
Returns:
Promise<void>
|
void