What is an Observer
An Observer is a function that observes the behavior of messages or commands. They are always keeping an eye on the behavior of messages and commands dependant on what you want it to observe.
Observers can be restricted to observe certain types of text whether it be messages, commands or both. In addition, you can choose to disable an Observer easily.
Spark already contains some pre-made Observers for you:
-
prefixHelp
When you do @bot-name, it will tell you the prefix of the bot.
Below you will find out how to create an Observer, as well as the methods that may be used to help you with creating an Observer.
Constructor
To create an Observer, you will need to create a new ".js" file inside the functions/observers folder.
Below is an example of how a default Observer file is structured:
var Spark = require("sparkbots") const Observer = Spark.observer("name") Observer.code = (client, message) => { // Execute Code Here } module.exports = Observer;
Methods
-
setType( Type )
-
Type
Please note that you may choose from the following options: "command" "message" or "all".
-
-
.disable()