Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ulughann/essence
Pure, Type-Safe and Minimal template for Discord.js v14 and Slash Commands
https://github.com/ulughann/essence
altyapi altyapi-bot discord discord-bot discord-js
Last synced: 2 months ago
JSON representation
Pure, Type-Safe and Minimal template for Discord.js v14 and Slash Commands
- Host: GitHub
- URL: https://github.com/ulughann/essence
- Owner: ulughann
- Created: 2023-12-31T10:23:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-05T15:26:10.000Z (about 1 year ago)
- Last Synced: 2024-09-11T22:38:24.237Z (4 months ago)
- Topics: altyapi, altyapi-bot, discord, discord-bot, discord-js
- Language: TypeScript
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Essence
Pure, Type-Safe and Minimal template for Discord Bots using [Discord.js v14](https://discord.js.org/)
Get Started
After cloning the repository with `git clone`, add your bot token to the `config` file
config:
```
token = XXXXXXXXXXXXXX_XXXXXXX_XXXXXXXXXXXXX
```Then, install the dependencies and run the bot with `npm run dev`
```bash
npm install
npm run dev
```Project Structure
```
Essence
├── src
│ ├── commands
│ │ ├── command.ts
│ │ └── subdirectory/
│ │ └── command.ts
│ ├── events
│ │ ├── event.ts
| |
│ └── utils
│ | ├── ...
│ |
│ └── index.ts
│
├── config
├── logs.yml
├── .gitignore
├── package.json
├── tsconfig.json
└── nodemon.json
```## Commands
Commands are positioned in the `commands/` directory (of course subdirectories to `commands/` are allowed, eg. `commands/moderation/ban.ts`), and are loaded automatically by the bot. Commands are structured as follows:```ts
import { SlashCommandBuilder } from "@discordjs/builders";export default {
data: new SlashCommandBuilder()
.setName("ping") // check out the command builder docs for more info
.setDescription("Pong!"),
run: async (client, interaction) => {
// comamnd body
}
};
```## Events
Events are positioned in the `events/` directory, and are loaded automatically by the bot. Events are structured as follows:```ts
import { Client } from "discord.js";export default {
name: 'ready',
once: true, // true if event should only be executed once
execute(client: Client) {
// event body
},
};
```## Utils
Utils are positioned in the `utils/` directory, and are extra code that helps you with your bot. Utils have no structure, and can be anything you want them to be. By default there is a `console.ts` util for structured logging, `log.ts` util for logging to a file and the `configParser.js` to read the [NOML](https://github.com/onrirr/noml) config file.### Structured Logging
The `console.ts` util is used for structured logging. It is used as follows:```ts
import { Print, Warn, Inform, Error } from "./utils/console";Print("Hello World!");
Warn("Hello World!");
Inform("Hello World!");
Error("Hello World!");
```### Logging to a file
The `log.ts` util is used for logging to a file. It is used as follows:Example;
```ts
import { Error } from "./utils/console";
import { $l } from "./utils/log";catch (error) {
Error("Hello World!", $l(error));
}
```(this adds the error to the log file in `logs.yml`, and logs it to the console)
## Utils/intents.ts
This file is used to define the intents, shards and partials for your bot. By default, the intents are set to `GUILDS` and `GUILD_MESSAGES`. You can read more about intents [here](https://discordjs.guide/popular-topics/intents.html).Requirements
- [Node.js](https://nodejs.org/en/) v16 or higher
![Stats](https://repobeats.axiom.co/api/embed/d86852e3898713e1283f4916a29d73a701c9266c.svg "Repobeats analytics image")