Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/canta-slaus/bot-prefab-package
A small template to help building Discord bots using Discord.js and Node.js
https://github.com/canta-slaus/bot-prefab-package
cli discord discord-bot discord-js node-js typescript
Last synced: 16 days ago
JSON representation
A small template to help building Discord bots using Discord.js and Node.js
- Host: GitHub
- URL: https://github.com/canta-slaus/bot-prefab-package
- Owner: canta-slaus
- Created: 2021-08-04T19:54:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-23T14:07:09.000Z (almost 3 years ago)
- Last Synced: 2024-12-10T10:28:19.361Z (about 1 month ago)
- Topics: cli, discord, discord-bot, discord-js, node-js, typescript
- Language: JavaScript
- Homepage:
- Size: 213 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bot-Prefab
Join the Discord [server](https://discord.gg/eN8PfTRgh6) if you have any questions!## What is this?
This package is based on a project of mine [`bot-prefab`](https://github.com/canta-slaus/bot-prefab) and is meant to offer the same functionality as the prefab but **easier to use**.## Installing and usage
Using [`npm`](https://npmjs.com):
```
$ npm i bot-prefab-package -g
```
or using [`yarn`](https://yarnpkg.com/):
```
$ 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`](https://jsdoc.app/) 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`](https://github.com/canta-slaus/bot-prefab-package/issues) 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, ..._