Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alvarocastro/diamondbot
Modular library to easily build powerful discord bots
https://github.com/alvarocastro/diamondbot
bot bot-framework chat chatbot discord discordjs framework
Last synced: 3 days ago
JSON representation
Modular library to easily build powerful discord bots
- Host: GitHub
- URL: https://github.com/alvarocastro/diamondbot
- Owner: alvarocastro
- License: mit
- Created: 2021-01-26T02:05:58.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-23T01:41:52.000Z (over 3 years ago)
- Last Synced: 2024-11-07T01:05:13.738Z (14 days ago)
- Topics: bot, bot-framework, chat, chatbot, discord, discordjs, framework
- Language: JavaScript
- Homepage:
- Size: 383 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Diamond Bot Logo](/logo.png)
# Diamond Bot
[![NPM](https://img.shields.io/npm/v/@diamondbot/core)](https://www.npmjs.com/package/@diamondbot/core)
[![Maintainability status](https://img.shields.io/codeclimate/maintainability/alvarocastro/diamondbot)](https://codeclimate.com/github/alvarocastro/diamondbot/maintainability)
[![Code style: XO](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)Modular library to easily build powerful Discord bots.
- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [Support](#support)## Install
```bash
npm install @diamondbot/core
```## Usage
Just instantiate the bot, make it login with your discord token and you are done!
```js
// 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](/commands/README.md) 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/cats))
```js
// 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.
```js
// 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 :)