Skip to content
BitQuote edited this page Apr 10, 2016 · 25 revisions

Starting with version 3.2, AwesomeBot supports extensions! They are code snippets run in response to a keyword or command, managed per-server via the admin console. To add an extension to a server, send a JSON file (described below) to the bot after logging into the admin console for a server.

The file you attach should have the following basic structure:

{
    name: name of extension,
    type: "keyword", "command", or "timer",
    key: array of keywords or one-word command,
    case: boolean for case sensitivity for a keyword, 
    interval: timer interval in seconds,
    usage: (optional) parameters for a command, e.g. "<param1> <param2>",
    extended: (optional) detailed help for command extensions
    channels: (optional) array of applicable channel names,
    process: code to execute, as a string
}

process is the crucial component here (you can compress your code into a string using this website). This code is given 3 seconds to run in a sandbox, with access to the following:

  • unirest: lightweight HTTP request library
  • imgur: preauthenticated imgur-node-api module
  • image: Google Image Search, usage image(query, num, svrid, callback(url))
  • rss: feed-read module, usage rss(svrid, url, svrid, callback(err, articles))
  • message: full content of the message
  • svrid: the Discord ID of the server you're in
  • selected: for keyword extensions the index of the match in the key array
  • author: tag for the sender
  • setTimeout, JSON, Math, isNaN, Date, Array, Number
  • send: write final output to this

Note: For timer extensions, you will not be given an author or message, and channels and interval are required in your extension JSON file.

Outside of this sandbox, the extension cannot use other Node modules or methods. If a message is identified as an extension target, send must have a value within 1.5 seconds or the bot will not repond to the command/keyword. You are also responsible for validiing the message if you are using a command to ensure that it contains the proper parameters. When sending the JSON file to the bot, it will run several tests to verify its integrity and validity. If it is acceptable, you can remove it at any time in the admin console.

Clone this wiki locally