Giter Club home page Giter Club logo

axoncore's Introduction

AxonCore

Complete, Stable, Fast, Universal
The best all-in-one framework for discord bots. The power of a fully featured framework, the simplicity of a predictable API.

AxonCore is an all in one framework, built to make bot development fast and easy. Focus only on what matters: creating commands for your users. AxonCore handles all the hard and annoying work for you. Take advantage of its stability and robustness to fasten your development.
AxonCore is opiniated to enforce good code practice and has all features you could possibly want in a framework, from command and event handlers, to full Database support, more details further down.
AxonCore is lib agnostic, which mean you can use it indifferently with Eris, Discord.js or Detritusjs.

When to use AxonCore:

  • If you want power and stability in your bots.
  • Creating simple bots fast and easy with many customisation options.
  • Creating large stable bots designed to scale.

When not to use AxonCore:

  • If you prefer to create your own client for your specific needs.
  • If you prefer an unopiniated solution or don't want to use the features AxonCore offers.
  • If you don't want a Database at all or prefer other ways to interact with a DB.

Main Features

  • Client - Extendable custom client with an advanced permission system.
  • Command Handler - Easy and fast fully customisable command creation with advanced permission and options system, command throttling and subcommands.
  • Event Handler - Setup and react to discord events.
  • Library agnostic - Work with any javascript discord library (eris, discordjs, detritusjs).
  • Modular - Separate your bot into several modules to entirely encapsulate your application.
  • Extendable - Extend anything that you want on top of the framework.
  • Controlable execution flow - Control every step from client initialisation to command execution.
  • Database - Built in database support (extendable to any database type - SQL, NoSQL).
  • Advanced error management - Advanced context management and error tracking for easy bug-hunting.
  • Hooks - Execute functions and actions on events (inhibitor hooks, pre/post-execute hooks, finalizers hooks). [TODO]
  • Translations - Built-in support for translation and message management system.
  • Logging - Built-in custom logging.
  • Tracking - Easily track and debug command usage, events and errors with custom events emitted by AxonCore.
  • Typescript support - Full typescript and intellisense support

Philosophy

AxonCore was built with specific aims. At it's core, it makes developing a bot fast and easy, particularly for developers that want to create small and specific bots for communities (singe server, small set of servers). However, this framewok is also designed for scaling, and creating a big public bot is super easy and fast thanks to all features embeded in the framework and its stability.

Primarily designed to work with Eris, all the library implementation was abstracted to make the framework library agnostic, which means you can use it with other existing JS libraries, like Discord.js, Eris or Detritusjs).

It was built with an OOP approach and uses predictable abstraction while keeping the power and speed of javascript prototypal nature. Separation of concerns makes sure everything is correctly encapsulated, maintainable and extendable. The framework is fully modular (AxonCore uses Modules that holds set of commands, events, etc...). It also comes with a lot of features for all possible usages and needs. AxonCore will handle everything, leaving only one job to you: creating the bot. It does however still allow you to edit and customise anything you want with a full extendable approach and total control over the initialisation and execution flow.

Setup

Examples
To get your application started easily, you can use the create-app boilerplate: create-axoncore-app.
Here's how to use it:
yarn create axoncore-app --lib <library> --type <module management type> <destination>
npm init axoncore-app --lib <library> --type <module management type> <destination>

  • Available libraries: eris, discordjs.
  • Available module types: commonjs, esm, ts.

AxonCore has FULL typescript support.
When you install the package the first time, you can choose the library you are using, and the package will automatically link the library typings. That will allow you to have full and complete typings for your typescript project or for using intllisense.
Note: AxonCore creates a .axoncorerc file with the default configuration. Editing or deleting this file will change the typings link on the next install.

Features Overview

Because it is built with the correct level abstraction, using AxonCore feels natural and powerful. Everything is easily accessible, extendable and customisable. AxonCore takes full benefits of promises while having a strong and complete error management system. Events are emitted on command execution (on success / failure / error) with a full context information.
It also takes advantage of the lastest ECMAScript and Node features (Node12, ECMAScript 2019...). It also uses ESM to fully profit of ES6 modules (import / export syntax).

Guild configs are abstracted in a specific cache, which allows easy access and data management and switching to other types of caches later on (eg: LRUCache, redis...).

There's also a built-in help command that you can easily override if you want to.

Commands

You can create commands by extending Command, CommandPermissions and CommandOptions.

Listeners

You can also create listeners by extending Listener.
A Listener is a function that is run when a Discord-specific event occurs. Many listeners can be bound to one Discord event.
A Handler is an object responsible of running all listeners for a specific Discord event.

Databases support

All database interactions are done by AxonCore via an ADBProvider.
There are specific providers for each type of Database, such as:

The only thing you will handle is a GuildConfig and an AxonConfig object. Those are stored in the GuildConfigCache.

Translation support

TODO

Logging support

Client lifecycle

Schema TODO

Command lifecycle - Hooks

Schema TODO

Execution context, error management, usage tracking

A Command always should returns a Promise wrapping a CommandResponse. Either explicitely by creating a CommandResponse and wrapping it in a Promise (CommandResponse.resolve()), or implicitely via sendMessage, sendSuccess or sendError. CommandResponse in these last cases is filled with appropriate information regarding command execution.

The framework will then build a CommandContext object after each command execution.
Two types of events will then be emitted, depending on the scenario:

  • The command was executed entirely and successfully. A commandExecution event is emitted by AxonClient with status = true.
  • The command was called but something blocked the execution and it was not successfully executed. This can be due to a missing permission, invalid usage, or even a condition in the command.execute method (via the sendError method for instance). In this case a commandExecution event is emitted with status = false.
  • The command was executed but an error occured in the execution (API error, code error...). A commandError event is then emitted.

You can listen to these events according to the following example.

axonClient.on('commandExecution', (status: Boolean, commandLabel: String, { msg: Message, command: Command, guildConfig: GuildConfig, context: CommandContext }) => {} );
axonClient.on('commandError', (commandLabel: String, { msg: Message, command: Command, guildConfig: GuildConfig, err: AxonCommandError }) => {} ); // err.context = CommandContext

For listener execution, listenerExecution and listenerError events are also emitted by AxonClient.

axonClient.on('listenerExecution', (status: Boolean, eventName: String, listenerName: String, { listener: Listener, guildConfig: GuildConfig }) => {} ); // event: the event name, listener: the Listener object
axonClient.on('listenerError', (eventName: String, listenerName: String, { listener: Listener, guildConfig: GuildConfig, err: Error }) => {} );

Utilities

Notes

Dependencies

ESM is used to run this framework. It makes using ES6 modules possible, of which AxonCore takes full advantage of.
See here on how to use ESM.
You don't however need ESM to use this framework, using require is also compatible.

You can use any Database you want. If support for this Database isn't built-in, you can create your own by extending ADBProvider and passing it in AxonOptions.
There is currently support for: Mongoose.
You can also use the available JSON variant, if you don't need a DB solution.

Dev-tools

This project strongly uses eslint to enforce style rules and to avoid bugs. The eslint config used can be found here. Docs are built with a custom solution that can be found here.
Github actions used in this project can be found here:

Documentation

All documentation can be found here!

Examples

AxonCore is being used in these cool projects:

  • Ease - Enhance A Server Easily - A all in one modular bot that you can build and selfhost.
  • WebSPELL - A custom RSS feed subscriber bot made for a french community.
  • NookAmis - A custom Animal Crossing companion bot made for a french community.

Contributions

Feel free to contribute to this project by opening PRs or Issues. Contributions are always welcome.
To know more about contributions, discuss the development of AxonCore or get help, you can join our discord server here.

axoncore's People

Contributors

aervyon avatar bsian03 avatar dependabot[bot] avatar eleosos avatar john-bv avatar khaaz avatar khaazz avatar matthew119427 avatar santhosh-annamalai avatar taosemc avatar wh0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

axoncore's Issues

ES6 named import support

Add ES6 modules support alongside require.
Currently there is no way to use named import. We need to add support for this while we wait for node 14 LTS

Message Collector / await Message

An utility engine to use await message/message collector easily could be a nice addition as well.

It needs to only be an Utility feature optional.
It needs to be efficient and bug free but complete and customizable.

More database support

Adding support for more Database could be a super interesting features.

Suggestion:
Embeded:

NoSQL:
Others NoSQL engine?

  • ArangoDB
  • RethinkDB

SQL:

  • PostGreSQL
  • Mysql

All contributions are welcome.
The Database Service just offer an interface with the DB for AxonCore since it uses Database natively.
It needs to replicate the current behavior with a different Database engine.

BUG: Invalid embed limit checker

BUG REPORT

Description

image
embed.length doesn't exist

Issue state:

  • I know how to fix this and I will open a PR to do so
  • I am just reporting the issue

Details:
This issue is about:

  • Typings
  • Documentation
  • Bug in existing feature
  • Missing feature / breaking change
  • API / library update
  • None of the above (don't know what the issue is about)

Utility: Reaction Collector

Add a Reaction Collector module that behave like MessageCollector.
No particular requirement here, but can be discussed if needed.

TypeError: this.client.executeWebhook is not a function

The next error code is displayed on console after running the start script:

yarn run v1.21.1
$ node -r esm src/index.js
  ___                  _____                
 / _ \                /  __ \               
/ /_\ __  _____  _ __ | /  \/ ___  _ __ ___ 
|  _  \ \/ / _ \| '_ \| |    / _ \| '__/ _ \
| | | |>  | (_) | | | | \__/| (_) | | |  __/
\_| |_/_/\_\___/|_| |_|\____/\___/|_|  \___|
 
VERSION: 2.0.1
 
[ 23h00m47s ] - [ INFO  ] => Selected Logger: Default Logger.
[ 23h00m47s ] - [NOTICE ] => Logger ready.
[ 23h00m47s ] - [ INFO  ] => Selected Library Interface: ERIS.
[ 23h00m47s ] - [NOTICE ] => Library Interface ready. [TYPE: 0]
/home/kike/prs/discord/dead-master/node_modules/axoncore/src/Libraries/eris/lib/ErisClient.js:1
TypeError: this.client.executeWebhook is not a function
    at ErisClient.triggerWebhook (/home/kike/prs/discord/dead-master/node_modules/axoncore/src/Libraries/eris/lib/ErisClient.js:80:27)
    at AxonUtils.triggerWebhook (/home/kike/prs/discord/dead-master/node_modules/axoncore/src/Utility/AxonUtils.js:129:33)
    at Client.log (/home/kike/prs/discord/dead-master/node_modules/axoncore/src/AxonClient.js:442:28)
    at new AxonClient (/home/kike/prs/discord/dead-master/node_modules/axoncore/src/AxonClient.js:168:14)
    at new Client (/home/kike/prs/discord/dead-master/src/Client.js:19:5)
    at Object.<anonymous> (/home/kike/prs/discord/dead-master/src/Bot.js:56:13)
    at Generator.next (<anonymous>)
    at Object.<anonymous> (/home/kike/prs/discord/dead-master/src/index.js:1)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Enhanced Cooldown system

More customisation for cooldown.
Ability to use one or many of these CD types:

  • Channel cd
  • User cd
  • Member cd
  • Guild cd
    ...?
    CD should be coordinated by a CommandCooldown manager class, that will call ChannelCooldown, UserCooldown, MemberCooldown, GuildCooldown.
    This should be done using correct hierarchy and extension.

Typings: File splitting

Creating just so we can keep track of stuff

File structure:

AxonCore
| typings
| | Definitions and subdefinitions
| | libraries
| | | Eris.ts
| | | DiscordJS.ts
| | | Detritus.ts
| | | index.ts (read off this file)
| | | Normal library typings - Includes library specific enums - default to contain Eris enums
| | misc
| | | interfaces.ts
| | | enums.ts - Only AxonEnums and DiscordEnums

I'll open and link PR once this is ready

BUG: Prompt is not collecting any message

BUG REPORT

Overview

Prompt is not collecting any message.

Description

Issue state:

  • I know how to fix this and I will open a PR to do so
  • [ X ] I am just reporting the issue

Details:
This issue is about:

  • Typings
  • Documentation
  • [ X ] Bug in existing feature
  • Missing feature / breaking change
  • API / library update
  • None of the above (don't know what the issue is about)

Additional information:

  • Node.js version: V12.18
  • AxonCore version: 2.1
  • Library used: (discordjs)

Typings

Typings need to be done.
The file is already created, just need to be completed.
(make sure to do it on dev branch)

I can't do it at the moment so until I am able to do it, it is open to anyone.

Documentation update

The requirements are as follow:

  • generate from typings (the primary goal is to ditch all jsdoc from the js)
  • looks good / be nice to use for the user
  • have an easy way to add data (eg: guides etc.) for example via markdown files (which would be the best).
  • be easy to deploy via github page

We already thought about a gatsby solution that could be promising.
(ping @VoidNulll )

BUG: Incorrect return type

BUG REPORT

Overview

image

This returns a buffer. Could add option to return as string

Issue state:

  • I know how to fix this and I will open a PR to do so
  • I am just reporting the issue

Details:
This issue is about:

  • Typings
  • Documentation
  • Bug in existing feature
  • Missing feature / breaking change
  • API / library update
  • None of the above (don't know what the issue is about)

Utility: Paginator

Add a paginator module via reaction (embed or not embed).
Features:

  • custom emoji
  • content per page (easy to use: eg via a function?)
  • timeout

Optional/Interogation:

  • allow asking for a page directly on input (defaut page)
  • page change via different input type (other than emoji)

Goal: paginator used to list items in a message (eg: score etc)
Exported as an independant module (general utility tool)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.