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.
You need to export a class with at least two methods: getName()
and onExecute()
.
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>
.
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
.
module.exports = class AsyncTimeout {
getName() {
return "asyncTimeout";
}
onExecute(time) {
return new Promise((res) => {
setTimeout(res, time);
});
}
}