0.12.3 • Published 4 years ago

@centrum/framework v0.12.3

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

@centrum/framework

A semi-complex bot framework using discord.js

Installation

npm install @centrum/framework

Basic Example

import { CentrumClient, Events } from "@centrum/framework";

const client = new CentrumClient({
	fetchPrefix: () => "!",
	readyMessage: client => `${client.user.tag} (${client.id}) is ready!`,
});

client.on(Events.Message, message => {
	if (message.author.bot) return;

	if (message.content.startsWith("ping")) return message.channel.send("Pong!");
});

MessageHandler

client
	.on(Events.Message, async message => {
		if (message.author.bot) return;
		return MessageHandler.validatePrefix(message);
	})
	.on(Events.PrefixedMessage, async (message, prefix) => {
		const [, args] = MessageHandler.resolveArgs(message, prefix);

		const name = args.shift();
		if (!name) return;

		return MessageHandler.validateCommand(message, args, name);
	})
	.on(Events.ValidCommand, async (message, command) => {
		try {
			client.emit(Events.CommandRun, message, command);
			const result = await command.run(message);
			client.emit(Events.CommandSuccess, message, command, result);
		} catch (error) {
			client.emit(Events.CommandError, error, message, command);
		} finally {
			client.emit(Events.CommandFinish, message, command);
		}
	});

Changelog

v0.11.0 - v0.11.1

  • Overall of betterment changes.
  • Removed the mentions feature for commands until can implement better system.
  • Added CentrumError

v0.10.0

  • Added Paginator
  • Added TSDoc comments everywhere. Thanks @ethamitc

v0.9.0 - v0.9.1

  • Added Injector
  • Added InjectorManager
  • Overall changes and fixes

v0.8.2

  • Add loadEvents() to CentrumClient to mimic the functionality of CommandManager#load()
  • Changed return type of CommandManager#load() to CommandManager

v0.8.0 - v0.8.1

  • Add DirRegistry
  • Changed CentrumClient to now extend BaseManger<K, V> again
  • Add CallableExtendedCommand
  • Changed CommandManager
    • Add load() to load commands using a path (from process root)

v0.7.0 - v0.7.1

  • Minor changes and bug fixes (honestly did not mean to version to v.0.7.0 only to v0.6.1

v0.6.0

  • Changed MessageHandler
    • All methods in the class are now static.
    • All validators emit the appropriate event.
  • Rewrote all unit tests
  • Changed CentrumClient
    • Minor changes and bug fixes
  • Changed ClientOptions
    • Added readyMessage
  • Rewrote DatabaseManager
  • Changed Events
    • Added events for MessageHandler
    • Fixed a typo

v0.5.0 - v0.5.4

  • Added Event enum
  • Changed MessageHandler
    • Added bot-ception
  • Other minor changes and bug fixes

v0.4.1 - v0.4.2

  • Changed BaseManager
    • Removed Enmap as an option for a cache due to auto install better-sqlite3

v0.4.0

  • Changed AccessManager to PermissionLevelManager
    • Better handling of permission levels.
  • Changed CommandManager
    • register() method now takes only the command as a parameter.
  • Changed Command
    • Added a check to see if the command name exists in the constructor.

v0.3.3 - v0.3.6

  • Fixed major bugs pertaining es modules.

v0.3.2

  • Added the export for MessageHandler

v0.3.1

  • Fixed type augments for module discord.js

v0.3.0

  • Added MessageHandler
  • Changed CommandManager
    • Removed all instances of commandHandler()

v0.2.1

  • Changed CommandManager
    • Added preHandler() and postHandler()
    • Added checks for commandHandler()
    • Other minor changes and fixes

v0.2.0

  • Added CentrumClient
  • Changed CommandManager
    • validateFlags() is now resolveFlags()

v0.1.0

  • Added BaseManager
  • Added DatabaseManager
  • Added AccessManager
  • Added Command
  • Added CommandManager
0.12.3

4 years ago

0.12.1

4 years ago

0.12.2

4 years ago

0.12.0

4 years ago

0.11.8

4 years ago

0.11.9

4 years ago

0.11.4

4 years ago

0.11.5

4 years ago

0.11.6

4 years ago

0.11.7

4 years ago

0.11.3

4 years ago

0.11.2

4 years ago

0.11.1

4 years ago

0.10.0

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.0

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago