Skip to content

A dice-rolling bot for Discord that lets you Just Roll To Roll

License

Notifications You must be signed in to change notification settings

Nichlas-Schmidt/rollem-discord

 
 

Repository files navigation

Docker CI Syntax

Rollem for Discord

A feature-filled dicebot that allows you to just roll.

Add this bot to your server.

View the change log. (or type @rollem changelog in chat)

Beta Channel (Rollem Next)

Changes will be vetted in the beta channel before being moved to the main bot.

You may have both Rollem Next and Rollem active in the same server, but they should not be allowed in the same channels.

Add the beta bot to your server.

Links

How to use this bot

Just roll.

@you: 4d6
@rollem: @you, 17 ⟵ [6, 5, 3, 3]4d6

@you: 4d6 for glory
@rollem: @you, 'for glory', 17 ⟵ [6, 5, 3, 3]4d6

Inline rolls.

@you: Rolling [4d6] for glory
@rollem: @you, 17 ⟵ [6, 5, 3, 3]4d6

@you: Rolling [4d6 for glory]
@rollem: @you, 'for glory', 17 ⟵ [6, 5, 3, 3]4d6

Repeated rolls.

@you: 3#d20
@rollem: @you,
20 ⟵ [20]1d20
13 ⟵ [13]1d20
11 ⟵ [11]1d20

Stat generation.

@you: 6#4d6d1
@rollem: @you,
12 ⟵ [6, 3, 3, 2 ]4d6dl1
6 ⟵ [2, 2, 2, 1 ]4d6dl1
13 ⟵ [5, 5, 3, 2 ]4d6dl1
10 ⟵ [5, 3, 2, 2 ]4d6dl1
13 ⟵ [6, 5, 2, 1 ]4d6dl1
15 ⟵ [6, 6, 3, 3 ]4d6dl1

Math.

@you: &50+50
@rollem: @you, 100 ⟵ 50 + 50

@you: r50+50
@rollem: @you, 100 ⟵ 50 + 50

Dice Syntax

X/Y/Z are integers. A and B are arbitrary Expressions.

Syntax
XdY Rolls X dice of Y size. 4d6 rolls 4 six-sided dice.
dY Rolls a single die of Y size.
dY! XdY! Exploding dice. Rolling Y on a Y-sided die grants an additional die roll.
dY!Z XdY!Z Exploding dice. Rolling Z or above on a Y-sided die grants an additional die roll.
XdYns XdY!ns Disable dice sorting.
A+B A-B Arbitrary chains of addition and subtraction.
A*B A/B Arbitrary chains of multiplication and division.
A++B A--B Arbitrary chains of per-die addition and subtraction. Each value modifies each individual die roll. 4d6--2 rolls 4d6 with 2 subtracted from each.
(E) Parenthetic expressions
A<<B Counts the quantity of values in A that are lower than or equal to the value B. 10d6 << 3 counts the number of dice at 3 or below.
A>>B Counts the quantity of values in A that are greater than or equal to the value B. 10d6 >>4 counts the number of dice at 4 or above.
A<B A>=B Equality comparison on A and B. Must be the last operator ((1 < 2) * 5 is invalid, 1 < (2 * 5) is valid). Supported operators: < <= > >= =
BX GX WX Burning Wheel notation. Aliased to Xd6 >> Y where Y is determined by B/G/W. B=4, G=3, W=2.
BX! GX! WX! Burning Wheel open roll notation. Aliased to Xd6! >> Y where Y is determined by B/G/W. B=4, G=3, W=2.
dF XdF Fate Dice notation. Rolls dice with values of -1, 0, 1. Represented by -, 0, and +.
XdYns No Sort. Does not sort the result of XdY in the output.
X#A Evaluates the expression A X times. Use for stat generation: 6#4d6d1
dYdZ XdYdZ Drop dice notation. Drops the lowest Z dice from the result of XdY. Alias for XdYdlZ. May be used with ns and !.
dYdlZ XdYdlZ Drop dice notation. Drops the lowest Z dice from the result of XdY. May be used with ns and !.
dYdhZ XdYdhZ Drop dice notation. Drops the highest Z dice from the result of XdY. May be used with ns and !.
dYkZ XdYkZ Keep dice notation. Keeps the highest Z dice from the result of XdY. Alias for XdYkhZ. May be used with ns and !.
dYkZ XdYkZ Keep dice notation. Keeps the highest Z dice from the result of XdY. May be used with ns and !.
dYklZ XdYklZ Keep dice notation. Keeps the lowest Z dice from the result of XdY. May be used with ns and !.
dYcZ XdYcZ Critrange notation. Bolds all rolls greater than or equal to Z. Cannot be used with keep or drop notations.
2dYdaro 3dYtaro XdYaro Doubles/Triples/All-Same And Roll Over notation. "Explodes" when all dice match. Used for Tunnels and Trolls.

Limitations

  • Rollem will not roll more than 100 dice.
  • Rollem will not roll "one-sided" dice.
  • Rollem will not roll single numbers.
  • Pure math must be prefixed with & or r.
  • Rolls prefixed with N# will be rolled N times. N > 100 will be ignored.

Prefixing

Give Rollem a role of rollem:prefix:<your prefix here> to disable no-prefix rolling.

With this role:

  • Rollem will still roll lines prefixed with & or r
  • Rollem will still roll lines addressed to him. @Rollem 2d20
  • Rollem will still roll inline syntax swing the sword [2d20 for justice]
  • Rollem with not aggressively parse lines 2d20 for justice
  • Rollem will aggressively parse lines prefixed with <your prefix here>

Preview Syntaxes

Give Rollem one of the following roles to enable different versions of the syntax for an entire guild:

  • rollem:beta - use the unstable preview syntax for v1
  • rollem:v2 - use the in-development v2 syntax

Give a user one of the following roles to enable different versions of the syntax for that specific user (this overrides the above):

  • rollem:v1 - use the stable v1 syntax
  • rollem:beta - use the unstable preview syntax for v1
  • rollem:v2 - use the in-development v2 syntax

Commands

All commands are performed by mentioning @rollem in server chat, and without prefix in private chat.

Command Example Purpose
stats, help @rollem stats Dump stats, uptime and credit.
storage dump @rollem storage dump View everything we know about you.
storage forget @rollem storage forget Have us delete everything we know about you.
changelog, changes, change log, diff @rollem changelog View the most recent changelog entries.

Development

First-time setup

  1. Set up yarn
  2. You will need an app bot user token from discord's applications page
  3. You will need access to an initialized Postgres server. See [Setting up a database][#Local Database Setup] for details.
  4. Rename and update ./secrets/sample-vscode.env
  • You will need to replace YOUR_TOKEN_HERE with an app bot user token from discord's applications page
  • The Application Insights line may be deleted to switch to console-only logging.
  1. Run yarn install in the root directory
  2. Link packages with yarn bootstrap
  3. Build packages with yarn build

Run Bot From VSCode (with debugging)

  1. Rename and update ./secrets/sample-vscode.env
  2. Link packages with yarn bootstrap
  3. Build with one of:
  • yarn build:bot
  • yarn watch:bot and allow it to idle in the background
  1. Press F5 while the project folder is open. Launch configuration is in .vscode/launch.json

Run Single Shard

  1. Rename and update ./secrets/sample-vscode.env
  2. Run yarn bootstrap
  3. Build with one of:
  • yarn build:bot
  • yarn watch:bot and allow it to idle in the background
  1. Run yarn run start:bot

Running Single Shard in Docker

  1. You will need Docker
  2. yarn run package:bot (The container will compile it)
  3. yarn run package:bot:start

Local Database Setup

  1. You will need Docker
  2. Create database with docker-compose up database
  3. Initialize the database
    1. cd packages/common to get to the common code directory
    2. yarn install
    3. yarn run typeorm schema:sync to sync the TypeORM schema
  • You may have to repeat these steps when the schema changes
  • Clear the database with docker-compose down database and then docker-compose up database
  • To inspect the database you will likely want pgAdmin

Language Development

Current version of the language is in packages/language/src/rollem-language-2.

  1. cd into packages/language
  2. Run yarn watch in one terminal
  3. Run yarn watch:test in another terminal
  4. Modify any file under packages/language
  5. Test output is for src/rollem-language-2/rollem.pegjs

Local Kubernetes Development

These are incomplete and are a massive pain on Windows anyway.

  1. Setup Minkube
  1. minikube start (may need to restart VSCode or your terminal first for it to find the command)
  2. kubectl cluter-info confirm it's working
  3. minikube dashboard open the dashboard
  4. eval $(minikube docker-env) to setup for local running
  5. docker-machine create --driver virtualbox default to get docker going on virtualbox
  6. docker build -t rollem-discord . to build the current docker image

Deploying the Bot

Summary

Minimal Deploy (no storage)

Not currently possible.

  1. Required tools
    1. Docker
  2. Start the bot
    1. Configure the values in compose.yaml
    2. run docker-compose up rollem-minimal in the root directory

Simple Deploy (no persistence)

  1. Required tools
    1. Docker
  2. Start the bot
    1. Configure the values in compose.yaml (You will need a bot token from discord)
    2. run docker-compose up rollem-database in the root directory

Publishing

Run one of the following; Follow semver:

  • yarn publish:major
  • yarn publish:minor
  • yarn publish:patch

Some useful links

Some useful commands

Change image:

curl --request PATCH --header "Authorization: Bot {TOKEN HERE}" -H "Content-Type: application/json" --data '{ "avatar": "{BASE-64 HTML EMBED HERE}" }' https://discordapp.com/api/users/@me
(echo -n '{ "avatar":"'; base64 -w 0 {FILENAME HERE}; echo '" }') | curl --request PATCH --header "Authorization: Bot {TOKEN HERE}" -H "Content-Type: application/json" -d @- https://discordapp.com/api/users/@me

Credits

Avatar by Kagura on Charisma Bonus.

License: MIT

Copyright (c) 2018 David Sharer

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.

About

A dice-rolling bot for Discord that lets you Just Roll To Roll

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 83.9%
  • PEG.js 5.8%
  • JavaScript 5.6%
  • Shell 1.7%
  • SCSS 1.2%
  • Dockerfile 0.7%
  • Other 1.1%