Bot

Bot

Manages the connection to Discord and interaction between plugins

Constructor

new Bot(options, rLoggeropt, rChatHandleropt)

See:
Properties:
Name Type Description
carbonBotsKey String

The API key for carbon bot list

discordBotsKey String

The API key for bots.discord.pw

discordBotsOrgKey String

The API key for discordbots.org

botsOnDiscordKey String

The API key for bots.ondiscord.xyz

logger function

The logging wrapper

chatHandler function

The class handling chat messages

blacklistedGuilds Array.<String>

Guilds that are banned from using the bot

blacklistedUsers Array.<String>

Users that are banned from using the bot

commandPlugins Object

The loaded command plugins

eventPlugins Object

The loaded event plugins

middleware Object

The loaded middleware

Creates a new instance of Mirai

Parameters:
Name Type Attributes Description
options Object

An object defining the configuration for Mirai

Properties
Name Type Attributes Description
token String

The token for your bot

carbonBotsKey String <optional>

An API key for carbon bot list

discordBotsKey String <optional>

An API key for bots.discord.pw

discordBotsOrgKey String <optional>

An API key for discordbots.org

botsOnDiscordKey String <optional>

An API key for bots.ondiscord.xyz

blacklistedGuilds Array.<String> <optional>

Guilds that are banned from using the bot

blacklistedUsers Array.<String> <optional>

Users that are banned from using the bot

gracefulExit Boolean <optional>

When SIGINT is received, destroy all plugins and middleware, and disconnect the bot

eris Object <optional>

The options to pass to the eris client. See the Eris docs

logger Object <optional>

The options to pass to the logger

chatHandler Object <optional>

The options to pass to the chatHandler

rLogger function <optional>

A replacement Logger. Must implement log info debug warn and error. Is passed this and options.logger

rChatHandler function <optional>

A replacement ChatHandler. Must implement run and stop. Is passed this and options.chatHandler

Extends

  • Eris.Client

Methods

findMember(query, members) → (nullable) {Member}

See:

Resolve a name or ID to a guild member

Parameters:
Name Type Description
query String

The name or ID to match

members Collection

The Collection of guild members

Returns:

The member the was found

Type
Member

findUser(query) → (nullable) {User}

See:

Resolve a name or ID to a user

Parameters:
Name Type Description
query String

The name or ID to match

Returns:

The user the was found

Type
User

(async) loadCommandPlugin(plugin) → {Promise}

See:
Example

Loading a Command Plugin

var funCommands = new FunCommandsPlugin();
mirai.loadCommandPlugin(funCommands);
Parameters:
Name Type Description
plugin function

The plugin to load. Must have a load method which is passed this

Returns:

The return value of plugin.load

Type
Promise

(async) loadEventPlugin(plugin) → {Promise}

Parameters:
Name Type Description
plugin function

The plugin to load. Must have a load method which is passed this

Returns:

The return value of plugin.load

Type
Promise

(async) loadMiddleware(middleware) → {Promise}

Parameters:
Name Type Description
middleware function

The middleware to load. Must have a load method which is passed this

Returns:

The return value of middleware.load

Type
Promise

(async) reloadCommandPlugin(plugin) → {Promise}

Reload a plugin by searching for a plugin with the same name and replacing it

Parameters:
Name Type Description
plugin function

The plugin to load. Must have a load method which is passed this

Returns:

The return value of plugin.load

Type
Promise

(async) reloadEventPlugin(plugin) → {Promise}

Reload a plugin by searching for a plugin with the same name and replacing it

Parameters:
Name Type Description
plugin function

The plugin to load. Must have a load method which is passed this

Returns:

The return value of plugin.load

Type
Promise

(async) reloadMiddleware(middleware) → {Promise}

Reload middleware by searching for middleware with the same name and replacing it

Parameters:
Name Type Description
middleware function

The middleware to load. Must have a load method which is passed this

Returns:

The return value of middleware.load

Type
Promise

(async) setAvatar(url) → {Promise}

Sets the bot's avatar from a url

Parameters:
Name Type Description
url String

A direct link to an image

Returns:

Resolves on completion

Type
Promise

(async) updateBotsOnDiscord(keyopt) → {Promise}

See:

Updates information on bots.ondiscord.xyz

Parameters:
Name Type Attributes Description
key String <optional>

bots.ondiscord.xyz API key

Returns:

The axios request result or error

Type
Promise

(async) updateCarbon(keyopt) → {Promise}

See:

Updates information on carbonitex.net

Parameters:
Name Type Attributes Description
key String <optional>

Carbon API key

Returns:

The axios request result or error

Type
Promise

(async) updateDiscordBots(keyopt) → {Promise}

See:

Updates information on bots.discord.pw

Parameters:
Name Type Attributes Description
key String <optional>

bots.discord.pw API key

Returns:

The axios request result or error

Type
Promise

(async) updateDiscordBotsOrg(keyopt) → {Promise}

See:

Updates information on discordbots.org

Parameters:
Name Type Attributes Description
key String <optional>

discordbots API key

Returns:

The axios request result or error

Type
Promise