Minor bug fixes and documentation completed

This is version 1.0.0 release.
This commit is contained in:
Ean Milligan (Bastion) 2021-01-08 01:02:38 -05:00
parent 96a4a88c2f
commit df4705360d
7 changed files with 113 additions and 16 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
node_modules/
config.json
config.ts
brokennode/
brokennode/
emojis/Thumbs.db

View File

@ -1,3 +1,5 @@
https://choosealicense.com/licenses/mpl-2.0/
Mozilla Public License Version 2.0
==================================

View File

@ -1,6 +1,73 @@
# The Artificer
A dice roller Discord bot using roll20 format, also functioning as a basic calculator.
# The Artificer - A Dice Rolling Discord Bot
The Artificer is a Discord bot that specializes in rolling dice. The bot utilizes the compact [Roll20 formatting](https://roll20.zendesk.com/hc/en-us/articles/360037773133-Dice-Reference) for ease of use and will correctly perform any needed math on the roll (limited to basic algebra).
https://discord.com/api/oauth2/authorize?client_id=789045930011656223&permissions=2048&scope=bot
This bot was developed to replace the Sidekick discord bot after it went offline many times for extended periods. This was also developed to fix some annoyances that were found with Sidekick, specifically its vague error messages (such as `"Tarantallegra!"`, what is that supposed to mean) and its inability to handle implicit mulitplication (such as `4(12 + 20)`).
https://discord.com/api/oauth2/authorize?client_id=789045930011656223&permissions=10240&scope=bot
## Using The Artificer
I am hosting this bot for public use and you may find its invite link below. If you would like to host this bot yourself, details of how to do so are found in this repository, but I do not recommend this unless you are experienced with running Discord bots.
After inviting the bot, if you would like it to remove the message requesting the popcat emoji, you will need to give the `The Artificer` role the `Manage Messages` permission. All other permissions needed are handled by the invite link.
[Bot Invite Link](https://discord.com/api/oauth2/authorize?client_id=789045930011656223&permissions=2048&scope=bot)
---
## Available Commands
The Artificer comes with a few supplemental commands to the main rolling command.
* `[[help or [[h or [[?`
* Provides a message similar to this available commands block.
* `[[ping`
* Tests the latency between you, Discord, and the bot.
* `[[version or [[v`
* Prints out the current version of the bot.
* `[[popcat or [[pop or [[p`
* Sends the animated popcat emote for those who do not have Discord Nitro.
* If bot is given the permission `Manage Messages`, the bot will remove the message requesting the emote.
* `[[stats or [[s`
* Prints out how many users, channels, and servers the bot is currently serving.
* `[[report or [[r [command that failed]`
* People aren't perfect, but this bot is trying to be.
* If you encounter a command that errors out or returns something unexpected, please use this command to alert the developers of the problem.
* Example:
* `[[report [[2+2]] returned 5 when I expected it to return 4` will send the entire message after `[[report` to the devs via Discord.
* `[[xdydzracsq!]]`
* This is the command the bot was built specifically for.
* It looks a little complicated at first, but if you are familiar with the [Roll20 formatting](https://roll20.zendesk.com/hc/en-us/articles/360037773133-Dice-Reference), this will no different.
* Any math (limited to exponentials, multiplication, division, modulus, addition, and subtraction) will be correctly handled in PEMDAS order, so use parenthesis as needed.
* PI and e are available for use.
* Paramaters for rolling:
| Paramater | Required? | Repeatable? | Description |
|---------------|-------------|---------------|--------------------------------------------------------------------------------------------------|
| x | Optional | No | number of dice to roll, if omitted, 1 is used |
| dy | Required | No | size of dice to roll, d20 = 20 sided die |
| dz or dlz | Optional | No | drops the lowest z dice, cannot be used any other drop or keep options |
| kz or khz | Optional | No | keeps the highest z dice, cannot be used any other drop or keep options |
| dhz | Optional | No | drops the highest z dice, cannot be used any other drop or keep options |
| klz | Optional | No | keeps the lowest z dice, cannot be used any other drop or keep options |
| ra | Optional | Yes | rerolls any rolls that match a, r3 will reroll any dice that land on 3, throwing out old rolls |
| csq or cs=q | Optional | Yes | changes crit score to q |
| cs<q | Optional | Yes | changes crit score to be less than or equal to q |
| cs>q | Optional | Yes | changes crit score to be greater than or equal to q |
| cfq or cs=q | Optional | Yes | changes crit fail to q |
| cf<q | Optional | Yes | changes crit fail to be less than or equal to q |
| cf>q | Optional | Yes | changes crit fail to be greater than or equal to q |
| ! | Optional | No | exploding, rolls another dy for every crit roll |
* If the paramater is Required, it must be provided at all times.
* If the paramater is Repeatable, it may occur multiple times in the roll configuration.
* Examples:
* `[[4d20]]` will roll 4 d20 dice and add them together.
* `[[4d20r1!]]` will roll 4 d20 dice, rerolling any dice that land on 1, and repeatedly rolling a new d20 for any critical success rolled.
* `[[d20/40]]` will roll a d20 die and divide it by 40.
* `[[((d20+20) - 10) / 5]]` will roll a d20, add 20 to that roll, subtract off 10, and finally divide by 5.
## Problems? Feature requests?
If you run into any errors or problems with the bot, or think you have a good idea to add to the bot, please submit a new GitHub issue detailing it. If you don't have a GitHub account, a report command (detailed above) is provided for use in Discord.
---
### Built in memory of my Grandmother, Babka
With much love, Ean
December 21, 2020

View File

@ -20,13 +20,20 @@ export const config = {
"[[report [text] - Report a command that failed to run",
"[[stats - Statistics on the bot",
"[[xdydzracsq!]] ... - Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with ]])",
" * x [OPT] - number of dice to roll, if omitted, 1 is used",
" * dy [REQ] - size of dice to roll, d20 = 20 sided die",
" * dz [OPT] - drops the lowest z dice, cannot be used with kz",
" * kz [OPT] - keeps the highest z dice, cannot be used with dz",
" * ra [OPT] - rerolls any rolls that match a, r3 will reroll any dice that land on 3, throwing out old rolls",
" * csq [OPT] - changes crit score to q, where q can be a single number or a range formatted as q-u",
" * ! [OPT] - exploding, rolls another dy for every crit roll",
"* x [OPT] - number of dice to roll, if omitted, 1 is used",
"* dy [REQ] - size of dice to roll, d20 = 20 sided die",
"* dz || dlz [OPT] - drops the lowest z dice, cannot be used with kz",
"* kz || khz [OPT] - keeps the highest z dice, cannot be used with dz",
"* dhz [OPT] - drops the highest z dice, cannot be used with kz",
"* klz [OPT] - keeps the lowest z dice, cannot be used with dz",
"* ra [OPT] - rerolls any rolls that match a, r3 will reroll any dice that land on 3, throwing out old rolls",
"* csq || cs=q [OPT] - changes crit score to q",
"* cs<q [OPT] - changes crit score to be less than or equal to q",
"* cs>q [OPT] - changes crit score to be greater than or equal to q ",
"* cfq || cs=q [OPT] - changes crit fail to q",
"* cf<q [OPT] - changes crit fail to be less than or equal to q",
"* cf>q [OPT] - changes crit fail to be greater than or equal to q",
"* ! [OPT] - exploding, rolls another dy for every crit roll",
"```"
],
"emojis": {

14
mod.ts
View File

@ -71,6 +71,14 @@ startBot({
}
}
// [[rip [[memory
// Displays a short message I wanted to include
else if (command === "rip" || command === "memory") {
utils.sendIndirectMessage(message, "The Artificer was built in memory of my Grandmother, Babka\nWith much love, Ean\n\nDecember 21, 2020", sendMessage, sendDirectMessage).catch(err => {
console.error("Failed to send message 11", message, err);
});
}
// [[help or [[h or [[?
// Help command, prints from help file
else if (command === "help" || command === "h" || command === "?") {
@ -172,9 +180,9 @@ startBot({
modifiers.gmRoll = true;
// -gm is a little more complex, as we must get all of the GMs that need to be DMd
while (((i + 1) < args.length) && args[i + 1].startsWith("<@!")) {
while (((i + 1) < args.length) && args[i + 1].startsWith("<@")) {
// Keep looping thru the rest of the args until one does not start with the discord mention code
modifiers.gms.push(args[i + 1]);
modifiers.gms.push(args[i + 1].replace(/[!]/g, ""));
args.splice((i + 1), 1);
}
if (modifiers.gms.length < 1) {
@ -229,7 +237,7 @@ startBot({
const msgs = utils.split2k(returnText);
const failedDMs = <string[]>[];
for (let i = 0; ((failedDMs.indexOf(e) === -1) && (i < msgs.length)); i++) {
await sendDirectMessage(e.substr(3, (e.length - 4)), msgs[i]).catch(() => {
await sendDirectMessage(e.substr(2, (e.length - 3)), msgs[i]).catch(() => {
failedDMs.push(e);
utils.sendIndirectMessage(message, "WARNING: " + e + " could not be messaged. If this issue persists, make sure direct messages are allowed from this server.", sendMessage, sendDirectMessage);
});

View File

@ -1,3 +1,9 @@
/* The Artificer was built in memory of Babka
* With love, Ean
*
* December 21, 2020
*/
import { RollSet, SolvedStep, SolvedRoll } from "./solver.d.ts";
// MAXLOOPS determines how long the bot will attempt a roll
@ -678,7 +684,7 @@ const fullSolver = (conf: (string | number | SolvedStep)[], wrapDetails: boolean
}
// Replace the two operands and their operator with our subStepSolve
conf.splice((i - 1), (i + 2), subStepSolve);
conf.splice((i - 1), 3, subStepSolve);
// Because we are messing around with the array we are iterating thru, we need to back up one idx to make sure every operator gets processed
i--;
}

View File

@ -1,3 +1,9 @@
/* The Artificer was built in memory of Babka
* With love, Ean
*
* December 21, 2020
*/
import { Message } from "https://deno.land/x/discordeno@10.0.0/mod.ts";
// split2k(longMessage) returns shortMessage[]