Giter Club home page Giter Club logo

discordbottemplate's Introduction

Bot Template

This is a template for a Discord bot using DiscordJS and Discord's new slash commands

The bot uses a custom permission system and a user management with coins and levels using MongoDB/mongoose.

Commands

All commands should be in the command path specified in your config.json (default is ./commands)

Structure of an example command:

Name: The name of the command

Category: The category of the command (deprecated) - default: Uncategorized

Options: The slash command options More on the Options - default: []

Permission level: The minimum required permission level to execute the command (default levels are 0 - 4 but you can adjust them manually) - default: 0

Currency cost: How much the command costs - default: 0

const Base = require("../base/Command");

class ExampleCommand extends Base {
    constructor(client) {
        super(client, {
            name: "exampleName",
            category: "ExampleCategory",
            options: [
                {
                    "name": "example_option",
                    "description": "Example option description",
                    "type": 3,  // Type 3 is string
            }],
            description: "Example commad description.",
            permissionLevel: 2,
            currencyCost: 10,
        })
    }

Execution of the command:

The run function gets the data of the user passed as an argument.

The command should resolve the string or embed you want to return to the user.

The options passed by the user can be accessed via this.args

    run(userData) {
        return new Promise(async (resolve, reject) => {
            resolve(`Example Option: ${this.args.example_option}, Current coins: ${userData.coins}`)
        })
    }

}

module.exports = ExampleCommand;

Events

All events should be in the command path specified in your config.json (default is ./events)

The name of the file specifies the name of the event (Case sensitive)

The event gets passed all the parameters - in this case it's only the message one

const Base = require("../base/Command");

class MessageEvent extends Base {
    constructor(client) {
      this.client = client;
    }

    run(message) {
        if(message.content.includes('beep'))
          message.reply("boop)
    }

}

module.exports = MessageEvent;

discordbottemplate's People

Stargazers

Meesum Ahmed avatar Philo avatar

Watchers

Felix Schubert avatar

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.