new Agent(data)
Create an Agent
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The agent data |
Properties:
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data.Eris |
Eris | The Eris class the system runs off of |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data.token |
String | The token to log in to the Discord API with |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data.handlerData |
Object |
<optional> |
{} | The commands and replacers the bot will respond to as well as options for their handlers Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data.options |
Object |
<optional> |
{} | Options for the agent Properties
|
Members
-
private _argTypeDescs : Object
-
Descriptions for argument types
-
private _assetURLs : Object
-
URLs to assets used internally
Properties:
Name Type Description helpString The help icon
-
private _Eris : Class
-
The Eris class
-
private _guildData : GuildData
-
Guild specific data
-
private _handlerData : Object
-
The commands and replacers the bot will respond to as well as options for their handlers
Properties:
Name Type Description commandsArray<Command> The commands for the command handler
reactCommandsArray<ReactCommand> The commands that trigger on reactions
replacersArray<Replacer> The replacers for the command handler
optionsObject The options for the handlers
Properties
Name Type Description prefixString The prefix to execute commands
replacerBracesObject The braces that invoke a replacer
Properties
Name Type Description openString The opening brace
closeString The closing brace
maxInterfacesNumber The maximum amount of interfaces cached before they start getting deleted
-
private _helpCache : Array<String>
-
A cache for the
buildHelpmethod -
private _middleware : Array<Middleware>
-
Middleware to run during command processing
-
private _options : Object
-
The options for the agent
Properties:
Name Type Description statusMessageObject | StatusMessageFunction The status for the bot. It can be an object containing the data, or a callback function for each shard. By default, it's the bot's prefix
fireOnEditBoolean Whether the command handler is called when a command is edited or not
fireOnReactionRemoveBoolean Whether the reaction handler triggers on the removal of reactions
postEventFunctionsObject A collection of functions to run after an event is triggered.
Properties
Name Type Description messagePostMessageFunction A function that runs after every message whether it triggers a command or not
reactionPostReactionFunction A function that runs after every reaction whether it triggers a react command or not
permissionPostPermissionFunction A function that runs after a permission is changed
prefixPostPrefixFunction A function that runs after a guild prefix is changed
-
app : Object
-
The Discord app of the bot
-
attachments : Object
-
User-supplied data that is passed to commands
-
client : Eris.Client
-
The Eris client
-
commandHandler : CommandHandler
-
The command handler for the bot
-
reactionHandler : ReactionHandler
-
The reaction handler for the bot
Methods
-
async, private _awaitGuildOptions(guildOptions)
-
Wait for guild options to be asynchronous supplied
Parameters:
Name Type Description guildOptionsPromise<GuildData> The promise returning the data
-
private _bindBaseEvents()
-
Bind actions to base events
-
private _bindHandlerEvents()
-
Bind actions to events that require handlers
-
private _checkPermissions(msg, member, command)
-
Check if a user has the sufficient permissions to use a command
Parameters:
Name Type Description msgEris.Message The message
memberEris.Member The subject member of the guild
commandCommand | ReactCommand The command
Throws:
-
private _compileInfo(items, header : opt) → {Array<String>}
-
Compile command info into a list
Parameters:
Name Type Attributes Description itemsArray<Command> | Command | Array<Replacer> | Replacer | Array<ReactCommand> | ReactCommand The items to compile
headerString <optional>
The header of the content
Returns:
Array<String> -The resulting info pages
-
private _formatPrefixesForHandler(data) → {Object}
-
Format guild data for command handler prefixes
Parameters:
Name Type Description dataGuilData The data
Returns:
Object -Returns an object where guild IDs are mapped to prefixes
-
private _getApp() → {Promise<Object>}
-
Get the bot's app data and store it in
this.appReturns:
Promise<Object> -The app data
-
async, private _handleError(err, msg) → {Promise<(Message|void)>}
-
Send or log an error message if it's not an IgnoredError instance
Parameters:
Name Type Description errError The error
msgEris.Message The original message from Discord
Returns:
Promise<(Message|void)> -
private _initHandlers()
-
Initiate the event handlers
-
private _onError(error)
-
What to do when an unknown error occurs
Parameters:
Name Type Description errorError The error
-
async, private _onMessage(msg) → {Promise<void>}
-
What to do when a message is recived
Parameters:
Name Type Description msgEris.Message The recieved message
Returns:
Promise<void> -
async, private _onReaction(msg, emoji, userID) → {Promise<void>}
-
What to do when a reaction is recieved
Parameters:
Name Type Description msgEris.Message The message reacted on
emojiEris.Emoji The emoji used to react
userIDString The ID of the user who reacted
Returns:
Promise<void> -
private _onShardDisconnect(err, shard)
-
What to do when a shard loses connection
Parameters:
Name Type Description errError The error
shardEris.Shard The disconnected shard
-
private _onShardReady(shardID)
-
What to do when a shard is ready
Parameters:
Name Type Description shardIDNumber The ID of the shard that's ready
-
private _prefixToken(token) → {String}
-
Prefix a token with the appropriate keyword designating a bot account if required
Parameters:
Name Type Description tokenString The token
Returns:
String -The properly prefixed token
-
private _toArray(data) → {Array<*>}
-
Format data by turning existing single supply into arrays if necessary
Parameters:
Name Type Description data* | Array<*> The data
Returns:
Array<*> -The formatted data
-
attach(name, value) → {Object}
-
Add an attachment that is passed to commands
Parameters:
Name Type Description nameString The name of the attachment
value* The value of the attachment
Returns:
Object -All added attachments
-
generator buildCommandGuide(name)
-
Build a guide embed for a specific command (Does not work for replacers or react commands)
Parameters:
Name Type Description nameString The name of the command
-
generator buildHelp(data : opt, page : opt)
-
Build a help menu and compile command info (Does not update with commands added after the agent has been constructed)
Parameters:
Name Type Attributes Default Description dataObject <optional>
The data for the menu
pageNumber <optional>
1 The page of the help menu to load
Properties:
Name Type Attributes Default Description data.descString <optional>
The description of the bot
data.serverCodeString <optional>
The invite code to the bot's server (Note: This is the code, not the link)
data.colorNumber <optional>
33023 An integer color that changes the sidebar color of the embed
data.footerImageString <optional>
A link leading to an image for the footer (An image of the prefix recommended)
data.versionString <optional>
The version of the bot
-
compileGuildSQL(dbData) → {GuildData}
-
Compile Knex-like guild data format to the Agent's native format
Parameters:
Name Type Description dbDataArray<Object> The data from the database
Properties:
Name Type Attributes Default Description dbData.idString The ID of the guild
dbData.permissionsPermissionList <optional>
{} The authority level of the roles of the guild
dbData.prefixString <optional>
The custom server-side prefix
-
connect() → {Promise<void>}
-
Connect to the Discord API and initiate event handlers.
Returns:
Promise<void> -
detach(name) → {*}
-
Remove an attachment
Parameters:
Name Type Description nameString The name of the attachment to remove
Returns:
* -The value of the removed attachment
-
getTopPermissionLevel(user) → {Number}
-
Get a guild member's top authority level role
Parameters:
Name Type Description userEris.Member The member of the guild. (Do not provide an Eris User instance, it must be a Member)
Returns:
Number -The leading authority level
-
lastMessage(channel) → {Eris.Message}
-
Get the last message sent by the bot in a given channel
Parameters:
Name Type Description channelEris.Channel The ID of the channel to pick your last message from
Returns:
Eris.Message -The last message
-
resetHelpCache()
-
Resets the help menu cache
-
setGuildPrefix(guild, prefix)
-
Set a server's custom prefix
Parameters:
Name Type Description guildString The ID of the guild
prefixString The custom prefix
-
updatePermission(guild, role, level) → {Object}
-
Update the permission level of a guild role
Parameters:
Name Type Description guildString The ID of the guild
roleString The role to modify
levelNumber The permission level to set the role to
Returns:
Object -All current permissions of the guild