Skip to main content

Twitch

Command without parameters

const type = "CLASSIC" //  CLASSIC / THROTTLE / QUEUE / QUEUE_LOCK / THROTTLE_LOCK

const locker = null // Only required for QUEUE_LOCK & THROTTLE_LOCK types

const conditions = {
"twitch-message": ({ payload }) => payload.message === '!test'
};

async function reaction(eventData){
console.log('The !test command has been launched !')
};

Command with 5s cooldown without parameters

const type = "CLASSIC" //  CLASSIC / THROTTLE / QUEUE / QUEUE_LOCK / THROTTLE_LOCK

const locker = null // Only required for QUEUE_LOCK & THROTTLE_LOCK types

const conditions = {
"twitch-message": ({ payload }) => payload.message === '!test'
};

async function reaction(eventData){
console.log('The !test command has been launched !')
await utils.sleep(1000 * 5)
};

module.exports = {
type: "THROTTLE",
conditions,
reaction,
};

Command with parameters

const type = "CLASSIC" //  CLASSIC / THROTTLE / QUEUE / QUEUE_LOCK / THROTTLE_LOCK

const locker = null // Only required for QUEUE_LOCK & THROTTLE_LOCK types

const conditions = {
"twitch-message": ({ payload }) => payload.message.startsWith('!test ')
};

async function reaction(eventData){
const parameters = payload.message.replace('!test ', '')
console.log('The !test command has been launched with parameters !', parameters)
};

module.exports = {
type: "CLASSIC",
conditions,
reaction,
};