Addon class
The Addon class extends the NodeJS built-in EventEmitter class.
constructor
The Addon class requires one argument in the constructor which is an object with information about the addon. The object must contain the following information:
name
: The name of your addon to communicate to the owner of the bot. A string between 1-50 characters.description
: A brief description about what your addon does to communicate to the owner of the bot. A string between 1-100 characters.author
: The (user)name of the author of your addon to communicate to the owner of the bot. A string between 1-50 characters.version
: The version of your addon to communicate to the owner of the bot. A string between 1-10 characters.permissions
: An array with the permissions your addon requires in order to functionate.
options
An object which provides the required data to create the addon. The information which has to be provided is mentioned above.
Properties
name
The name of the addon which was provided in the constructor.
description
The description of the addon which was provided in the constructor.
author
The author of the addon which was provided in the constructor.
version
The version of the addon which was provided in the constructor.
permissions
A number which defines which permissions the addon has based on the permissions which were provided in the constructor.
ready
A boolean which defines whether the addon was accepted by the owner and can be used.
guilds
A save which provides the guilds the bot has access to.
Save<id(string), Guild>
channels
A save which provides the channels the bot has access to.
Save<channelId, TextChannel | VoiceChannel | CategoryChannel | StageChannel | DirectoryChannel | ForumChannel | ThreadChannel | DMChannel>
commands
A save which provides the commands that have been created by the addon.
Save<command name(string), CommandHandler>
Functions
createCommand
Creates a new command with the data of the CommandBuilder and returns a Promise which returns a CommandHandler once the Promise is fulfilled.
removeCommand
Removes a command which was created earlier by the same addon. The function returns a Promise
which will be fulfilled once the command has been deleted.
commandName
The name of the command you'd like to remove.
getCommandData
Gets the information about a certain command. This is the raw data for a CommandBuilder class which can be used in the constructor to build a command.
commandName
The name of the command where you'd like to get the information of.
createEventListener
Returns an EventEmitter which gets emitted when certain events happen. Only the events where your addon has permissions for, will be emitted. You can see here which events there are and which permissions are required for the events.
createCommandListener
Returns an EventEmitter which gets emitted when a command gets executed. The addon needs the COMMANDS
permission for the EventEmitter to emit events. The event name is the same as the command's name.
Listener parameters:
Information about the command that has been executed including functions to reply to the command for example.
next
A function which communicates with the library that another command listener is allowed to respond to the command.
abort
A function which cancels all the other command listeners to use the command listener and makes the current listener make the final response to the command.
getBot
Returns a Promise which returns a Bot class once the Promise is fulfilled. To fulfill the Promise, your addon needs the BOT
permission.
getHTTPServer
Returns a Promise which returns a HTTPServer. The HTTPServer will be returned if a port is set by the owner of the bot for the HTTP server to listen to and if the addon has the SERVERS
permission. The HTTPServer listens to GET and POST requests and can respond to them.
getWSServer
Returns a Promise which returns a WebSocketHandler. The WebSocketHandler will be returned if a port is set by the owner of the bot for the WebSocket server to listen to and if the addon has the SERVERS
permission. The WebSocketHandler allows for client users to connect with a WebSocket server and to communicate between the server and client user.
getRawSaves
Returns a Promise which returns an object with the raw data of the saves of the bot. The Promise will be fulfilled if the addon has the SAVES
permission. The object has the following structure:
Events
ready
Gets emitted when the bot owner has enabled the addon and the addon is ready to be used.
The ready event doesn't return any parameters.
Last updated