8 Commits
v1.1.2 ... main

7 changed files with 82 additions and 26 deletions

View File

@@ -1,7 +1,11 @@
FROM node:22 FROM node:latest
COPY . . WORKDIR /app
RUN npm i COPY . /app
CMD [ "npm", "run", "start" ] RUN npm clean-install && \
npm run build && \
npm run register
CMD [ "npm", "run", "start" ]

View File

@@ -69,5 +69,41 @@ For production:
npm run start 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. **Note**: This template is based on community best practices and has been customized for Discord bot development.

37
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"version": "1.0.0", "version": "1.0.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"discord.js": "^14.24.2", "discord.js": "^14.25.0",
"dotenv": "^17.2.2" "dotenv": "^17.2.2"
}, },
"devDependencies": { "devDependencies": {
@@ -47,12 +47,12 @@
} }
}, },
"node_modules/@discordjs/formatters": { "node_modules/@discordjs/formatters": {
"version": "0.6.1", "version": "0.6.2",
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.1.tgz", "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.2.tgz",
"integrity": "sha512-5cnX+tASiPCqCWtFcFslxBVUaCetB0thvM/JyavhbXInP1HJIEU+Qv/zMrnuwSsX3yWH2lVXNJZeDK3EiP4HHg==", "integrity": "sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"discord-api-types": "^0.38.1" "discord-api-types": "^0.38.33"
}, },
"engines": { "engines": {
"node": ">=16.11.0" "node": ">=16.11.0"
@@ -97,10 +97,13 @@
} }
}, },
"node_modules/@discordjs/util": { "node_modules/@discordjs/util": {
"version": "1.1.1", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.1.tgz", "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.2.0.tgz",
"integrity": "sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==", "integrity": "sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": {
"discord-api-types": "^0.38.33"
},
"engines": { "engines": {
"node": ">=18" "node": ">=18"
}, },
@@ -205,28 +208,28 @@
} }
}, },
"node_modules/discord-api-types": { "node_modules/discord-api-types": {
"version": "0.38.31", "version": "0.38.34",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.31.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.34.tgz",
"integrity": "sha512-kC94ANsk8ackj8ENTuO8joTNEL0KtymVhHy9dyEC/s4QAZ7GCx40dYEzQaadyo8w+oP0X8QydE/nzAWRylTGtQ==", "integrity": "sha512-muq7xKGznj5MSFCzuIm/2TO7DpttuomUTemVM82fRqgnMl70YRzEyY24jlbiV6R9tzOTq6A6UnZ0bsfZeKD38Q==",
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
"scripts/actions/documentation" "scripts/actions/documentation"
] ]
}, },
"node_modules/discord.js": { "node_modules/discord.js": {
"version": "14.24.2", "version": "14.25.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.24.2.tgz", "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.25.0.tgz",
"integrity": "sha512-VMEDbmguRdX/EeMaTsf9Mb0IQA90WdYF2cn4QDfslQFXgQ6LFtmlPn0FSotnS0kcFbFp+JBSIxtnF+bnAHG/hQ==", "integrity": "sha512-9rnJWTAkfauKTieYJ3oI4oncrSzpbJPWN1/XU+2H6wsHQPtqbOrXvgM0nFhSVnIbTo7nfUF7fzcYRevvRGjpzA==",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@discordjs/builders": "^1.13.0", "@discordjs/builders": "^1.13.0",
"@discordjs/collection": "1.5.3", "@discordjs/collection": "1.5.3",
"@discordjs/formatters": "^0.6.1", "@discordjs/formatters": "^0.6.2",
"@discordjs/rest": "^2.6.0", "@discordjs/rest": "^2.6.0",
"@discordjs/util": "^1.1.1", "@discordjs/util": "^1.2.0",
"@discordjs/ws": "^1.2.3", "@discordjs/ws": "^1.2.3",
"@sapphire/snowflake": "3.5.3", "@sapphire/snowflake": "3.5.3",
"discord-api-types": "^0.38.31", "discord-api-types": "^0.38.33",
"fast-deep-equal": "3.1.3", "fast-deep-equal": "3.1.3",
"lodash.snakecase": "4.1.1", "lodash.snakecase": "4.1.1",
"magic-bytes.js": "^1.10.0", "magic-bytes.js": "^1.10.0",

View File

@@ -27,7 +27,7 @@
"typescript": "^5.9.2" "typescript": "^5.9.2"
}, },
"dependencies": { "dependencies": {
"discord.js": "^14.24.2", "discord.js": "^14.25.0",
"dotenv": "^17.2.2" "dotenv": "^17.2.2"
} }
} }

View File

@@ -50,6 +50,19 @@ client.on(Events.InteractionCreate, async interaction => {
return; 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; if (!interaction.isChatInputCommand()) return;
const command = commands.get(interaction.commandName); const command = commands.get(interaction.commandName);

4
src/type.d.ts vendored
View File

@@ -1,3 +1,3 @@
import { ButtonInteraction, ChatInputCommandInteraction, SlashCommandOptionsOnlyBuilder } from "discord.js"; import { ButtonInteraction, ChatInputCommandInteraction, SlashCommandOptionsOnlyBuilder, ModalSubmitInteraction } from "discord.js";
export type CommandDefinition = { data: SlashCommandBuilder | SlashCommandOptionsOnlyBuilder, 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 }[]};

View File

@@ -2,9 +2,9 @@
"compilerOptions": { "compilerOptions": {
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src", "rootDir": "./src",
"target": "ES2020", "target": "es2024",
"module": "CommonJS", "module": "CommonJS",
"lib": ["ES2020"], "lib": ["ES2024"],
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,