1.0.1 • Published 2 years ago

@matta-official/bot-framework v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

🔩 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:

OptionDescriptionDefaultRequired
ownerThe ID of the bot ownertrue
tokenThe bot tokentrue
guildThe ID of the guild to deploy commands infalse
command_dirThe directory where commands are stored./commandsfalse
component_dirThe directory where components are stored./componentsfalse
event_dirThe directory where events are stored./eventsfalse
configThe path to the config file{}false
forceForce the bot to refresh the commandsfalsefalse

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.