Mining pool discord notifications

Discord Pool Notifications.

Do you own a crypto-note mining pool and want to create notifications when a block is found which is then sent to your discord? Well, you have come to the right place. In this guide, I will be explaining how to create a notification system that posts a message in your discord channel whenever a block is orphaned, found or unlocked.

Prerequisites

First of all, you will need a crypto-note pool, for this guide, I am using muscleman’s source code located Here so before you go any further make sure you have a pool fully setup :)

Guide

Now lets start creating the notifications

Step one.

Your first step is to go to the directory where your pool is located, open a terminal and send the following npm I webhook-discord This will download the package required to send a message to your discord channel.

Step two.

Your next step is to go to your discord channel and create a webhook for that channel (make sure you copy the link) This link is important for getting the notification system working The link should look something like this https://discordapp.com/api/webhooks/520782368404013066/f6EyylGEHA5ZY0CczE4LiiauhxFR_VL-RB2jlSMHjAU552MBsBdumpCin6rIbOuzar6j

If you are using canary you will need to delete the canary at the beginning, also the link is no longer valid so don’t even try using it :P

Step three.

Go back to your pool’s directory and find the file called notifications.js and open it, you will need to post the following at the top of your file and make you replace xxx with the link you obtained in step two

const webhook = require("webhook-discord");

const Hook = new webhook.Webhook("xxx");

You will then need to scroll down until you see exports.sendtoall (This should be at around line 71) and paste the following code.

if (id === "blockFound") {
  const msg = new webhook.MessageBuilder()
                  .setName("Pool")
                  .setColor("#2cf454")
                  .addField(`Block found!`, "http://yourpool/#pool_blocks")
                  .setTime();

  Hook.send(msg);
}
if (id === "blockUnlocked") {
  const msg = new webhook.MessageBuilder()
                  .setName("Pool")
                  .setColor("#64bdfc")
                  .addField("Block Unlocked!", "http://yourpool/#pool_blocks")
                  .setTime();

  Hook.send(msg);
}
if (id === "blockOrphaned") {
  const msg = new webhook.MessageBuilder()
                  .setName("Pool")
                  .setColor("#dd4430")
                  .addField("Block Orphaned :(", "http://yourpool/#pool_blocks")
                  .setTime();

  Hook.send(msg);
}

Now you will need to restart your pool and viola you should now have a fully functioning notification system. Feel free to edit the color codes to a color you like and make sure you edit the URL so it matches your pool.

Thanks for reading :)

Bencey