@matta-official/bot-framework

1.0.1 • Public • Published

🔩 Bot Framework

A simple Discord bot command/event framework. Supporting slash commands.

Features

  • Slash Commands
  • Utility Classes
  • Full API coverage (using discord.js)
  • Runs on Node
  • es6 syntax

Intallation

Install from npm

npm i bot-framework

Install dependencies

npm i discord.js

Create the bot

import { Bot } from 'bot-framework';

const client = new Bot({
	owner: 'YOUR_OWNER_ID',
	token: 'YOUR_BOT_TOKEN',
	command_dir: './commands',
	component_dir: './components',
	event_dir: './events',
	config: './config.yaml',
});

client.login();

Contributing

Contributions are always welcome! More info on how to contribute coming soon™.

Authors

Reference

Bot

When creating a bot, you can provide the following options:

Option Description Default Required
owner The ID of the bot owner true
token The bot token true
guild The ID of the guild to deploy commands in false
command_dir The directory where commands are stored ./commands false
component_dir The directory where components are stored ./components false
event_dir The directory where events are stored ./events false
config The path to the config file {} false
force Force the bot to refresh the commands false false

Commands

Create a command by doing the following:

import { Command } from 'bot-framework';

export default new Command({
	name: 'ping',
	description: 'Responds with pong!',
	// Also supports 'options', 'permissions', 'type'

	callback: (client, interaction) => {
		interaction.reply('Pong!');
	},
});

Components

Components are a framework for adding interactive elements to messages. Create a component by doing the following:

import { Component } from 'bot-framework';

export default new Component({
	id: 'press_me',
	type: 'button', // can also be select_menu

	callback: (client, interaction) => {
		interaction.reply('Pong!');
	},
});

Events

Events have a different number of arguments passed, check the discord.js documentation for information on each. Always pass the client before any additional arguments.

import { Event } from 'bot-framework';

export default new Event({
	name: 'ready',
	once: true, // omit this to listen for multiple events

	callback: (client, ...args) => {
		console.log(`Logged in as ${client.user.tag}!`);
	},
});

Datastore

Coming soon™ - Will be a simple key/value store accessible from the client object.

Readme

Keywords

none

Package Sidebar

Install

npm i @matta-official/bot-framework

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

12.9 kB

Total Files

14

Last publish

Collaborators

  • matta-official