last edited: 2026-01-25
Dispatches were a bad idea from the start.
Dispatches were added in the initial setup of yolkbot, which was done by enbyte. although dispatches worked, the methodology behind them was flawed. the issue was that dispatches were intended to have one execute every game tick and cycle through as a queue. unfortunately, there are multiple reasons this doesn't work:
so, dispatches got rewritten so that they always executed when the check passed in the game loop. this worked for a very long time, until i decided to redesign yolkbot's website.
on desktop, yolkbot's website presents a snippet of code demonstrating how easy yolkbot is to use:
import { Bot } from 'yolkbot/bot';
const bot = new Bot();
await bot.join('useast', 'ffa', 'Eggcrates');
unfortunately, i wanted to demonstrate MORE things you could do with yolkbot, like sending chat messages. however, i modeled that out:
import { Bot } from 'yolkbot/bot';
import { ChatDispatch } from 'yolkbot/dispatches/ChatDispatch';
const bot = new Bot();
await bot.join('useast', 'ffa', 'Eggcrates');
bot.on('gameReady', () => bot.dispatch(new ChatDispatch('Hello everyone!')));
and i realized...that's clunky. we don't need that. why not just have a simple method to send chat messages?
so, i decided to go back to the drawing board and redesign how yolkbot interacts with games. what i got was bot.emit, or what is called actions.
actions are simple. you don't need to import anything, you don't need to create any classes. you just need to use the new bot.emit function:
bot.emit('chat', 'Hello everyone!');
what went from an import, class initialization, and dispatch call turned into a simple one-liner. this is simple, and it confirms with many other NodeJS libraries. since yolkbot was rewritten to use the traditional bot.on system, it behaved very much like the classic EventEmitter in NodeJS. so, why not have bot.emit as well?
some examples:
bot.emit('reload'); // reload the bot's gun
bot.emit('bootPlayer', 1); // boot a player with ID 1 from the game
bot.emit('bootPlayer', '1ust'); // boot a player with the username '1ust' from the game
bot.emit('reportPlayer', '1ust', { cheating: true }); // report a player for cheating
as of yolkbot 1.5, actions still run dispatches under the hood for backwards compatibility. bot.dispatch still works as it always has. however, i highly recommend using bot.emit for all new code. it's simpler, easier to read, and easier to use. emitting things has no functionality loss while being 2x easier to use.
thanks for using yolkbot <3