Giter Site home page Giter Site logo

wollbot's Introduction

Wollbot

My friend needed a dice roller for discord d&d.
He's a pretty great friend, so I made him one.

Features

  • Rolling an any-sided die an arbitrary number of times
  • Combining multiple dice in one roll
  • Rolling a CURSED die
  • Advantage / Disadvantage
  • Modifiers
  • "Titling" a roll so you know what it was for.

Screenshot of the bot's reply

Notes

Built for deployment on Cloudflare Workers

Followed this setup: https://discord.com/developers/docs/tutorials/hosting-on-cloudflare-workers

And copied things from this example repo: https://github.com/discord/cloudflare-sample-app

Manual

Will's Rollbot
==============

    USAGE   Performs rolls as defined by the input text.
    PARAMS  A string of space-separated arguments.
    ------- ------------------------------------------------------------------
    ARGS    cursed  - A cursed roll. Will ignore 'd-rolls' if present.
            #d#     - A roll where the first # is the number of times and
                      the second # is the number of sides. Eg: 2d20
                      Will not work with in 'cursed-rolls'.
            adv     - Plays the given rolls a second time and takes the maximum.
            dis     - Plays the given rolls a second time and takes the minimum.
            -#      - A negative modifier. Eg: -3
            +#      - A positive modifier. Eg: +3
            for:"x" - Give a title to the roll. Title must be in double quotes.
            help    - Shows this manual.
    ------- ------------------------------------------------------------------
    NOTES   The order of the arguments doesn't matter.
            If multiple modifiers are present, only the first will be used.
            Will return an error if both 'adv' and 'dis' are provided.
            Modifiers can also be appended to d-rolls: 2d10+3
    EXAMPLE /roll d20 -3
            /roll 2d10 adv +4
            /roll +10 cursed
            /roll dis 2d27 -2 3d101
            /roll 4d4+2 for:"Perception check" adv

Development

  • Run register first if there are new/edited command names.
  • Get a forwarding url with npm run ngrok
    • IIRC there's some account setup involved if you've never used ngrok before?
  • Run npm run dev
  • Save the ngrok url into the Bot application's INTERACTIONS ENDPOINT URL (in Settings)
  • Make your changes.
  • When finished npm run publish to deploy changes to Cloudflare.
  • Don't forget to change the Bot's INTERACTIONS ENDPOINT URL back to the workers URL.

Todo: Fix register

Currently npm run register fails due to some esm/node import issues...
Kinda janky but, to workaround:

  • Add file extension .js to all local imports

    - import { randNum, logError } from '../lib/utils';
    + import { randNum, logError } from '../lib/utils.js';
  • Import Response as a named import where it is used

    // JsonResponse.js
    + import { Response } from 'node-fetch'
    class JsonResponse extends Response {
          ...
    }
  • Convert lodash imports to destructure fns from a default import

    - import { get } from 'lodash'
    + import l from 'lodash'
    + const { get } = l;

wollbot's People

Contributors

jasonflorentino avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.