Skip to content

Commit 3bf3a61

Browse files
Domin0deimagine-hussaintuneinzcDay1AcdSoftCo
authored
[DISC-120] Implementation of Various Features (#197)
* migrate from insou api to circles for the handbook commands (#128) * migrate from insou api to circles for the handbook commands * remove trailing forward slash in handbook.json * handbook: the handbook is fixed * Update handbook.js commented out a console.log --------- Co-authored-by: tunein <[email protected]> Co-authored-by: zcDay1 <[email protected]> * prettier formatted * chore(deps): update `renovate` config * chore(deps): update docker/build-push-action action to v4 (#134) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Projects description command feature (#145) * projects-descriptions v1 commit * project-descriptions command v2 commit * linting fixes for project-descriptions.js, and for handbook.js --------- Co-authored-by: AcdSoftCo <[email protected]> * disable annoying carrotboard pins * rolesPermOverride command is a script or one-time use command to attach every course role with permissions to view and send messages in any text channel with identical name. Please review and test before merging * Revert "rolesPermOverride command is a script or one-time use command to attach every course role with permissions to view and send messages in any text channel with identical name. Please review and test before merging" This reverts commit 2f59c71. * rolesPermOverride command (#152) * rolesPermOverride command is a script or one-time use command to attach every course role with permissions to view and send messages in any text channel with identical name. Please review and test before mergin * BUGGY CODE but still progress over the previous commit, I will come back this evening to fix * rolesPermOverride command: now admin-only command, and I've tested it for various cases regarding if a channel exists, if a role exists for a channel that doesnt exist, if there are two channels with the same name as a role and vice versa, and it works without error --------- Co-authored-by: AcdSoftCo <[email protected]> * Roles perm override (#153) * rolesPermOverride command is a script or one-time use command to attach every course role with permissions to view and send messages in any text channel with identical name. Please review and test before mergin * BUGGY CODE but still progress over the previous commit, I will come back this evening to fix * rolesPermOverride command: now admin-only command, and I've tested it for various cases regarding if a channel exists, if a role exists for a channel that doesnt exist, if there are two channels with the same name as a role and vice versa, and it works without error * course.js: removed code to create individual user permission overwrites in each channel --------- Co-authored-by: AcdSoftCo <[email protected]> * Project descriptions (#154) * project-descriptions.js: updated course descriptions written by the directors for 2023 levelling up with Projects Fair Day, and the discord bot CTF flag easter egg entry under this command included too for this event. * made messages ephemeral to prevent chat from being spammed by users. And got rid of link embeds in the messages. * lint update --------- Co-authored-by: AcdSoftCo <[email protected]> * Dev/course channel fix 3 (#158) * course-chat-fix-2, make new roles where there arent any in /rolespermoverride and also remove individual permission overwrites, and also updates to /course join to catch when there doesn't exist a role for a course and also /course leave to attempt to remove individual permission overwrites along with removing course role PLEASE TEST THOROUGHLY AND INSPECT CODE THOROUGHLY. I wrote this ASAP and haven't got time to properly review it. * Modified functions for course channel fixes * Check for if user only has read perms for overwrite replacing and fix looping over members * Fix to functionality of iteration and editing roles * Fix to initial working state * Fix linting * Additional fixes to ordering and component operations to remove role and individual permissions correctly * Appended filter for both view only perms and view + send messages perms --------- Co-authored-by: AcdSoftCo <[email protected]> Co-authored-by: Wolfdragon24 <[email protected]> * dev/course-channel-fix-5 (#160) * course-chat-fix-2, make new roles where there arent any in /rolespermoverride and also remove individual permission overwrites, and also updates to /course join to catch when there doesn't exist a role for a course and also /course leave to attempt to remove individual permission overwrites along with removing course role PLEASE TEST THOROUGHLY AND INSPECT CODE THOROUGHLY. I wrote this ASAP and haven't got time to properly review it. * Modified functions for course channel fixes * Check for if user only has read perms for overwrite replacing and fix looping over members * Fix to functionality of iteration and editing roles * Fix to initial working state * Fix linting * Additional fixes to ordering and component operations to remove role and individual permissions correctly * Appended filter for both view only perms and view + send messages perms * Appended single channel mode for permissions override * Appended check command for role permissions * Resolved merge conflicts in dev/course-channel-fix-4 --------- Co-authored-by: AcdSoftCo <[email protected]> Co-authored-by: Wolfdragon24 <[email protected]> * Update rolesPermOverride.js double equals updated to triple equals on line 156 * Course Command Fixing - Collection Null Value Error (#162) * Accounting for non-channel returns associated to snowflakes * Utilise cache directly as fetch falls back to a cache call anyway * Dev/upgrade handbook url (#164) * Upgraded handbook url in config.json to use 2024. Also fixed incorrect url links in the handbook.js command. * Fixed eslint warnings * Fixed bug for courses that do not yet have an offering term (Default: "None") (#165) * Upgraded handbook url in config.json to use 2024. Also fixed incorrect url links in the handbook.js command. * Fixed eslint warnings * Fixed equivalent courses urls being listed * Implementation of the Lunch Buddy feature (#167) * update: checking if perms work * Chron job set for every minute, basic embed added and structure for the locations and sub locations created * Updated README * Implemented area voting system * Ran linting and prettier for current changes * Appending location poll for given area, and vote counting for both area and locations * Implemented functional voting system for area and location, creating thread upon completion of set * Used await and cleaned up a bit of code, thread now adds all voters not only the ones who voted for the winning area * Lint fix * Removed promises and adjusted placement of vote function calls * Adjusted thread users, append location vote pings * Linting fixes * Locations Update * Adds "any" option and append additional vote info * Appended code for live run timing * Update to use config file * Allow disabling of feature without editing code and disable * Minor adjustment to readme and npm commands * Appended clarifying comment regarding edge case of only any votes --------- Co-authored-by: mi-mott <[email protected]> * [DISC-107] Adding csesocLinks to get CSESoc related links (#170) * completed csesocLinks command * linting * Refactor execute function to use arrow functions * linting * [DISC-109] Adding bot-status for events and member count (#169) * Adding bot-status for events and member count * Fixing lint errors * Adding fixes to how member count is calculated --------- Authored-by: Eric <[email protected]> * Update dependency nodemailer to v6.9.9 [SECURITY] (#168) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency axios to v0.28.0 [SECURITY] (#166) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency yaml to v2.2.2 [security] (#147) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency dotenv to v16 (#141) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update actions/checkout action to v4 (#157) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency discordjs-button-pagination to v3 (#140) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Remove unused discord-tictactoe dependency and updated canvas (#173) * fix(deps): update weekly patch updates (#142) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency @discordjs/builders to v1 (#135) * Update dependency @discordjs/builders to v1 * Update to project description choices to utilise object structure (Fix to erroring on dependency update) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Wolfdragon24 <[email protected]> Co-authored-by: Wolfdragon24 <[email protected]> * fix(deps): update dependency discord.js to v14 (#139) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update to fix v14 breaking changes (#176) * chore(deps): update actions/setup-node action to v4 (#172) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Nitpick refactor for courses command (#126) * I can finally sleep now * Implementation of suggested modifications * Modification to ensure correct regex form for case-insensitive match --------- Co-authored-by: Wolfdragon24 <[email protected]> * fix(deps): update dependency mathjs to v12 (#182) * chore(deps): update docker-github-actions * fix(deps): update dependency mathjs to v12 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency axios to v1 (#181) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency @discordjs/rest to v2 (#179) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update dependency eslint-config-prettier to v9 (#175) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency nodemon to v3 (#183) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update node.js to v20 (#171) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency mathjs to v13 (#184) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * DISC-119-unielectives-review (#188) * working unilectives review * added warning for chartjs dependency * changed to ephemeral reply * removed unneccesary libraries for chartjs * hopefully no npm package conflict dying * npm packages should be fixed * changed web scraper package for robustness * linting * fixed yaml npm issue * JSCode docu * linting * revert config files to og * package-json changes --------- Co-authored-by: addison <[email protected]> * [DISC-120] Update eslint dependency and nodejs to v20 * chore(deps): update dependency eslint to v9 * Update to eslint and babel/eslint-parser * Update lock file * Fixes for linting * Modifications to ignore node modules and consider all other files for linting * Force update of node to version 20 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Wolfdragon24 <[email protected]> * [DISC-120] Update to prettier and corresponding eslint plugin * chore(deps): update dependency prettier to v3 * Update prettier config to use auto end of line setting * Linting and prettifying * Prettier fixes and running format * Prettier fix * Fix by consolidating updates to prettier and eslint plugin --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Wolfdragon24 <[email protected]> * chore(deps): lock file maintenance (#186) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update weekly minor updates (#143) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [DISC-120] Fix to renovate.json file (#190) * [DISC-120] Declare file type for requiring data (#192) * [DISC-120] Adjust data type for file (#193) * Declare file type for requiring data * Use json as opposed to js data file * [DISC-120] Move to using fs for configuration (#194) * Declare file type for requiring data * Use json as opposed to js data file * Replace require to use reading file with fs * Move file to config * Fix spelling error * Append setup command for puppeteer browser * Downloading dependencies and requirements for puppeteer * Modification to installation order * Affirm installation * Revert prior changes and set to use alternate folder for chromium instance * Manually ignore puppeteer config file in eslint * Attempt fix to eslint hanging * [DISC-117] Adding travelguides command (#187) * initial travelguide add subcommand * fixing formatting * fixing syntax error * added get function * linting * completed travelguide command * linting * adding deletion confirmation * linting * migrating travelguide.json to postgres * linting * linting --------- Co-authored-by: Jessica Xu <[email protected]> * Modify location and method for chromium install * Alter setup to use chromium base * Update to puppeteer version * Replace secondary node image with puppeteer * Fix capitalisation inconsistency and assume permission set * Reappend entrypoint permission modification * Reset user from image setup * Attempt return to puppeteer user after setup * [DISC-110] Adding Course Chats 1-year "Subscription" (#191) * Added database implementation of user roles when assigned and removed * Added time checking function for expired user_roles and added time assigned column to user_roles table * Added on ready file with cron.js to perform daily check of old_roles * Adding new package cron for scheduling * fixing lint issues * Fixing prettier issues * Package changes * Restoring develop package lock.json and fixing db_ready * Moving guild and roles out of for loop to remove redundant fetching --------- Co-authored-by: imagine-hussain <[email protected]> Co-authored-by: tunein <[email protected]> Co-authored-by: zcDay1 <[email protected]> Co-authored-by: AcdSoftCo <[email protected]> Co-authored-by: Jared L <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: abiramen <[email protected]> Co-authored-by: Bigbugman <[email protected]> Co-authored-by: Abraham Assariparambil Earnest <[email protected]> Co-authored-by: mi-mott <[email protected]> Co-authored-by: chlowoee <[email protected]> Co-authored-by: ericwu2205 <[email protected]> Co-authored-by: XenocidePC <[email protected]> Co-authored-by: h34312575s <[email protected]> Co-authored-by: addison <[email protected]> Co-authored-by: Jessica Xu <[email protected]>
1 parent a93bd73 commit 3bf3a61

Some content is hidden

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

51 files changed

+6121
-2774
lines changed

.eslintrc.json

-48
This file was deleted.

.github/workflows/docker.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout repository
12-
uses: actions/checkout@v3
13-
- uses: actions/setup-node@v3
12+
uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
1414
with:
15-
node-version: 16
15+
node-version: 20
1616
- run: npm ci
1717
- run: npm run format:check
1818
- run: npm run lint
@@ -25,7 +25,7 @@ jobs:
2525
packages: write
2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2929
- name: Set up QEMU
3030
uses: docker/setup-qemu-action@v2
3131
with:
@@ -59,12 +59,12 @@ jobs:
5959
name: production (projects-bot)
6060
steps:
6161
- name: Checkout repository
62-
uses: actions/checkout@v3
62+
uses: actions/checkout@v4
6363
with:
6464
repository: csesoc/deployment
6565
token: ${{ secrets.GH_TOKEN }}
6666
- name: Install yq - portable yaml processor
67-
uses: mikefarah/yq@v4.27.5
67+
uses: mikefarah/yq@v4.44.2
6868
- name: Determine file to update
6969
id: get_manifest
7070
env:

Dockerfile

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build layer template for an eventual TS migration
2-
FROM node:16.17.0-slim as builder
2+
FROM node:20.15.0-slim AS builder
33
ENV NODE_ENV=production
44

55
# Set working directory
@@ -9,9 +9,11 @@ WORKDIR /app
99
COPY package.json package-lock.json ./
1010
RUN npm ci --omit=dev
1111

12-
FROM node:16.17.0-slim
12+
FROM ghcr.io/puppeteer/puppeteer:22.12.1
1313
ENV NODE_ENV=production
1414

15+
USER root
16+
1517
# Set working directory
1618
WORKDIR /app
1719

@@ -23,5 +25,7 @@ COPY . .
2325

2426
RUN chmod +x entrypoint.sh
2527

28+
USER pptruser
29+
2630
# Run bot
2731
ENTRYPOINT [ "./entrypoint.sh" ]

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@
88
- `DISCORD_TOKEN` with the token of the bot
99
- `APP_ID` with the ID of the bot application
1010
- Install dependencies with `npm install`
11-
- Register slash commands with `node deploy-commands.js`
11+
- Register slash commands with `npm run deploy` or `node deploy-commands.js`
12+
- Ensure a PostgreSQL database is setup according to "config/database.yml"
1213
- Start the bot with `node index.js`
14+
15+
## Running the bot with Nodemon
16+
17+
- Nodemon has been installed, this addition allows for continuous integration with and hot reloads the bot upon saving.
18+
- Run the bot with Nodemon using `npm run server`

commands/admin-standup.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { SlashCommandBuilder } = require("@discordjs/builders");
2-
const { MessageEmbed, MessageButton, Permissions } = require("discord.js");
2+
const { EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js");
33
const paginationEmbed = require("discordjs-button-pagination");
44

55
module.exports = {
@@ -104,7 +104,7 @@ module.exports = {
104104
if (notDone.length == 0) {
105105
standupEmbeded.forEach((el) => {
106106
embedList.push(
107-
new MessageEmbed()
107+
new EmbedBuilder()
108108
.setTitle("Standups (" + role.name + ")")
109109
.setDescription(
110110
el + "\n\n" + "_Everyone has done their standup_\n",
@@ -114,7 +114,7 @@ module.exports = {
114114
} else {
115115
standupEmbeded.forEach((el) => {
116116
embedList.push(
117-
new MessageEmbed()
117+
new EmbedBuilder()
118118
.setTitle("Standups (" + role.name + ")")
119119
.setDescription(
120120
el +
@@ -127,7 +127,7 @@ module.exports = {
127127
}
128128

129129
if (thisTeamStandups.length == 0) {
130-
const embed = new MessageEmbed()
130+
const embed = new EmbedBuilder()
131131
.setTitle("Standups (" + role.name + ")")
132132
.setDescription(
133133
"No standups recorded\n\n" +
@@ -138,11 +138,11 @@ module.exports = {
138138
}
139139

140140
const buttonList = [
141-
new MessageButton()
141+
new ButtonBuilder()
142142
.setCustomId("previousbtn")
143143
.setLabel("Previous")
144144
.setStyle("DANGER"),
145-
new MessageButton().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
145+
new ButtonBuilder().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
146146
];
147147

148148
paginationEmbed(interaction, embedList, buttonList);

commands/anonymouspost.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
22
const { allowedChannels } = require("../config/anon_channel.json");
33
const paginationEmbed = require("discordjs-button-pagination");
44
const fs = require("fs");
5-
const { Util, MessageEmbed, MessageButton, Permissions } = require("discord.js");
5+
const { Util, EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js");
66
module.exports = {
77
data: new SlashCommandBuilder()
88
.setName("anonymouspost")
@@ -223,7 +223,7 @@ module.exports = {
223223
} else if (interaction.options.getSubcommand() === "whitelist") {
224224
// No allowed roles
225225
if (allowedChannels.length == 0) {
226-
const embed = new MessageEmbed()
226+
const embed = new EmbedBuilder()
227227
.setTitle("Allowed Channels")
228228
.setDescription("No allowed channels");
229229
return await interaction.reply({ embeds: [embed] });
@@ -239,7 +239,7 @@ module.exports = {
239239
}
240240

241241
if (channels.length == 0) {
242-
const embed = new MessageEmbed()
242+
const embed = new EmbedBuilder()
243243
.setTitle("Allowed Channels")
244244
.setDescription("No allowed channels");
245245
return await interaction.reply({ embeds: [embed] });
@@ -250,18 +250,18 @@ module.exports = {
250250
const embedList = [];
251251
for (let i = 0; i < channels.length; i += channelsPerPage) {
252252
embedList.push(
253-
new MessageEmbed()
253+
new EmbedBuilder()
254254
.setTitle("Allowed Channels")
255255
.setDescription(channels.slice(i, i + channelsPerPage).join("\n")),
256256
);
257257
}
258258

259259
const buttonList = [
260-
new MessageButton()
260+
new ButtonBuilder()
261261
.setCustomId("previousbtn")
262262
.setLabel("Previous")
263263
.setStyle("DANGER"),
264-
new MessageButton().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
264+
new ButtonBuilder().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
265265
];
266266

267267
paginationEmbed(interaction, embedList, buttonList);

commands/coinFlip.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { SlashCommandBuilder } = require("@discordjs/builders");
2-
const { MessageEmbed } = require("discord.js");
2+
const { EmbedBuilder } = require("discord.js");
33

44
module.exports = {
55
data: new SlashCommandBuilder().setName("coinflip").setDescription("Tosses a coin 💰"),
@@ -13,7 +13,7 @@ module.exports = {
1313
: 'http://assets.stickpng.com/thumbs/5a521f522f93c7a8d5137fc7.png';
1414
*/
1515
const img = coinNum === 0 ? "attachment://heads.png" : "attachment://tails.png";
16-
const embed = new MessageEmbed().setTitle(`it's ${coin}!`).setImage(img);
16+
const embed = new EmbedBuilder().setTitle(`it's ${coin}!`).setImage(img);
1717
if (coinNum == 0) {
1818
return await interaction.reply({
1919
embeds: [embed],

commands/course.js

+33-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { SlashCommandBuilder } = require("@discordjs/builders");
2+
const { ChannelType } = require("discord.js");
23

34
const COMMAND_JOIN = "join";
45
const COMMAND_LEAVE = "leave";
@@ -35,20 +36,26 @@ const get_real_course_name = (course) => {
3536
};
3637

3738
const is_valid_course = (course) => {
38-
const reg_comp_course = /^comp\d{4}$/;
39-
const reg_math_course = /^math\d{4}$/;
40-
const reg_binf_course = /^binf\d{4}$/;
41-
const reg_engg_course = /^engg\d{4}$/;
42-
const reg_seng_course = /^seng\d{4}$/;
43-
const reg_desn_course = /^desn\d{4}$/;
39+
const reg_valid_course = /^[a-zA-Z]{4}\d{4}$/;
40+
41+
return reg_valid_course.test(course);
42+
};
43+
44+
const is_supported_course = (course) => {
45+
const reg_comp_course = /^comp\d{4}$/i;
46+
const reg_math_course = /^math\d{4}$/i;
47+
const reg_binf_course = /^binf\d{4}$/i;
48+
const reg_engg_course = /^engg\d{4}$/i;
49+
const reg_seng_course = /^seng\d{4}$/i;
50+
const reg_desn_course = /^desn\d{4}$/i;
4451

4552
return (
46-
reg_comp_course.test(course.toLowerCase()) ||
47-
reg_math_course.test(course.toLowerCase()) ||
48-
reg_binf_course.test(course.toLowerCase()) ||
49-
reg_engg_course.test(course.toLowerCase()) ||
50-
reg_seng_course.test(course.toLowerCase()) ||
51-
reg_desn_course.test(course.toLowerCase())
53+
reg_comp_course.test(course) ||
54+
reg_math_course.test(course) ||
55+
reg_binf_course.test(course) ||
56+
reg_engg_course.test(course) ||
57+
reg_seng_course.test(course) ||
58+
reg_desn_course.test(course)
5259
);
5360
};
5461

@@ -87,20 +94,20 @@ module.exports = {
8794
const input_course = await interaction.options.getString("course").toLowerCase();
8895
const course = get_real_course_name(input_course);
8996

90-
const other_courses = /^[a-zA-Z]{4}\d{4}$/;
9197
const is_valid = is_valid_course(course);
98+
const is_supported = is_supported_course(course);
9299

93100
const course_with_alias =
94101
course != input_course
95102
? `${course} (same course chat as ${input_course})`
96103
: `${course}`;
97104

98-
if (!is_valid && other_courses.test(course.toLowerCase())) {
105+
if (!is_supported && is_valid) {
99106
return await interaction.reply({
100107
content: `❌ | Course chats for other faculties are not supported.`,
101108
ephemeral: true,
102109
});
103-
} else if (!is_valid) {
110+
} else if (!is_supported) {
104111
return await interaction.reply({
105112
content: `❌ | You are not allowed to join this channel using this command.`,
106113
ephemeral: true,
@@ -120,9 +127,14 @@ module.exports = {
120127
ephemeral: true,
121128
});
122129
}
130+
// // Add it to the existing database to track.
131+
/** @type {DBuser} */
132+
const userDB = global.userDB;
133+
await userDB.add_user_role(interaction.user.id, role.name);
123134

124135
// If they don't, let's add the role to them
125136
await interaction.member.roles.add(role);
137+
126138
return await interaction.reply({
127139
content: `✅ | Added you to the chat for \`${course_with_alias}\`.`,
128140
ephemeral: true,
@@ -138,7 +150,7 @@ module.exports = {
138150
const input_course = await interaction.options.getString("course");
139151
const course = get_real_course_name(input_course);
140152

141-
if (!is_valid_course(course)) {
153+
if (!is_supported_course(course)) {
142154
return await interaction.reply({
143155
content: `❌ | Not a valid course.`,
144156
ephemeral: true,
@@ -155,7 +167,7 @@ module.exports = {
155167
content: `❌ | The course chat for \`${course}\` does not exist.`,
156168
ephemeral: true,
157169
});
158-
} else if (channel.type !== "GUILD_TEXT") {
170+
} else if (channel.type !== ChannelType.GuildText) {
159171
return await interaction.reply({
160172
content: `❌ | The course chat for \`${course}\` is not a text channel.`,
161173
ephemeral: true,
@@ -183,6 +195,10 @@ module.exports = {
183195
in_overwrites(permissions, role.id)
184196
) {
185197
// If they do remove the role
198+
/** @type {DBuser} */
199+
const userDB = global.userDB;
200+
userDB.remove_user_role(interaction.user.id, role.name);
201+
186202
await interaction.member.roles.remove(role);
187203
return await interaction.reply({
188204
content: `✅ | Removed you from the role and chat for \`${course}\`.`,

0 commit comments

Comments
 (0)