Inspiration

Tabletop and party streams often need dice rolls that chat can see and join. We wanted viewers to roll dice themselves, right in Twitch chat.

What it does

Viewers type !roll to roll a d20, or !roll 2d6+3 for any dice notation (up to 20 dice and 1000 sides). The bot replies in chat with each die and the total. A browser-source overlay shows the latest roll with the viewer's name. Streamers and moderators can use !roll reset to clear the overlay, and a 5-second cooldown per viewer keeps chat from flooding.

How we built it

Node.js with tmi.js for Twitch chat, a small HTTP server that serves the overlay and a JSON state endpoint, and a dice module with unit tests that does not depend on Twitch. The first scaffold was created before the Codex thread. In the Codex thread, Codex reviewed the code, ran the tests, and implemented !roll reset with Twitch moderator and broadcaster checks, reset tests, and a stricter command matcher.

Challenges we ran into

Checking Twitch roles correctly for the reset command, and keeping the overlay in sync with chat.

Accomplishments that we're proud of

It works live in Twitch chat, and all 8 unit tests pass.

What we learned

How Twitch chat tags carry moderator and broadcaster roles, and how to keep chat logic testable without a live connection.

What's next for Chat Dice

A shared initiative tracker for tabletop streams, and keeping the last few rolls on the overlay.

Built With

Share this project:

Updates

Submission history