bot-prefab-package v3.3.0
Bot-Prefab
Join the Discord server if you have any questions!
What is this?
This package is based on a project of mine bot-prefab
and is meant to offer the same functionality as the prefab but easier to use.
Installing and usage
Using npm
:
$ npm i bot-prefab-package -g
or using yarn
:
$ yarn global add bot-prefab-package
Now, go to the folder where you keep your projects and run prefab
in a terminal (you might have to re-open the terminal after installing the package globally so it adds the command). This will open up the CLI. From here, you can create new projects, update existing ones, edit them, ...
CLI
After running
$ prefab
it will prompt you different options to chose from.
New project
To create a new project, it will ask your for a name for that project and which language you would like (JavaScript or TypeScript).
Update a project
The idea of the prefab is to allow you to easily create projects but also to easily update to the newest version. Here's how it works:\
All necessary base-prefab classes and files will be located in src/prefab
. However, the classes you use are located in src/util
and extend the base-prefab classes. This allows you to add anything you would like to add yourself to your own class and to update, the CLI tool will simply replace the base-files!\
This setup also allows you to e.g. change which built-in features (and/or commands) you want to have, switch database systems, ... without too much incovenience.\
Any changes of the files in src/prefab
and src/commands/prefab
might be lost when updating, as these will be completely replaced!
Add command
This is a quick way of adding a new command - it will ask you for the command type (normal message or slash command), a command name and a category. After that, it will automatically add a new file in the category folder (and create the category folder if it doesn't exist already) and add some template code for you to work with.
Add event
Simply chose which event(s) you would like to add and it will create the event(s) categorized into specific groups as well as blank template including the the parameters of that event and the necessary type declarations.
Add types
To make the most out of the Manager
class, I recommend defining the key and document type it is storing. For that, you can use either JSDoc
as seen in some of the files of the prefab (e.g. prefab/slashCommand.js
) or make use of d.ts
files (e.g. src/types/profile.d.ts
). However, not everyone might know how to use either of those but making use of this is very helpful and makes working with the Manager
class a lot more pleasant. When you choose this, it will prompt you to specify which schema (actually the model file) you would like to generate the type for.\
Disclaimer: The resulting type might not be 100% accurate or might be missing some elements, if you find any missing/wrong type declarations, feel free to open a new issue
or join the Discord server!
Why use this?
The package offers a feature-rich template to make prototyping bots easier and faster! It offers a command handler (including slash commands) and event handler. In the future, there will be more options to chose from when creating/updating your project.
Available Features
- Per server settings (prefix, disabling/enabling certain commands, disabling/enabling all commands in some channels, setting custom permission requirements for commands, customimizable cooldowns based on roles, adding custom aliases for certain commands)
- Quality of life utility functions (pagination, ...)
What's next?
The whole purpose of this package is to have a quick and easy way to setup a new project to prototype bots (or have an actual bot for your own server). I would like to keep it all optional and modular, so you can easily swap out certain parts or completely opting out of those. There will be a lot more quality of life features added to allow all kinds of bot behavior and give you the best experience possible while using the package and it's CLI.\ I plan to add support for more databases (SQLite, Firebase, ...), more modules and built-in commands (auto-mod, mod-logs, moderation, reaction roles, ...) but always keeping it easy-to-use.
Disclaimer: This package might not be the best for everyone. The structure was purposefully designed to allow the user to add their own ideas, but keeping it easy to update (main flaw of my old bot-prefab is the fact that it was very tedious to update) and thus it comes with a few unneccesary things. It is intended to be a template for you to build on top and to prototype and play with new ideas or even add modules for other people to use, ...