Skip to content

Instantly share code, notes, and snippets.

@fadookie
Last active January 5, 2025 13:40
YAGPDB Custom Command - Cosmere RPG Plot Die Roller

Cosmere RPG Plot Die Roller

This is a custom command script for the YAGPDB Discord Bot. It is a virtual dice roller for the "plot die" for the Cosmere RPG.

It is designed to work with the plot die emoji from the Cosmere RPG Discord Server.

Note the source code is not JavaScript but it was the closest syntax highlighting I could find on GitHub, you can ignore the file extension.

Usage

Screenshot of discord showing a few example rolls of the plot die command.

With the default command name and prefix:

-plotdie or -plotdie 1 rolls a single plot die.

-plotdie 2 rolls two plot dice.

Other amounts are currently unsupported, but I don't think you would ever need to roll more than two at once when you have advantage or disadvantage.

Other Types of Dice Rolls

This script is only intended for rolling plot dice, but YAGPDB has a built-in dice roller command that can roll other types of dice. Rollem is also another good dice roller bot for Discord.

Installation

Add YAGPDB to your server if it isn't in it already, and create a new custom command.

I used the trigger plotdie and the name Plot Die Roll, but this can be whatever you want.

Copy the custom command script from this repository into the response editor.

I think you can leave all the other settings as default, and click save.

Customizing roll emoji

This command is designed to use custom emoji to match the symbols of the plot die. I got these from the Cosmere RPG Discord server, but you can use any emoji.

Complication symbol with the number 4 Complication symbol with the number 2 Opportunity symbol

Note that for custom emoji using the user-friendly name like :Opportunity: will not work here, use the method below to get the emoji ID.

If you want to use custom emoji like these, upload them to your Discord server and send them in a message. Then, copy the message. You should see emoji ID like so:

<:Complication4:1324770126553157684> <:Complication2:1324770111827214386> <:Opportunity:1324770094622179450>

Paste these into the script in the respective variable definitions indicated by the comment. So for example, for these IDs, the code should look as follows:

{{/*Replace these with the emoji IDs you want to use. Copy a message with custom server emoji to the clipboard to obtain its emoji ID. */}}
{{$complication4 := "<:Complication4:1324770126553157684>"}}
{{$complication2 := "<:Complication2:1324770111827214386>"}}
{{$neutral := ":white_large_square:"}}
{{$opportunity := "<:Opportunity:1324770094622179450>"}}

The following license applies to the code only, and not any images contained in this repository, which are copyrighted by their respective owners.

Copyright © 2025 Eliot Lash

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

{{ $args := parseArgs 0 "" (carg "int" "number of dice") }}
{{$numDice := 1}}
{{ if $args.IsSet 0 -}}
{{ if or (gt ($args.Get 0) 2) (lt ($args.Get 0) 1) }}
Invalid dice number. Must be between 1 and 2.
{{ return }}
{{ end }}
{{$numDice = $args.Get 0 }}
{{end}}
{{/* Debug output
dice: {{ $args.Get 0 }}
numDice: {{ $numDice }}
*/}}
{{/*Replace these with the emoji IDs you want to use. Copy a message with custom server emoji to the clipboard to obtain its emoji ID. */}}
{{$complication4 := "<:Complication4:1324770126553157684>"}}
{{$complication2 := "<:Complication2:1324770111827214386>"}}
{{$neutral := ":white_large_square:"}}
{{$opportunity := "<:Opportunity:1324770094622179450>"}}
{{/*=====Roll Die 1======*/}}
{{$rollInt1 := randInt 6}}
{{$rollStr1 := ""}}
{{if eq $rollInt1 0}}
{{$rollStr1 = $complication4}}
{{else if eq $rollInt1 1}}
{{$rollStr1 = $complication2}}
{{else if eq $rollInt1 2}}
{{$rollStr1 = $neutral}}
{{else if eq $rollInt1 3}}
{{$rollStr1 = $neutral}}
{{else if eq $rollInt1 4}}
{{$rollStr1 = $opportunity}}
{{else if eq $rollInt1 5}}
{{$rollStr1 = $opportunity}}
{{else}}
error, unexpected value {{$rollInt1}}
{{ return }}
{{end}}
{{ $output := $rollStr1 }}
{{/*=====Roll Die 2 If Needed======*/}}
{{$rollInt2 := -1}}
{{$rollStr2 := ""}}
{{if eq $numDice 2}}
{{$rollInt2 = randInt 6}}
{{if eq $rollInt2 0}}{{$rollStr2 = $complication4}}
{{else if eq $rollInt2 1}}
{{$rollStr2 = $complication2}}
{{else if eq $rollInt2 2}}
{{$rollStr2 = $neutral}}
{{else if eq $rollInt2 3}}
{{$rollStr2 = $neutral}}
{{else if eq $rollInt2 4}}
{{$rollStr2 = $opportunity}}
{{else if eq $rollInt2 5}}
{{$rollStr2 = $opportunity}}
{{else}}
error, unexpected value {{$rollInt2}}
{{ return }}
{{end}}
{{ $output = (joinStr " " $output $rollStr2)}}
{{end}}
{{/* Debug output
{{ $output := (joinStr "" "rollInt1 = " $rollInt1 "\nrollStr1 = '" $rollStr1 "'\nrollInt2 = " $rollInt2 "\nrollStr2 = '" $rollStr2 "'")}}
*/}}
{{ sendMessage nil $output }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment