Coder Social home page Coder Social logo

wayne's Introduction

paul

A modular bot template for discord.js.

Getting Started

First, edit the bot.js file and fill out OWNERID, PREFIX, and TOKEN.

The OWNERID variable should be set to your Discord ID, which you can obtain by enabling developer mode (found in the "apperance" tab in settings), right clicking your name in the online list of any server, and then clicking "Copy ID".

The PREFIX variable is used to tell the bot what prefix your commands should use. Most bots use !.

The TOKEN variable is your Discord bot's token. You can get this from the Discord Developer Portal.

After you've filled these out, install the indev version of discord.js using NPM. Be sure you have node.js >=6.0.0, and then run npm install hydrabolt/discord.js#indev. If you need voice support, you can run npm install discord.js node-opus for node-opus support, or npm install discord.js opusscript for opusscript support.

Adding Commands

To add commands to the bot, create new .js files in the commands directory. After writing whatever JavaScript is neccesary for your command, add the following lines to the bottom of the file:

module.exports = {
  main: (bot, msg, settings) => {
	//your code goes here
  },
  args: '<string>',
  help: 'sample help text',
  hide: false
}

The main function gives you access to everything in the bot.js file. So, for example, to send a reply, you can just add msg.reply("reply") inside the main function, and it will run whenever the command is called.

The other three lines at the bottom help to generate the help text. If you set hide to true, it won't show up inside the help menu, but otherwise, you should include args and help, and fill them out to help the end user.

args tells the user what arguments they need to provide, and help is just to provide generic help text.

Running

Finally, to run the bot, a simple node bot.js will usually do. However, if you want to keep your bot running, I suggest you use forever. Install it with npm install forever -g, and then just run forever start bot.js inside the same folder as the bot.

Default Functionality

Paul provides four core commands within bot.js out of the box:

  • help - Generates a help message based on loaded commands
  • load <file> - Loads a new command from <file>
  • unload <file> - Unloads <file>, disabling the command
  • reload - Reloads all currently loaded commands

Alongside these, there are three commands in the commands folder by default. They can be removed, but they serve as good utility commands.

  • ping - Used to test if the bot is responding.
  • setgame - Changes the bot's status (what game they are "playing").

Roadmap

  • Configuration file support, and an easy way to access it.
  • Better logging

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.