Skip to content

Post Event Functions

Arthur Neuman edited this page Jul 26, 2020 · 2 revisions

Functions that occur after events

If you'd like to have a function run after an event happens (message, reaction, prefix alter, permission change) even if a command is not executed, you can!

Just simply define the functions in your agent constructor.

function PMFunc (msg, results) {
  if (results) { // If a command was executed
    console.log(`${msg.timestamp} - **${msg.author.username}** > *${results.command.name}*`)

    if (msg.channel.id === '1233673') msg.channel.createMessage('You shouldn't be using commands in this channel...')
  }
}

const agent = new Agent({
  Eris,
  token: TOKEN,
  options: {
    postEventFunctions: {
      message: PMFunc
    }
  }
})

Available event functions and their parameters

Event Description Parameters
message Fires after a message is sent (and command data is processed, if any) msg: The message
res: The results of the command (See CommandHandlerResults)
reaction Fires after a cached message is reacted on (and command data is processed, if any) msg: The message
emoji: The Eris data of the emoji reacted with
user: An Eris.User instance of the user that reacted
res: The results of the command (See ReactionHandlerResults)
prefix Fires when a guild's custom prefix is changed with the method Agent.setGuildPrefix() guild: The ID of the guild being altered
prefix: The prefix being set
oldPrefix: The old prefix
permission Fired when a guild role's authority level is changed with the method Agent.updatePermission() guild: The ID of the role being altered's guild
role: The ID of the role being altered
level: The new authority level of the role
oldLevel: The old authority level of the role