npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollem-discord

v0.1.1

Published

Rollem for Discord - A dicebot and parser that aggressively matches rolls, and supports a variety of roll syntax.

Downloads

5

Readme

Rollem for Discord

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

Add this bot to your server.

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

Dice Syntax

X and Y 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. Rolly Y on a Y-sided die grants an additional die roll. | | A+B A-B | Arbitrary chains of addition and subtraction. | | A*B A/B | Arbitrary chains of multiplication and division. | | (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: < <= > >= = |

Limitations

  • Rollem will not roll more than 100 dice.
  • Rollem will not roll "one-sided" dice.

Reporting Problems and Requesting Features

Development

Vagrant and Docker Setup

  1. Setup Vagrant with vagrant up
  2. vagrant ssh to get into it.
  3. Code will be in /vagrant.
  4. From /vagrant, run docker build -t rollem . && docker run -it --rm -e DISCORD_BOT_USER_TOKEN='<YOUR TOKEN>' --name rollem rollem

Deploying the Bot

Publishing

  • Bump the version number. Follow semver.
  • npm publish

Using rollem.js as a library

  • npm install rollem-discord

  • const Rollem = require ('rollem-discord');

  • var result = Rollem.parse(text)

  • If text did not look like a valid roll, result === null.

  • If text looked like a roll, but was illegal. typeof(result) === "string", where the value is the error message.

  • If text was a valid roll, typeof(result) === "object" and follows this format:

{
  "value": 27,
  "values": [ value1, value2, value3 ],
  "pretties": "[value1, value2, **value3**]",
  "label": "Anything you want",
  "depth" 5
}

Breakdown:

| Field | | |------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | value | The final value. Usually a number. Will be boolean if the last statement was of the type x < y. If dice were involved, it will be the collapsed result of summing values. | | values | The most recent array of results. 2d2 * 2 will result in an array of length 2 with values of either 2 or 4. Probably not useful. | | pretties | The pretty-printed result. Markdown-compatible. Designed for use with discord. Min/max values are bolded. | | depth | The depth of the operations. Ex: 5 is 1. 5+5 is 2. d5 is 2. (d5+7)*3 is 4. Use this to avoid matching on 5. | | label | Any junk text that was passed after the parsed text. Ex: 5 And Some Junk has And Some Junk for this value. |

Some useful links

License: MIT

Copyright (c) 2016 Lemtzas

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.