Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

CityOfZion/neo-discord-bot

Repository files navigation

NEO Discord Bot

Discord bot made for NEO community.

Description

This bot is specially made for the NEO (previously ANS) Discord server. Its purpose is to provide a multitude of functionality for new and seasoned members. Its primary function is to respond to certain text in channels by sending the user a message with information, such as "The current GAS price is $10, B$0.00001 and rank 5".

Modules

You can use the discord api methods listed here and commando methods listed here:

  • client is the client is Discord client
  • message is the message object

To write extra modules please take a look at the imports/commands folder. You can also find documentation about writing extra modules, here.

const { Command } = require('discord.js-commando');
const request = require('request');
const currency = require('currency-formatter');

module.exports = class NeoCommand extends Command {
  constructor(client) {
      super(client, {
          name: 'neo',
          group: 'neo-related',
          memberName: 'neo',
          description: 'Shows more details for NEO using CoinMarketCap.',
          examples: ['!neo'],
          guildOnly: false,
      });
  }

  async run(message) {
    request.get({
        url: 'https://api.coinmarketcap.com/v1/ticker/neo/?convert=USD',
        json: true
      },
      function (e, r, prices) {
        const price = prices[0];
        message.channel.send(`current NEO price = ${currency.format(price.price_usd, { code: 'USD' })}, B${price.price_btc} (CoinMarketCap)`);
      });
  }
};

How to setup

  • Clone this repository
  • In the directory where it's located do yarn install
  • Change the values in settings.js to your own values
  • Run the bot with yarn start (if you don't want to use pm2, you can use node --harmony index.js)

Settings explanation

  • botToken - Sets token of Discord bot.
  • reportChannel - Report details are posted on this channel after reporting a user.
  • supportChannel - Periodic Neo service status updates are sent to this channel.
  • ownersId - Specifies which users has admin rights for bot - command list for admins, more details about user permissions.
  • botPrefix - Sets custom prefix for all commands.
  • autoReconnect - Automatically reconnects the bot in case of connection issues.
  • unknownCommandResponse - If bot doesn't recognize specified command, it will send a message about it (with reference to help command).
  • disableEveryone - Filters out all messages sent by bot and always removes @everyone mention.
  • coinDictUrl - Url used to fetch coin dictionary.
  • coinDictUpdateInterval - Interval which defines how often dictionary should be updated.
  • marketPriceCommand - Contains settings related to market price command.
    • marketPriceChannel - Market price details are posted on this channel.
    • updateInterval - How often should market price be updated.
    • smartPriceMessagesThreshold - Previous posted message will be updated (instead of posting new one) if threshold is not reached.
    • uniqueStringOfCommand - Unique string which is present only in market price command.