logo bannerlogo banner

yolkbot is adopting actions, the alternative to Dispatches

last edited: 2026-01-25

Dispatches were a bad idea from the start.

an abbreviated history of dispatches (skip to introducing actions if not nerd)

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:

  1. dispatches had to have "checks" - a way to see if it made sense to execute the dispatch. for example, you shouldn't run a ReloadDispatch if you're not spawned in. so, does this just get held and then executed at next tick? i sure didn't know.
  2. dispatches could clog quickly. the initial adopters of yolkbot didn't understand this principle and had trouble, often queuing too many dispatches and having dispatches "clog up" and never execute.
  3. since dispatches were the best way to execute actions ingame, some dispatches got added that shouldn't be tied to the game loop. for example, ChatDispatch. chat messages don't need to be tied to the game loop, and having them be tied to it just made things more complicated.

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.

introducing...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