Skip to content
Daniel Grace edited this page May 9, 2016 · 1 revision

A die token is a token in a roll result that represents one or more dice that was rolled. There will be a die object for each logical grouping of dice. For instance, roll 3d20 is a single grouping of dice, while roll 1d20+2d20 is two different groupings, even though logically these two rolls are equivalent.

A die token looks like the following:

{
    type: 'die',
    number: 2,
    dieSize: 4,
    comment: 'this is a comment',
    string: '2d20',
    rolls: ...
}

number is the number of dice to be rolled. For instance 1d20 would have a number of 1

dieSize is the number of faces on the die. For instance, 1d20 would have a dieSize of 20.

comment is a textual comment attached to this die. It is often nothing, but you can add a comment to a die by following that roll with a comment inside of square brackets. For instance 1d20 + 1d6 [fire] would put a comment of fire on the second die.

string is the string representation of this die roll. Note that this includes things like advantage. It is intended to be echoed back to the end user to validate that the bot rolled what you expect. Note that this isn't necessarily exactly what the user put in, since at this point we've parsed the input string into an internal representation. The most obvious example of this is that if the user types 2d20-H, the string will show up as 2d20kh1. The rolls are equivalent, but since we've parsed things into an internal representation we've effectively forgotten exactly how the user typed it.

rolls is an array of the actual dice rolls. If your roll is something simple like 1d20, this array probably only has one element. If you do a 2d20, it will have two. If you do 4d6ro<2 it can have a variable number of elements. Each element is an instance of Die Roll Token.

Clone this wiki locally