Coder Social home page Coder Social logo

discot's Introduction

discot-logo

Node CI npm npm NPM

Create simple, yet powerful discord bots focusing on commands.

What is it ?

Discot is a wrapper around discord.js to simplify the creation of server bots. It permists to focus on the creation of commands instead of spending time working with discord's API.

Usage

Installation

Discot can be installed using yarn or npm.

npm install discot
# or
yarn add discot

Example

const bot = new Bot({
    token: 'discord_token', // default value: process.env.DISCORD_TOKEN
    prefix: '!'             // default value: '!'
});

bot.addCommand({
        name: 'ping',
        description: 'Reply pong',
        action: message => message.channel.send('pong')
    })
    .addCommand({
        name: 'say',
        description: 'Send the text passed as first argument. Usage: "!say hello"',
        action: (message, args) => message.channel.send(args[0]),
        requiredArgCount: 0
    })
    .start(() => console.log('Bot started.'));

discord-example

message in the action method for a command is the object from discord.js

API

Bot constructor

const bot = new Bot({
    token: 'discord_token', // default value: process.env.DISCORD_TOKEN
    prefix: '!'             // default value: '!'
});

Set your discord token in the env variable DISCORD_TOKEN (use dotenv).

bot.addCommand(command)

bot.addCommand({
    name: 'ping',              // name of the command, the one to type
    description: 'Reply pong', // description displayed in the help message
    action: message => message.channel.send('pong'), // action to execute when the command is triggered
    requiredArgCount: 1        // amount of required parameters for the command for validation
})                             

message in the action method for a command is the object from discord.js

bot.start(callback?)

bot.start(() => console.log('Bot started.'))

The callback is triggered when the bot is started.

Contribute

Pull requests are welcome ! Feel free to contribute.

Credits

Coded with ❤️ by Corentin Thomasset.

License

This project is under the MIT license.

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.