Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	pnpm-lock.yaml
  • Loading branch information
Jaku-BB committed Sep 10, 2023
2 parents 8b135bc + 78754bb commit ac6c668
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 165 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ updates:
directory: '/'
schedule:
interval: 'daily'
time: '22:00'
27 changes: 27 additions & 0 deletions .github/workflows/template-initialization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Template initialization

on:
create:

permissions:
contents: write

jobs:
template-initialization:
if: ${{ !github.event.repository.is_template }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Remove this script
run: |
rm .github/workflows/template-initialization.yml
- name: Overwrite initial commit
run: |
git config user.email ${{ github.actor }}@users.noreply.github.com
git config user.name ${{ github.actor }}
git add .
git commit --message "chore: initial commit" --amend
git push origin HEAD --force
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# d.js-template

![Build](https://img.shields.io/github/actions/workflow/status/Jaku-BB/d.js-template/test.yml)

This repository contains a template for building Discord bots in [TypeScript](https://www.typescriptlang.org/) using the [discord.js](https://discord.js.org/) library.
It allows you to quickly start your own project. Note that this template is mostly adapted to my projects, but feel free to contribute.

## Features

- interaction handler (application commands, message components and modals) with usage examples
- event handler
- built-in support for interaction cooldown
- environment validation
- separate application commands registration script
- [Docker](https://www.docker.com/) with [Docker Compose](https://docs.docker.com/compose/)

## Requirements

- [Node.js](https://nodejs.org/) >= v20.5.0
- [pnpm](https://pnpm.io/)
- access to a [PostgreSQL](https://www.postgresql.org/) database

## Installation

After creating a new repository using this template, download it locally.
Then, create the `.env` file and fill it according to the `.env.example` file.

If you want to use Docker for your database, feel free to use the `compose.yaml` file.
Just remember to expose port **5432** locally.

To start the bot in development mode, run:

```shell
pnpm install

pnpm dlx prisma migrate dev
pnpm dlx prisma generate

pnpm run watch
```

## Usage

The `src` directory already contains everything you need to start your project.
There are also some examples to help you along the way.

### Your own handler

If you want to add your own handler:

- create a new file in the `handlers` directory
- import the handler class you want to use from `structures.ts`
- instantiate it and export it as the default
- if your handler is an application command handler, remember to register it with `pnpm run register-application-commands`

Simple as that!

> **Note**
> Keep in mind that any interaction key, whether it's an application command name or a `customId` property, must be unique throughout your bot.
## Support

Be sure to have a look at the [discord.js guide](https://discordjs.guide/) if you need help with the library itself.

If you need support, you can reach me on Discord - **jaku.bb** - or [create a new issue](https://github.com/Jaku-BB/d.js-template/issues) here.

## License

[MIT](https://github.com/Jaku-BB/d.js-template/blob/main/LICENSE.md)
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
"discord-api-types": "^0.37.56",
"discord.js": "^14.12.1",
"inquirer": "^9.2.10",
"pino": "^8.15.0",
"pino": "^8.15.1",
"zod": "^3.22.1"
},
"devDependencies": {
"@types/inquirer": "^9.0.3",
"@types/node": "20.5.9",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"@types/node": "20.6.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"concurrently": "^8.2.1",
"dotenv": "^16.3.1",
"eslint": "^8.48.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-perfectionist": "^2.0.1",
"eslint-plugin-prettier": "^5.0.0",
Expand Down
Loading

0 comments on commit ac6c668

Please sign in to comment.