Skip to content
A small but modular bot for Discord
JavaScript Dockerfile
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update pull_request_template.md Oct 19, 2018
assets Forgot the fontlist file Aug 14, 2018
commands Made help information look pretty and constistent Apr 7, 2019
lib Made help information look pretty and constistent Apr 7, 2019
.eslintrc.json npm audit and removes standard completely Aug 24, 2019
.gitignore Changes figlet to have a better help page aswell as more error messages Mar 17, 2018
.travis.yml
CONTRIBUTING.md Small fix for CONTRIBUTING May 3, 2019
Dockerfile Fix for issue #13 and small change to dockerfile Aug 4, 2018
LICENSE Initial commit Feb 10, 2018
README.md Made help information look pretty and constistent Apr 7, 2019
docker-compose.yml Fixes last commit using wrong restart Jun 22, 2018
index.js Made help information look pretty and constistent Apr 7, 2019
package-lock.json Adds eslint as dependency in place of standard Aug 24, 2019
package.json

README.md

Simple Discord Bot Build Status JavaScript Style Guide

This is a Discord bot that has a variety of different features ranging from creating huge text to renaming random people.


Setup

Configuration

Create a .env file and set the following values:

DISCORD_TOKEN=<discord bot token>
PREFIX=<prefix for bot commands>
REPO_BASE_URL=https://github.com/Hoi15A/simple-discord-bot
EMBED_COLOUR=<hex colour code>
BOT_OWNERS=<user Id's>

You can enter multiple values for owner and admin roles, separate them with ,

Running the bot

General Requirements:

  • NodeJs
  • npm

Using just node

Just run npm install to get dependencies and start with npm start

Using pm2

  • Install the pm2 process manager by running npm i pm2 -g.
  • Download the dependencies with npm install like above.
  • Start the bot with pm2 using pm2 start index.js and stop the bot using pm2 stop index.js

Using docker

Requirements:

  • Docker
  • Docker-compose

Then simply run npm run docker-build to create the image (can be used to recreate after updates).
npm run docker-down to stop the bot.
npm run docker-up to start it again.


Adding your own commands

Adding commands is actually very easy, they all follow a structure similar to this:

const format = require('../lib/format.js')
const send = require('../lib/messageSender.js') // includes a few handy functions that automatically format responses nicely

const info = {
  'name': 'getroles', // the name of the command and how it is called (in this example its ""<prefix>getroles")
  'requiredPermission': '', // either BOT_OWNER, a discord permission string or empty for everyone
  'colour': '#3a7fc4', // colour for embeds sent by this command. If not set the default from the .env is used
  'enabled': true, // if you want the command enabled by default, false if you don't
  'man': format.help( // information printed by the help command
    'getroles', // command title
    'Returns a list of all roles in this guild', // description
    `${process.env.PREFIX}getroles`, // use
    [], // examples
    'MANAGE_GUILD' // required permission if any
  )
}

module.exports = {
  getInfo: function () {
    return info
  },
  command: function (msg, params) {
    // you can do whatever you like here, this is just the getroles command as an example
    let allRoles = []
    msg.guild.roles.map(role => {
      allRoles.push(role.name + ': ' + role.id)
    })
    allRoles.sort((a, b) => a.localeCompare(b))
    send.standardResponse(msg, allRoles.join('\n'), info)
  }
}

For a command to be valid it needs to be a .js file in the commands directory and must export getInfo() and command().

You can’t perform that action at this time.