Discord Dice Roller Bot

By vampwood, in Star Wars: Edge of the Empire RPG

On 3/15/2017 at 7:26 AM, Darzil said:

Dark and Light, and Despair and Triumph, are the two cases where 'opposites' do not cancel out.

On 3/18/2017 at 5:49 PM, Boisterous Bothan said:

I just wanted to say thank you for taking the time to create this bot. It has streamlined our online games immensely and your work is greatly appreciated by all!

I look forward to the update fixing the cancelling of Light/Dark points.

On 3/15/2017 at 7:26 AM, Darzil said:

Dark and Light, and Despair and Triumph, are the two cases where 'opposites' do not cancel out.

The update is now live, download the latest version from github

On 3/3/2017 at 5:26 AM, MaxXIII said:

It is working!!!!!! Thank you all so much! :)
Unfortunately, there still seems to be sth wrong with the node mudule folder from the github link,
bc after reinstalling it told me first that a db.json file was missing (which i found in the node.js node modules folder under mimedb)
and after I fixed that a types.json file was missing (which I couldnt find :( )
In the end Vlagrikes method worked for me:
I dug up the old zip without the node module update and installed discord.js and chalk through the command prompt.

Another noob question:
Does evrune playing with me need to install node.js and get the bot activated or just me?

On 3/8/2017 at 7:07 AM, JonesyUSA said:

Can I have some help? No matter what I try I keep getting this message when I click on start.bat or EotE Dice Roller:

module.js:472
throw err;
^

Error: Cannot find module './db.json'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\kyle\Desktop\SWEotE-Discord-Dice-Roller-master\node_modules\mime-db\index.js:11:18)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
Press any key to continue . . .

Any help would be greatly appreciated,

Thanks

On 3/9/2017 at 1:23 PM, Valik said:

I'm having the same problem as @JonesyUSA and @RixxyAGoGo . Error: Cannot find module './db.json'. Rixxy what was your solution exactly?I found the mime file, but can't find any place to modify/input the code there. Did you mess with the config file?

On 3/18/2017 at 1:36 PM, Arctanaar said:

I'm still getting that 'db.json' error. Any ideas regarding what I could try?


This error is fixed. Please download the newest version of the bot, before running the bot for the first time. Please run the file named "run this before first launch". This will install the dependencies the bot needs. I've documented this update in the readme file. Cheers

@Astrydax

It's working perfectly! Thank you for the update.

One question: is there possibility of implementing a d100?

Nevermind. I missed it when reading the Update. Again! Thanks SO MUCH!

Edited by Boisterous Bothan
grammar and mistake
On 22/03/2017 at 3:00 AM, Astrydax said:

This error is fixed. Please download the newest version of the bot, before running the bot for the first time. Please run the file named "run this before first launch". This will install the dependencies the bot needs. I've documented this update in the readme file. Cheers

Unfortunately, it seems that I am still getting the same error, even after running the file 'run this before first launch'.

Edited by Arctanaar
16 hours ago, Arctanaar said:

Unfortunately, it seems that I am still getting the same error, even after running the file 'run this before first launch'.

Did you make sure to delete the bot you had first? Make sure you're running "runthisfirst.bat" for windows and " runthisfirst.command" for mac. If you have nodejs installed on your machine this should work for everyone now.

@Astrydax

Is there a way to follow your progress on updates? Or is it best to just await your Update messages here in this thread?

6 minutes ago, Boisterous Bothan said:

@Astrydax

Is there a way to follow your progress on updates? Or is it best to just await your Update messages here in this thread?

You can go to github, sign up for a free account, and click the "watch" button. https://github.com/Astrydax/SWEotE-Discord-Dice-Roller

Edited by Astrydax
clarity

I've been helping out with the Discord Dice. Lots has been added. https://github.com/Astrydax/SWEotE-Discord-Dice-Roller

Testing server https://discord.gg/G8au6FH Come say Hi to D1-C3!

- !roll (Rolls any combination of SWRPG dice and returns the canceled results)

- You may add " " at the end of the line to give the roll a name like Initiative
- Dice results and cancellations are computed by the bot so you don't have to!
- Only the remaining symbols will be displayed.

DICE IDENTIFIERS
- y/pro = Yellow/Proficiency
- g/a = Green/Ability
- b/boo = Blue/Boost
- blk/k/sb/s = Black/Setback
- r/c = Red/ Challenge
- p/diff = Purple/ Difficulty
- w/f = White/Force

- note: if you use the !roll yyyggbbd method you must use the single character dice identifiers

EXAMPLES
- !roll yyyggbbd "Blast Him!"
- !roll 3pro 2a 2boo 2dif 2sb "Delusions of Grandeur"
- !roll "Get to the ship" 2y 1g 1r 1p

- !d100 (Rolls a d100 with optional modifier and displays result.)

EXAMPLES
- !d100 +10
- !d100 + 10
- !d100 -10
- !d100 - 10


- !destiny (Sets and manages the Destiny Balance for the group)

COMMANDS
- !destiny (View the destiny pool)
- !destiny l/light (uses light side point)
- !destiny d/dark (uses dark side point)
- !destiny set #l #d (sets destiny pool)
- !destiny set lldd (sets destiny pool)
- !destiny reset (resets the destiny pool)

- !crit (Rolls a d100 with optional modifier and displays result of the critical hit.)

EXAMPLES
- !crit +10
- !crit + 10
- !crit -10
- !crit - 10

- !shipcrit (Rolls a d100 with optional modifier and displays result of the ship critical hit.)

EXAMPLES
- !shipcrit +10
- !shipcrit + 10
- !shipcrit -10
- !shipcrit - 10

#Installation and Setup

1. First you will need to have NodeJS installed on your machine. You can find the latest version [here](https://nodejs.org/en/)
2. Next create a discord account for your bot. You can do this [here](https://discordapp.com/developers/applications/me)
1. Click "New App"
2. Provide a Name (this is the name people will see when the bot joins a channel) and Description
3. Click "Create App"
4. On the new screen click "Create a Bot User"
5. Open Notepad
6. Under the heading "App Bot User" you will see "Token:click to reveal" Click to reveal it and copy the resulting text and paste it in notepad. Be sure to keep this token private.
7. Under the heading "App Details" Copy the number after "Client ID:" and paste this in notepad as well.
8. Replace "CLIENT_ID_GOES_HERE" in the following link with the Client ID you copied in the above step https://discordapp.com/oauth2/authorize?client_id=CLIENT_ID_GOES_HERE&scope=bot&permissions=0
9. Paste the edited link into a web browser, select the discord server you wish to add the bot to, and click "Authorize".
3. Click "Clone or Download" at the top of this page. Click "Download Zip" and extract the files.
4. Open Config.json with a text editor program of your choice.
5. Replace "BOT TOKEN" with your bot token you copied in step 2.6 and save the file
6. Your bot is now configured and ready to launch.

#Running the bot

Before you first launch the bot you need to run the file "Run this before first launch". You can't miss it. This will install all the dependencies that bot needs to run.

To run the bot, Just execute the file "EotE Dice Roller.lnk". You can copy/move this file to any location you want. However, do not move "start.bat" out of the installation folder.

#Configuration File config.json

config.json has four properties

1. token
- this is the login token for your bot
2. prefix
- this is the symbol the bot uses to recognize commands. This is set to "!" by default
3. descriptorPrenpend
- Any text you place between the double quotes following this property will be prepended to the text provided in the comment parameter.
Example: if "descriptorPrepend" is set to "Targeting: ", then the command !roll 2g 2blk "Soldier 1" is called, the bot will respond with: Targeting: Soldier 1
Astrydax roll results: Success: 1 Threat: 1
4. maxRollsPerDie
- This is the max number per dice type that can be rolled in a given roll command. Set to 20 by default. Commands that don't respect the roll limit will be aborted and send an error message to the discord chat.
5. emoji
- set to 'true' to enable custom emoji

#CUSTOM emoji

1. Follow instructions here https://support.discordapp.com/hc/en-us/articles/207619737-Adding-Emoji-Magic to add emoji from /dice to your discord server

2. Set "emoji": true in config.json

3. Start your bot
1. if any emoji don't work type "\:emoji:" into your channel for every emoji that doesn't work. (ie \:adv: \:tri:)
The server will output <:adv:294221000277491714> <:tri:294221000713830401>
2. Make sure those output values match the values in printValues.json

#Amazon EC2 install

1. Connect to your ubuntu Linux instance using SSH.

2. Install node
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

3. Download and unzip lastest build
wget https://github.com/Astrydax/SWEotE-Discord-Dice-Roller/archive/master.zip
unzip master.zip
cd SWEotE-Discord-Dice-Roller-master

4. Install npm for the bot
npm install

5. Configure the bot
sudo nano config.json

6. launch bot (this will launch the bot and let you close the terminal window)
nohup nodejs bot.js &>/dev/null & disown

Screen Shot 2017-03-29 at 3.40.27 PM.png

Screen Shot 2017-03-29 at 3.41.09 PM.png

Screen Shot 2017-03-29 at 3.41.38 PM.png

Screen Shot 2017-03-29 at 3.43.04 PM.png

Edited by SkyJedi
added discord link

First off, thank you for writing this. It makes our game so much easier now that we don't have to rely solely on roll20.

Using the updated files, install was a breeze.

But, I am having an issue... here's the error log... I get this and the bot logs out. Any help would be appreciated.

Quote

Rolling dice for BDelp8
Beg: undefined End: 0
g
Rolling 1 Ability Dice.
Advantage
g
Rolling 1 Ability Dice.
Advantage
p
Rolling 1 Difficulty Dice.
Threat

The Standing Count is
{ success: 0,
failure: 0,
advantage: 2,
threat: 1,
triumph: 0,
despair: 0,
light: 0,
dark: 0,
face: '<:ga:297522507701944320> <:ga:297522507701944320> <:pt:297522509685850124> ' }
Rolling dice for Thor Odinson
Beg: undefined End: 0
~\ffg_dice2\bot.js:588
var num = str.match(/\d+/g);
^

TypeError: Cannot read property 'match' of undefined
at checkNumbers (~ffg_dice2\bot.js:588:16)
at Client.bot.on.message (~\ffg_dice2\bot.js:487:9)
at emitOne (events.js:96:13)
at Client.emit (events.js:188:7)
at MessageCreateHandler.handle (~\ffg_dice2\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (~\ffg_dice2\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:120:65)
at WebSocketManager.eventMessage (~\ffg_dice2\node_modules\discord.js\src\client\websocket\WebSocketManager.js:273:31)
at WebSocket.onMessage (~\ffg_dice2\node_modules\ws\lib\WebSocket.js:442:14)
at emitTwo (events.js:106:13)
at WebSocket.emit (events.js:191:7)
Press any key to continue . . .

On 4/10/2017 at 6:54 PM, obscurus said:

First off, thank you for writing this. It makes our game so much easier now that we don't have to rely solely on roll20.

Using the updated files, install was a breeze.

But, I am having an issue... here's the error log... I get this and the bot logs out. Any help would be appreciated.

crap, just saw this. I'm updating on this thread

Where can I find the EotE Dice Roller.lnk at? I have been trying to find the link but I could not find it on my system.

31 minutes ago, thedonnie said:

Where can I find the EotE Dice Roller.lnk at? I have been trying to find the link but I could not find it on my system.

Use start.bat

4 hours ago, SkyJedi said:

Use start.bat

Thanks. I did that and this is the result I ended up with on a sample roll:

thedonnie -Today at 5:33 PM

!r gggyyrr

EotE Dice Roller BOT-Today at 5:33 PM

gb custom emoji not installed on this server. Please upload. gs custom emoji not installed on this server. Please upload. ga custom emoji not installed on this server. Please upload. yt custom emoji not installed on this server. Please upload. yb custom emoji not installed on this server. Please upload. rft custom emoji not installed on this server. Please upload. rtt custom emoji not installed on this server. Please upload.
@thedonnie, results: suc custom emoji not installed on this server. Please upload. 1 thr custom emoji not installed on this server. Please upload. 2 tri custom emoji not installed on this server. Please upload. 1
What did I do wrong with this?
43 minutes ago, thedonnie said:

Thanks. I did that and this is the result I ended up with on a sample roll:

thedonnie -Today at 5:33 PM

!r gggyyrr

EotE Dice Roller BOT-Today at 5:33 PM

gb custom emoji not installed on this server. Please upload. gs custom emoji not installed on this server. Please upload. ga custom emoji not installed on this server. Please upload. yt custom emoji not installed on this server. Please upload. yb custom emoji not installed on this server. Please upload. rft custom emoji not installed on this server. Please upload. rtt custom emoji not installed on this server. Please upload.
@thedonnie, results: suc custom emoji not installed on this server. Please upload. 1 thr custom emoji not installed on this server. Please upload. 2 tri custom emoji not installed on this server. Please upload. 1
What did I do wrong with this?

You just have to upload the emoji files from the dice/ folder into your discord server.

#CUSTOM emoji

  1. Follow instructions here https://support.discordapp.com/hc/en-us/articles/207619737-Adding-Emoji-Magic to add emoji from /dice to your discord server

Thank you. It works now perfectly.

Hello,

First of all, thank you for the this wonderful app. After some tinkering I finally got it work. However it's not displaying the dice when I roll.

*Edit* I uploaded the dice emojis and they are still not showing up when I roll.

app.png

Edited by ramza82
On 5/28/2017 at 1:04 PM, ramza82 said:

Hello,

First of all, thank you for the this wonderful app. After some tinkering I finally got it work. However it's not displaying the dice when I roll.

*Edit* I uploaded the dice emojis and they are still not showing up when I roll.

app.png

it looks like your hosting your own version. make sure you have the latest files It look like you may be using an old version, double check with !ver. 1.7.2 is the lastest. Emoji should be on by default but yours are pulling from the non-emoji file.

did you replace printvalues.js? if you have the latest version you should NOT need to replace it.

Quote

#CUSTOM emoji

  1. Follow instructions here https://support.discordapp.com/hc/en-us/articles/207619737-Adding-Emoji-Magic to add emoji from /dice to your discord server
  • NOTE: To disable emoji rename printValues_NO_EMOJI.js to printValues.js, replacing existing file.

I got it working thanks. I forgot to modify the text document to set emojis to "true".

30 minutes ago, ramza82 said:

I got it working thanks. I forgot to modify the text document to set emojis to "true".

if you have that option, you're using an old version. for the new stuff

Is there a way to track a player's experience credits strain wounds etc like you do destiny points?

1 hour ago, TheShard said:

Is there a way to track a player's experience credits strain wounds etc like you do destiny points?

!char

Seriously? That's awesome...

Great one, was wondering about something like this for a while now

Edited by Blue300