How does features and events work?
✨ Welcome to Events & Features section!
Features
A feature can include multiple event listeners and other systems to handle how your bot works. You can create a "features" folder and place all your features in that folder.
The files will be automatically imported and ran. Here's an example:
const { Feature } = require('sl-commands')
new Feature()
/** This will be executed once when the handler starts */
.setInit(({ client, handler }) => {
console.log('This will be ran once.')
})
/** This will be executed continuously with the interval of your choice */
.addTimed(({ client, handler }) => {
console.log('This will be ran every 5 seconds.')
}, 5000) // 1000 = 1 secondimport { Feature } from 'sl-commands'
new Feature()
/** This will be executed once when the handler starts */
.setInit(({ client, handler }) => {
console.log('This will be ran once.')
})
/** This will be executed continuously with the interval of your choice */
.addTimed(({ client, handler }) => {
console.log('This will be ran every 5 seconds.')
}, 5000) // 1000 = 1 secondEvents
But if you want just one event listener and nothing more, you can create an event in an "events" folder. The files imported will be ran whenever the event is emitted. You can create an event using this structure:
This can be used to handle SLCommands events too! You can see more here:
SLCommands EventsLast updated