Skip to content

Commit 7676e89

Browse files
Initial interactions setup (#2)
* chore: add log to redis startup * chore: pin node version * feat: add inital interactions framwork and info slash commands * chore(deps): bump discord api version to v10 (not-breaking) * fix: move auth routes out of versioned routed * feat: add field encryption * feat: Add send message Add commands.json for application commands Add encryption to prisma Update prisma and client Remove LoggingChannel table and move that to Guild Add Message and MessageHistory table Migrate database with above Add testing Revert change to v10 as dependencies haven't updated yet Add new permissions to permissions constant Add base limits for messages and permissions Add guild only handling for interactions Add modal handling - by the start of the custom_id Add /send handling Add sending message logic Add modal builders Add custom missing permission errors Add custom permissions system (the start of one) Add tests for the custom permission system with tap Add todo file * chore: remove analytics routes * feat: add metrics and improve error handling Add internal interaction to track interaction state * feat: dockerize and add build action * feat: add customizable port * chore: add migration script commands * fix: add host option * chore(debugging): add temp permission creation when missing permissions * chore: add code block to some error messages * chore(deps): update redis-discord-cache * fix: tags are not required on modal submit * fix: check for user permissions, not bot permissions for user * feat: add message actions Add context menu commands to command data Add context menu commands handler Add fetch context menu Add formdata handling and move to modules to support that Change response for interactions to allow for formdata responses Add actions context menu Add message component handling Add delete message action, and follow up cancel and confirm actions Add edit message action, and follow up modal Add report action (follow up modal is a todo) Consolidate message history table into message table Fix redirecting after discord oauth Improve error handling for discordOauth Add errors to error enum Add components to custom error to support login buttons Add parseTags utility Add get channel utility Add checking database message existence utility Add view messages permission Move checking discord permissions into a function Check permissions on final send incase of a permissions change * feat: add reporting Add report tables and migrations Remove email from scopes Add related error to enum Add modal handling * chore!: Update user path and add test to check if input is a number * chore: move message logic to lib dir * feat: add permission management and restructure permissions logic * chore: remove resolved todo comment * feat: add eslint and prettier and update to match * feat(ci): add lint action * chore(ci): rename action job * chore(ci): add check script * fix(ci): incorrect script name for linting * feat: change info to a tag based system with fuzzy matching Update dependencies * feat: add logging * chore: update todo file * feat: add migration process * chore: remove tags feature * fix: channel create failed on logger creation * chore: disable reporting * feat: add deferred interaction handling * fix: report message should be ephemeral * fix: some formatting issues and typos in logging * chore(ci): add manual trigger to deploy action * chore: update limits * fix: allow logging commands for management roles * feat: add tip feature to embed Move some commands still on text based commands to embeds * chore: format and lint issue * chore: format
1 parent ce30f3b commit 7676e89

File tree

84 files changed

+17452
-2119
lines changed

Some content is hidden

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

84 files changed

+17452
-2119
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.env
3+
dist
4+
.nyc_output
5+
logs

.env.example

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
PORT=3000
2+
HOST="localhost"
3+
14

25
DISCORD_TOKEN=""
36
DISCORD_CLIENT_ID=""
@@ -11,6 +14,14 @@ BASE_API_URL="http://localhost:3000"
1114

1215
DATABASE_URL="postgres://bot_access:12345@localhost/bot_test"
1316

17+
PRISMA_FIELD_ENCRYPTION_KEY="ENCRYPTION_KEY"
18+
1419

1520
UUID_NAMESPACE="A_UUID"
16-
COOKIE_SECRET="SECURE_SECRET"
21+
COOKIE_SECRET="SECURE_SECRET"
22+
23+
METRICS_AUTH_TOKEN="A_SECRET_TOKEN
24+
25+
AVATAR_URL="https://cdn.discordapp.com/avatars/760778370119761921/b09d7fd2ec0f27e29d000f4fd62d8ea5.webp"
26+
27+
NO_MIGRATION_AFTER=1649923675917

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
.nyc_output
3+
logs

.eslintrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"parserOptions": {
6+
"tsconfigRootDir": ".",
7+
"project": ["./tsconfig.json"]
8+
},
9+
10+
"extends": [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
13+
"prettier",
14+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
15+
]
16+
}

.github/workflows/codeql-analysis.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ main ]
16+
branches: [main]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ main ]
19+
branches: [main]
2020
schedule:
21-
- cron: '19 12 * * 2'
21+
- cron: "19 12 * * 2"
2222

2323
jobs:
2424
analyze:
@@ -32,39 +32,39 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
language: [ 'typescript' ]
35+
language: ["typescript"]
3636
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3737
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3838

3939
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v2
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
4242

43-
# Initializes the CodeQL tools for scanning.
44-
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v1
46-
with:
47-
languages: ${{ matrix.language }}
48-
# If you wish to specify custom queries, you can do so here or in a config file.
49-
# By default, queries listed here will override any specified in a config file.
50-
# Prefix the list here with "+" to use these queries and those in the config file.
51-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v1
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5252

53-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54-
# If this step fails, then you should remove it and run the build manually (see below)
55-
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v1
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v1
5757

58-
# ℹ️ Command-line programs to run using the OS shell.
59-
# 📚 https://git.io/JvXDl
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
6060

61-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62-
# and modify them (or add more) to build your code if your project
63-
# uses a compiled language
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
6464

65-
#- run: |
66-
# make bootstrap
67-
# make release
65+
#- run: |
66+
# make bootstrap
67+
# make release
6868

69-
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v1
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v1

.github/workflows/deploy-image.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
pull_request:
1010
branches:
1111
- "main"
12-
1312

1413
workflow_dispatch:
1514

.github/workflows/lint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Lint
2+
on: push
3+
jobs:
4+
lint:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- name: Install modules
9+
run: npm ci
10+
- name: Run ESLint
11+
run: npm run lint
12+
- name: Run Prettier
13+
run: npm run format:check

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
.env
3-
dist
3+
dist
4+
.nyc_output
5+
logs

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v17.5

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
.nyc_output
3+
logs

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:17-buster
2+
# Create app directory
3+
WORKDIR /usr/src/app
4+
5+
# Install app dependencies
6+
COPY package*.json ./
7+
8+
RUN npm ci
9+
10+
COPY . .
11+
12+
RUN npm run generate
13+
RUN npm run build
14+
15+
CMD [ "npm", "run", "start" ]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Message Manager Backend
22

33
Backend service for [message.anothercat.me](https://message.anothercat.me)
4+
5+
PRISMA_FIELD_ENCRYPTION_KEY: https://github.com/47ng/prisma-field-encryption#2-setup-your-encryption-key

0 commit comments

Comments
 (0)