Skip to content

Commit efe18fd

Browse files
authored
Feature: Slash Commands and Context Menu Commands (#109)
* refactor(messageCreate): move commands handling into specific file * feat(commands): move all commands to slash commands Parallel to a huge refactor for the reply to interactions, all commands are now processed as slash commands (except for the pin command which became a message context menu command now). This means we do not need messageCreate event anymore (nor do we need the intents related to content). Changes on the config to remove unnecessary emotes as well. * fix(db): migrations always run into error when run on existing db * refactor(events): apply same strategy of loading commands to events Adapt helper to log information as well. Fix dockerfile warning with stage names * fix: apply sonarcloud feedbacks, new linter * fix(datadrop): avoid nested template literal * fix: no need for eslint mentions anymore * refactor(owner commands): destructuring config to get ownerIds directly * fix(CommandHandler): first check for deferred interaction before checking if it's replied already or not * fix(Event): type-safety for events * style: fix linting issues * fix(datadrop): runtime issue due to complex infered types * refactor(deploy-commands): protocol file:/// also works on linux machines * fix(pin): remove commented description setter There is no description on Context Menu Commands * refactor(deploy-commands): divide script in different paths related to args * refactor(deploy-commands): separate behaviour in fully async functions, rework flow to shutdown client after script ran entirely * style: lint scripts and src files * fix(docker): properly write logs to a file in the volume * style(Dockerfile): better lisibility and less layers
1 parent 1b0315f commit efe18fd

47 files changed

Lines changed: 1987 additions & 1718 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ typings/
4242
# Optional npm cache directory
4343
.npm
4444

45-
# eslint
46-
.eslintcache
47-
.eslintrc.json
48-
4945
# Optional REPL history
5046
.node_repl_history
5147

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"recommendations": [
33
"ms-azuretools.vscode-docker",
4-
"dbaeumer.vscode-eslint",
54
"gamunu.vscode-yarn",
5+
"biomejs.biome",
66
]
77
}

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"files.exclude": {
99
"node_modules": true
1010
},
11-
"editor.codeActionsOnSave": {
12-
"source.fixAll.eslint": "explicit"
13-
},
1411
"npm.packageManager": "yarn",
1512
"files.eol": "\n",
1613
"editor.insertSpaces": true,

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
FROM node:lts-alpine AS BUILD
1+
FROM node:lts-alpine AS build
22

33
WORKDIR /app
44

55
RUN apk --no-cache add zip
66

77
COPY . .
8-
RUN yarn install --frozen-lockfile
9-
RUN yarn env-gen
10-
RUN yarn build
11-
RUN yarn install --production
12-
RUN zip -r app.zip ./node_modules ./build ./yarn.lock ./.env
8+
RUN yarn install --frozen-lockfile \
9+
&& yarn env-gen \
10+
&& yarn build \
11+
&& yarn install --production \
12+
&& zip -r app.zip ./node_modules ./build ./yarn.lock ./.env ./entrypoint.sh
1313

1414
# ------------------------------------------------------------
15-
FROM node:lts-alpine AS APP
15+
FROM node:lts-alpine AS app
1616

1717
WORKDIR /app
1818

1919
RUN apk --no-cache add unzip
2020

21-
COPY --from=BUILD /app/app.zip .
22-
RUN unzip app.zip && rm app.zip && mv ./build/* . && rm -rf ./build
21+
COPY --from=build /app/app.zip .
22+
RUN unzip app.zip \
23+
&& rm app.zip \
24+
&& mv ./build/* . \
25+
&& rm -rf ./build \
26+
&& chmod +x ./entrypoint.sh
2327

24-
CMD ["sh", "-c", "sleep 2 && node ./index.js"]
28+
ENTRYPOINT ["./entrypoint.sh"]

biome.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"vcs": {
7+
"enabled": true,
8+
"clientKind": "git",
9+
"useIgnoreFile": true,
10+
"defaultBranch": "master"
11+
},
12+
"linter": {
13+
"enabled": true,
14+
"rules": {
15+
"recommended": true
16+
}
17+
},
18+
"formatter": {
19+
"enabled": true,
20+
"indentStyle": "space",
21+
"indentWidth": 4,
22+
"lineEnding": "lf"
23+
}
24+
}

config.development.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
],
66
"minLevel": "debug",
77
"includeTimestamp": true,
8-
"prefix": "dab!",
98
"botName": "Yoda Beta",
9+
"botId": "703031563062870107",
1010
"communitymanagerRoleid": "1028257512383848478",
1111
"adminRoleid": "1028257512358674472",
1212
"delegatesRoleid": "1028257512358674468",
@@ -143,8 +143,6 @@
143143
"roleid": "1028257512312557591",
144144
"emote": "📢"
145145
},
146-
"ok_hand": "👌",
147-
"warning": "⚠️",
148146
"communicationServiceOptions": {
149147
"mailData": {
150148
"from": "mdpdevti@henallux.be",

config.production.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
],
66
"minLevel": "info",
77
"includeTimestamp": true,
8-
"prefix": "da!",
98
"botName": "Yoda",
9+
"botId": "454768256364969985",
1010
"communitymanagerRoleid": "288659580064366592",
1111
"adminRoleid": "360850813914185738",
1212
"delegatesRoleid": "288659613732306944",
@@ -151,8 +151,6 @@
151151
"roleid": "364008970966269952",
152152
"emote": "📢"
153153
},
154-
"ok_hand": "👌",
155-
"warning": "⚠️",
156154
"communicationServiceOptions": {
157155
"mailData": {
158156
"from": "mdpdevti@henallux.be",

docker-compose.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ x-restart-policy:
99
&restart-policy
1010
restart: always
1111

12-
version: '3.8'
1312
services:
1413
database:
1514
<<: [*env-file, *network, *restart-policy]
@@ -33,7 +32,7 @@ services:
3332
context: .
3433
dockerfile: ./Dockerfile
3534
volumes:
36-
- bot_logs:/app/logs
35+
- bot_logs:/var/log/datadrop/
3736
depends_on:
3837
- database
3938

entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
echo "Waiting for PostgreSQL to be ready..."
4+
until nc -z -v -w30 database 5432
5+
do
6+
echo "Waiting for PostgreSQL..."
7+
sleep 1
8+
done
9+
10+
echo "PostgreSQL is up and running!"
11+
12+
node ./index.js | tee -a /var/log/datadrop/console.log

0 commit comments

Comments
 (0)