Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dc68dfae9 | ||
|
|
c1168b7cd4 | ||
| b5cf762730 | |||
| ce4996ae9d | |||
| 0ee1dc7e53 | |||
| fd4530db48 | |||
|
|
f13eea1a22 | ||
| 2d52089d1d | |||
| b79be2df41 | |||
| 12cd8cae7a |
10
Dockerfile
10
Dockerfile
@@ -1,7 +1,11 @@
|
||||
FROM node:22
|
||||
FROM node:latest
|
||||
|
||||
COPY . .
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm i
|
||||
COPY . /app
|
||||
|
||||
RUN npm clean-install && \
|
||||
npm run build && \
|
||||
npm run register
|
||||
|
||||
CMD [ "npm", "run", "start" ]
|
||||
36
README.md
36
README.md
@@ -69,5 +69,41 @@ For production:
|
||||
npm run start
|
||||
```
|
||||
|
||||
## Docker Production Deployment
|
||||
|
||||
### Build and Deploy
|
||||
Build the Docker image and run the container:
|
||||
```bash
|
||||
docker buildx build -t discord-bot . && docker run -d --restart unless-stopped --name discord-bot discord-bot
|
||||
```
|
||||
|
||||
### Container Management
|
||||
|
||||
**Stop the container:**
|
||||
```bash
|
||||
docker stop discord-bot
|
||||
```
|
||||
|
||||
**Start the container (after stop):**
|
||||
```bash
|
||||
docker start discord-bot
|
||||
```
|
||||
|
||||
**View container logs:**
|
||||
```bash
|
||||
docker logs -f discord-bot
|
||||
```
|
||||
|
||||
**Remove the container:**
|
||||
```bash
|
||||
docker rm discord-bot
|
||||
```
|
||||
|
||||
### Complete Rebuild
|
||||
Stop, remove, rebuild and redeploy:
|
||||
```bash
|
||||
docker stop discord-bot && docker rm discord-bot && docker buildx build -t discord-bot . && docker run -d --restart unless-stopped --name discord-bot discord-bot
|
||||
```
|
||||
|
||||
---
|
||||
**Note**: This template is based on community best practices and has been customized for Discord bot development.
|
||||
43
package-lock.json
generated
43
package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"discord.js": "^14.24.1",
|
||||
"discord.js": "^14.25.0",
|
||||
"dotenv": "^17.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -47,12 +47,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/formatters": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.1.tgz",
|
||||
"integrity": "sha512-5cnX+tASiPCqCWtFcFslxBVUaCetB0thvM/JyavhbXInP1HJIEU+Qv/zMrnuwSsX3yWH2lVXNJZeDK3EiP4HHg==",
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.2.tgz",
|
||||
"integrity": "sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"discord-api-types": "^0.38.1"
|
||||
"discord-api-types": "^0.38.33"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.11.0"
|
||||
@@ -97,10 +97,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/util": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.1.tgz",
|
||||
"integrity": "sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==",
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.2.0.tgz",
|
||||
"integrity": "sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"discord-api-types": "^0.38.33"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
@@ -177,9 +180,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz",
|
||||
"integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==",
|
||||
"version": "24.9.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.2.tgz",
|
||||
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~7.16.0"
|
||||
@@ -205,28 +208,28 @@
|
||||
}
|
||||
},
|
||||
"node_modules/discord-api-types": {
|
||||
"version": "0.38.31",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.31.tgz",
|
||||
"integrity": "sha512-kC94ANsk8ackj8ENTuO8joTNEL0KtymVhHy9dyEC/s4QAZ7GCx40dYEzQaadyo8w+oP0X8QydE/nzAWRylTGtQ==",
|
||||
"version": "0.38.34",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.34.tgz",
|
||||
"integrity": "sha512-muq7xKGznj5MSFCzuIm/2TO7DpttuomUTemVM82fRqgnMl70YRzEyY24jlbiV6R9tzOTq6A6UnZ0bsfZeKD38Q==",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"scripts/actions/documentation"
|
||||
]
|
||||
},
|
||||
"node_modules/discord.js": {
|
||||
"version": "14.24.1",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.24.1.tgz",
|
||||
"integrity": "sha512-LzL+MTGxB9mBwD8FjvkMwcIL4UtgG04e713U3+euqPCvOphhoVEoPpUNTvBPw4iJOas2uiuuh3JcveYSxIn8Tg==",
|
||||
"version": "14.25.0",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.25.0.tgz",
|
||||
"integrity": "sha512-9rnJWTAkfauKTieYJ3oI4oncrSzpbJPWN1/XU+2H6wsHQPtqbOrXvgM0nFhSVnIbTo7nfUF7fzcYRevvRGjpzA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^1.13.0",
|
||||
"@discordjs/collection": "1.5.3",
|
||||
"@discordjs/formatters": "^0.6.1",
|
||||
"@discordjs/formatters": "^0.6.2",
|
||||
"@discordjs/rest": "^2.6.0",
|
||||
"@discordjs/util": "^1.1.1",
|
||||
"@discordjs/util": "^1.2.0",
|
||||
"@discordjs/ws": "^1.2.3",
|
||||
"@sapphire/snowflake": "3.5.3",
|
||||
"discord-api-types": "^0.38.31",
|
||||
"discord-api-types": "^0.38.33",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"lodash.snakecase": "4.1.1",
|
||||
"magic-bytes.js": "^1.10.0",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"discord.js": "^14.24.1",
|
||||
"discord.js": "^14.25.0",
|
||||
"dotenv": "^17.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
13
src/index.ts
13
src/index.ts
@@ -50,6 +50,19 @@ client.on(Events.InteractionCreate, async interaction => {
|
||||
return;
|
||||
}
|
||||
|
||||
if(interaction.isModalSubmit()) {
|
||||
const id = interaction.customId;
|
||||
commands.forEach((value) => {
|
||||
if(value.modals) {
|
||||
const button = value.modals.filter((b) => b.id == id);
|
||||
if(button.length == 1) {
|
||||
button[0]?.handle(interaction);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const command = commands.get(interaction.commandName);
|
||||
|
||||
4
src/type.d.ts
vendored
4
src/type.d.ts
vendored
@@ -1,3 +1,3 @@
|
||||
import { ButtonInteraction, ChatInputCommandInteraction } from "discord.js";
|
||||
import { ButtonInteraction, ChatInputCommandInteraction, SlashCommandOptionsOnlyBuilder, ModalSubmitInteraction } from "discord.js";
|
||||
|
||||
export type CommandDefinition = { data: SlashCommandBuilder, execute: (interaction: ChatInputCommandInteraction) => void, buttons?: { id: string, handle: (interaction: ButtonInteraction) => void}[]};
|
||||
export type CommandDefinition = { data: SlashCommandBuilder | SlashCommandOptionsOnlyBuilder, execute: (interaction: ChatInputCommandInteraction) => void, buttons?: { id: string, handle: (interaction: ButtonInteraction) => void}[], modals?: { id: string, handle: (interaction: ModalSubmitInteraction) => void }[]};
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"target": "ES2020",
|
||||
"target": "es2024",
|
||||
"module": "CommonJS",
|
||||
"lib": ["ES2020"],
|
||||
"lib": ["ES2024"],
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
|
||||
Reference in New Issue
Block a user