logo bannerlogo banner
Page Navigator

A hook is a way to listen for specific events in the game. When an event occurs, the bot can execute a function that you define. This allows you to respond to various actions in a game or the bot's lifecycle.

You can listen to a hook using bot.on:

bot.on('hookName', (arg1, arg2, ...) => {
    // Your code here
});

You can stop listening to a hook using bot.off with the second param as the function you want to stop listening to:

const hookHandler = (arg1, arg2, ...) => {
    // Your code here
    bot.off('hookName', hookHandler);
};

bot.on('hookName', hookHandler);

The above example will stop listening to the hookName hook after the first time it is called.

You can call bot.off with no second parameter to remove all listeners for that hook:

bot.off('hookName');

You can also use bot.onAny to listen to all hooks at once:

bot.onAny((hookName, ...args) => {
    console.log(`Hook ${hookName} was called with arguments:`, args);
});

You can also replace bot.on with bot.once to listen to a hook only once.

Hook List