New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@diamondbot/core

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diamondbot/core

Modular library to easily build discord bots

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

Diamond Bot Core

NPM Maintainability status Code style: XO

This is the starting point for creating awesome Discord bots.

Install

npm install @diamondbot/core

Usage

Just instantiate the bot, make it login with your discord token and you are done!

// index.js
import { Bot } from '@diamondbot/core';

const bot = new Bot();

bot.login('YOUR_DISCORD_TOKEN');

The bot by itself has no commands. Take a look at our ever-expanding list of commands that you can add to the bot, or if you want some custom stuff you can easily build your own!

Let's make a command to get cat images (this is just an example, we already have a command for cats)

// commands/cat.js
import { ChatCommand } from '@diamondbot/core';

export default class CatCommand extends ChatCommand {
	constructor () {
		super({
			name: 'cat', // This will be used as the name to invoke the command, eg: !cat
			alias: 'cats' // As the name says it, this is an alias for the command, eg: !cats
		});
	}

	async run ({channel}, [count]) { // Our command will be able to accept a parameter, eg: !cat 3
		count = Number(count);
		count = count > 1 ? count : 1;

		for (let i = 0; i < count; i++) {
			await channel.send('https://cataas.com/cat');
		}
	}
}

Done! Our command is created, now we have to tell about it to our bot, let's go back to our index.js file.

// index.js
import { Bot } from '@diamondbot/core';
import CatCommand from './commands/cat.js';

const bot = new Bot();

bot.addCommand(CatCommand);

bot.login('YOUR_DISCORD_TOKEN');

Now our bot is ready to fill our channels with cats!

Contributing

Contributions are always welcome! Feel free to fix any bug you find or propose commands to add to the bot.

Support

If you use this package please consider starring it :)

Keywords

diamondbot

FAQs

Package last updated on 07 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts