Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the bot in TypeScript (v2) #72

Merged
merged 103 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
f858966
fresh start
RafDevX Jun 23, 2021
49b57b8
move from python to node with yarn
RafDevX Jun 29, 2021
0d8855e
initial setup
RafDevX Jun 30, 2021
bcee4e2
remove docker-compose.yml from version control
RafDevX Jun 30, 2021
2efcc8d
upgrade do discord.js v13
RafDevX Aug 8, 2021
8241136
upgrade node to version compatible with discord.js@v13
RafDevX Aug 8, 2021
5876149
basic skeleton
RafDevX Aug 8, 2021
7ff45bf
ignore unused vars starting with _
RafDevX Aug 14, 2021
eb91842
useless maintenance mode
RafDevX Aug 14, 2021
852346c
add codeowners
RafDevX Aug 14, 2021
6b360dd
Add attendance poll module (#50)
diogotcorreia Aug 14, 2021
bb11ab2
remove codeowners
RafDevX Aug 14, 2021
e10d414
small tweak
RafDevX Aug 14, 2021
5caf267
install better-sqlite3
RafDevX Aug 14, 2021
2ea7e8a
start storage abstraction
RafDevX Aug 14, 2021
40d990e
use storage abstraction
RafDevX Aug 14, 2021
ff189d9
fix attendance
RafDevX Aug 14, 2021
de03c9c
install deps to build better-sqlite3
RafDevX Aug 14, 2021
b907315
fix storage bugs
RafDevX Aug 14, 2021
b4e6fa0
remove extraneous token checking
RafDevX Aug 14, 2021
b12c89b
implement prisma
RafDevX Aug 15, 2021
588cbd9
tweaks to allow prisma to generate client from within docker
RafDevX Aug 15, 2021
c0b2621
remove dependency on better-sqlite3
RafDevX Aug 15, 2021
c5c5a42
deploy prisma migrations from dockerfile
RafDevX Aug 15, 2021
0a8f0a5
update readme
RafDevX Aug 15, 2021
bda0bf6
run migrations before generating prisma client
RafDevX Aug 15, 2021
f31dfff
move prisma migrate and generate to dockerfile
RafDevX Aug 16, 2021
34c9a60
extract utils module
RafDevX Aug 16, 2021
e9961ec
re-organize startup chores
RafDevX Aug 16, 2021
5b3b884
add short description at the beginning of files
RafDevX Aug 16, 2021
6ea0dee
Role Selection (#52)
RafDevX Sep 6, 2021
e9fd812
Misc commands (#56)
RafDevX Sep 6, 2021
a7d4e66
Sudo Module (#57)
RafDevX Sep 6, 2021
6ab6fb5
Use native permissions for slash commands (#58)
RafDevX Sep 6, 2021
b3da17a
Gallery channels (#59)
RafDevX Sep 6, 2021
d680e1d
Infer command name (#60)
RafDevX Sep 6, 2021
8318e9f
TourIST config commands (#61)
RafDevX Sep 6, 2021
953b07e
Update README (#62)
RafDevX Sep 6, 2021
8eb7946
Voice threads (#63)
RafDevX Sep 6, 2021
80e5f7b
remove populate module
RafDevX Sep 6, 2021
0626c4c
fix dockerfile so migrations can run
RafDevX Sep 7, 2021
40261c2
fix \n replace on role selection
RafDevX Sep 7, 2021
6b75708
allow \n in tourist info
RafDevX Sep 7, 2021
5bbf1c6
Fix wrong interaction options key on role-selection tourist set-info
diogotcorreia Sep 7, 2021
ab107db
Make docker work (#65)
RafDevX Sep 7, 2021
9bdaa33
Control attendance polls with commands (#64)
RafDevX Sep 7, 2021
fd04d24
Fix docker image not building from scratch
diogotcorreia Sep 7, 2021
de11af1
Add docker image publish github action
diogotcorreia Sep 7, 2021
dee1366
Fix attendance response reply not being sent
diogotcorreia Sep 8, 2021
b9a8934
Bump version to v2.0.1
diogotcorreia Sep 8, 2021
de87eb4
Welcome module (#67)
RafDevX Sep 9, 2021
1b472ef
Bump version to v2.1.0
diogotcorreia Sep 9, 2021
6e4dfa9
Multiselect support (#68)
RafDevX Sep 16, 2021
60bb3c0
Important necessary commands (#69)
RafDevX Sep 16, 2021
b053411
Bump version to v2.2.0
diogotcorreia Sep 16, 2021
81a0118
Say logs (#70)
RafDevX Sep 18, 2021
993abbf
Dev Dockerfile (#73)
RafDevX Sep 18, 2021
3fa116b
Ignore shell.nix
luishfonseca Sep 18, 2021
79d2c0c
Merge branch 'v2' of github.com:ist-bot-team/ist-discord-bot into v2
luishfonseca Sep 18, 2021
cf8d9bc
Generalize to any kind of polls (#76)
luishfonseca Sep 22, 2021
d5931e6
Add leaderboard module (#71)
RafDevX Sep 22, 2021
a8de067
Bump version to v2.3.0
diogotcorreia Sep 22, 2021
a8ea2b6
Upgrade to Prisma V3 (#77)
RafDevX Sep 30, 2021
891bdad
Degree Features (#75)
RafDevX Oct 3, 2021
b2c4239
Add RSS feed announcements module (#80)
diogotcorreia Oct 3, 2021
78427e8
Add @luishfonseca to contributors list
diogotcorreia Oct 3, 2021
d651fd5
Bump version to v2.4.0
diogotcorreia Oct 3, 2021
a24c82f
Fix course role name not respecting displayAcronym
diogotcorreia Oct 3, 2021
dd04e3a
Bump version to v2.4.1
diogotcorreia Oct 3, 2021
bea8f67
Add which degrees need course command (#81)
RafDevX Oct 3, 2021
2f07e76
Bump version to v2.4.2
diogotcorreia Oct 3, 2021
d2230bc
Improve leaderboard (#82)
RafDevX Oct 10, 2021
66bfb36
Add just-ask command (#84)
d-card Oct 10, 2021
d586aa0
Simple command logs (#83)
RafDevX Oct 10, 2021
d9a5505
Bump version to v2.5.0
diogotcorreia Oct 10, 2021
5d67811
remove debug message
RafDevX Oct 10, 2021
6002e27
Bump ansi-regex from 5.0.0 to 5.0.1 (#85)
dependabot[bot] Oct 10, 2021
713a18a
Bump version to v2.5.1
diogotcorreia Oct 12, 2021
fefd8ed
Fix leaderboard cache (#86)
RafDevX Nov 9, 2021
5d70222
Bump version to v2.5.2
diogotcorreia Nov 9, 2021
3532187
Fix tourist role selection button throwing error
diogotcorreia Nov 26, 2021
2ba701c
Bump version to v2.5.3
diogotcorreia Nov 26, 2021
481fcf5
Handle errors while fetching RSS feed from Fénix
diogotcorreia Mar 10, 2022
c9f6fe8
Bump version to v2.5.4
diogotcorreia Mar 10, 2022
f0a7685
Fix typo on Don't Ask to Ask command description (#92)
RafDevX Apr 20, 2022
0656b35
Add `migrate-members-with-role` command (#95)
RafDevX Sep 13, 2022
bd4ebaf
Bump version to v2.5.5
RafDevX Sep 13, 2022
ae7f5ae
Migrate to Discord.js v14 (#96)
diogotcorreia Sep 15, 2022
a0ced12
Upgrade dependencies to latest patch version
diogotcorreia Sep 15, 2022
50651df
Bump version to v2.6.0
diogotcorreia Sep 15, 2022
acc8f57
Bump docker node version to 16.17.0
diogotcorreia Sep 15, 2022
4ce55d3
Bump version to v2.6.1
diogotcorreia Sep 15, 2022
dd039d1
Add error logs to all catch blocks
diogotcorreia Sep 19, 2022
0b5263a
Fix permission denied on public commands
diogotcorreia Sep 19, 2022
9a92e91
Add Don't Ask to Ask usage logs
diogotcorreia Sep 19, 2022
86cb24f
Remove voice chat threads support
diogotcorreia Sep 19, 2022
81c5994
Bump version to 2.7.0
diogotcorreia Sep 19, 2022
2d383fc
Make course insertion into database sequential
diogotcorreia Sep 19, 2022
4673204
Bump version to v2.7.1
diogotcorreia Sep 19, 2022
0597e84
Fix course RSS link not being imported (#98)
diogotcorreia Oct 3, 2022
af2c386
Allow refreshing courses without specifying a degree (#99)
diogotcorreia Oct 3, 2022
c88d746
Bump version to v2.7.2
diogotcorreia Oct 3, 2022
0f34e2b
Merge branch 'master' into v2
diogotcorreia Oct 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
data/
dist/
.husky/
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-unused-vars": [
"error",
{ "varsIgnorePattern": "^_" }
]
}
}
53 changes: 53 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Create and publish a Docker image

on:
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
.env
.venv
node_modules/
dist/
data/
docker-compose.yml

.vscode

shell.nix
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"useTabs": true
}
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:16.17.0-alpine3.16 as ts-compiler
ARG DATABASE_URL
ENV DATABASE_URL ${DATABASE_URL}
WORKDIR /app
COPY package.json .
COPY yarn.lock .
RUN yarn install --frozen-lockfile
COPY ./ ./
RUN yarn run prisma generate
RUN yarn build

FROM node:16.17.0-alpine3.16
ARG DATABASE_URL
ENV DATABASE_URL ${DATABASE_URL}
WORKDIR /app
COPY --from=ts-compiler /app/package.json .
COPY --from=ts-compiler /app/yarn.lock .
COPY --from=ts-compiler /app/src/prisma ./src/prisma
COPY --from=ts-compiler /app/dist ./dist
RUN yarn install --prod --frozen-lockfile
RUN yarn run prisma generate
CMD [ "yarn", "start:docker" ]
11 changes: 11 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:16.17.0-alpine3.16
ARG DATABASE_URL
ENV DATABASE_URL ${DATABASE_URL}
WORKDIR /app
COPY package.json .
COPY yarn.lock .
RUN yarn install --frozen-lockfile
COPY ./ ./
RUN yarn run prisma generate
RUN yarn build
CMD [ "yarn", "start:docker:dev" ]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 IST Bot Team
Copyright (c) 2021 IST Bot Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
# ist-discord-bot
# IST Discord Bot

![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/ist-bot-team/ist-discord-bot?label=version)
[![Discord](https://img.shields.io/discord/759576132227694642?label=discord&logo=discord)](https://discord.leic.pt)
![GitHub](https://img.shields.io/github/license/ist-bot-team/ist-discord-bot)

Discord bot to manage the IST Hub server -- join [here](https://discord.leic.pt).

### Running

#### Production

1. Create a `docker-compose.yml` file as below:

```yaml
version: "3.8"

services:
ist-discord-bot:
## EITHER:
image: ghcr.io/ist-bot-team/ist-discord-bot:2
## OR:
build:
context: .
dockerfile: Dockerfile.dev
args:
DATABASE_URL: file:/app/data/bot.db
## END;
volumes:
- type: bind
source: ./data
target: /app/data
environment:
DISCORD_TOKEN: PLACE_BOT_TOKEN_HERE
GUILD_ID: PLACE_MAIN_GUILD_ID_HERE # or "GLOBAL" to use in multiple guilds (1hr roll-out time)
ADMIN_ID: PLACE_ADMIN_ROLE_ID_HERE
ADMIN_PLUS_ID: PLACE_ADMIN_PLUS_ROLE_ID_HERE
COMMAND_LOGS_CHANNEL_ID: PLACE_LOGGING_CHANNEL_ID_HERE
TZ: Europe/Lisbon # default timezone for crontab and other date related stuff
restart: unless-stopped
```

2. Create a folder named `data` for Docker to store things in
3. Run `docker-compose up -d --build`
4. That's it!

_You can also use `docker-compose down`, `docker-compose up`, `docker-compose restart` and `docker-compose logs [-f]`._

### Adding to a Server

Replacing `CLIENT_ID` with the application's public ID, access the following link:

```
https://discord.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot+applications.commands&permissions=8
```

### Development

If you're looking at the source code, you should probably run

```sh
npx prisma generate
```

first so you can have typings.
Loading