This project is a template for creating a Discord Interaction Endpoint App using TypeScript, Express, and the Discord API. It provides a basic structure for handling Discord interactions, including example commands.
- [
src/
]- [
commands/
] Contains example commands with this layout- [
...
] However nesting your project requires, prefered to be justCommandName
mod.ts
Contains the Command Data
- [
- [
utils/
]index.ts
: Main entry point, exports various utilities and initializes environment variables.constants.ts
: Contains constants.rest.ts
: Defines a class for making REST API requests to Discord.typings.ts
: Contains TypeScript types and interfaces.
index.ts
: Main server file, sets up Express and handles incoming interactions.register.ts
: Script to register application commands with Discord.
- [
.env
File user creates to contain secrets
- Node.js
- npm or pnpm
-
Clone the repository:
git clone https://github.com/Noro95/discord-interactions-template.git cd discord-interactions-template
-
Install dependencies:
npm install
-
Create a
.env
file and fill in the required values according toexample.env
To build the project, run:
npm run build
To register the commands with Discord, run:
npm run register
To start the server, run:
npm start
This will start the server on the port specified in the .env
file.
-
Ping Command :
- Name:
ping
- Description: Responds with "Pong!"
- Name:
-
Echo Command :
- Name:
echo
- Description: Echoes a message.
- Options:
message
.
- Name:
Feel free to open issues or submit pull requests if you find any bugs or have suggestions for improvements.
This project is licensed under the MIT License.
Andrew [email protected]
- discord-interactions-js - Some code at src/index.ts#L88 was adopted to this repository.
This README provides an overview of the project, how to set it up, and how to use it. For more detailed information, refer to the source code and comments within the files.