Functions - Paultje52/SupaBotBase GitHub Wiki

Functions are just like Events in the file setup. You can bind functions to the main bot class if you have functions you're using in multiple commands or events.

Module export

You need to export a class with at least two methods: getName() and onExecute().

getName()

This function gets called when loading your function. You need to return the name of the function. The name will be used to bind your function on the main class: bot.<name>.

onExecute

This function gets called when your code calls your function. You can still use other methods in your class with this.<method>(). You can access the main bot class with this.main.

Example

module.exports = class AsyncTimeout {

  getName() {
    return "asyncTimeout";
  }

  onExecute(time) {
    return new Promise((res) => {
      setTimeout(res, time);
    });
  }

}
⚠️ **GitHub.com Fallback** ⚠️