This package has been deprecated

Author message:

this version has been deprecated

donbot
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

donbot

discord bot framework based on discord.js

Installation and Usage

Install via npm

npm install --save donbot

Import the base client

const { Bot } = require("donbot");

Provide the bot with login data and connect. The Bot class extends the discordjs.Client so all methods and properties can be found in an bot object.

const bot = new Bot({
  token: "LOGIN_TOKEN",
  prefix: "+",
  owner: "OWNER_ID",
});
 
bot.connect();

token is the login token obtained from the discord dev website

prefix is the prefix each command must have to be recognized as one. For this example we will pe using + as our prefix.

onwer is the id of the user who owns the server. This user will always be allowed to execute commands

First Command

Let's try to make a simple command that replies with the users name

First we have to import the class each command is based on

const { TextCommand } = require("donbot");

Then we make a new class extending TextCommand. In the constructor we have to call the super() method and pass it an object with command specific arguments

class EchoUsername extends TextCommand {
  constructor() {
    super({
      command: "username"
    });
  }
}

The functionality is made with a run(). The method takes the bot, the original message and a parsedMessage which has all arguments parsed out of the message and ready to use in your code;

public async run(bot, message, parsedMessage) {
    message.reply(message.member.displayName);
}

The full code will look something like this

const { Bot, TextCommand } = require("donbot");
 
const client = new Bot({
  token: "YOUR_TOKEN",
  prefix: "+",
  owner: "YOUR_ID"
});
 
client.connect()
 
class EchoUsername extends TextCommand {
  constructor() {
    super({
      command: "username"
    })
  }
 
  public async run(bot, message, parsedMessage) {
    message.reply(message.member.displayName);
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i donbot

Weekly Downloads

1

Version

1.3.0

License

ISC

Last publish

Collaborators

  • dan_lio