What is an Engine
An Engine is a piece of code that runs upon launching your bot. All essential code that you want to have executed upon booting your bot should be placed in an Engine. Engines can be used to send information or configure settings upon launch such as checking for updates or sending server counts to bot lists.
Engines can be restricted to run at certain intervals of time. You also have the opportunity to set delays to the execution of a certain Engine. In addition, you can choose to disable an Engine easily.
Spark already contains some pre-made Engines for you:
-
checkUpdate
This is making sure your bot is up to date and you will be notified if it isn't.
Below you will find out how to create an Engine, as well as the methods that may be used to help you with creating an Engine.
Constructor
To create an Engine, you will need to create a new ".js" file inside the functions/engines folder.
Below is an example of how a default Engine file is structured:
var Spark = require("sparkbots") const Engine = Spark.engine("name") Engine.setTime(number) Engine.setDelay(number) Engine.code = (client, message) => { // Execute Code Here } module.exports = Engine;
Methods
-
setTime( Number )
-
Number
-
-
setDelay( Number )
-
Number
-
-
.disable()