Skip to content

[DISC-120] Implementation of Various Features #197

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

Merged
merged 71 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
054128a
migrate from insou api to circles for the handbook commands (#128)
imagine-hussain Feb 22, 2023
ea97f33
prettier formatted
AcdSoftCo Feb 22, 2023
81e5085
chore(deps): update `renovate` config
lhjt Mar 22, 2023
883a0d8
chore(deps): update docker/build-push-action action to v4 (#134)
renovate[bot] Mar 23, 2023
d0656ca
Projects description command feature (#145)
zcDay1 May 16, 2023
9a4c9ec
disable annoying carrotboard pins
abiramen Aug 18, 2023
2f59c71
rolesPermOverride command is a script or one-time use command to atta…
AcdSoftCo Sep 16, 2023
617c373
Revert "rolesPermOverride command is a script or one-time use command…
AcdSoftCo Sep 16, 2023
da9b795
rolesPermOverride command (#152)
zcDay1 Sep 20, 2023
d55e093
Roles perm override (#153)
zcDay1 Sep 24, 2023
b2562be
Project descriptions (#154)
zcDay1 Sep 25, 2023
9f7c78d
Merge branch 'projects-bot' into develop
zcDay1 Sep 26, 2023
65f32ef
Dev/course channel fix 3 (#158)
Bigbugman Oct 21, 2023
7912884
Merge branch 'projects-bot' into develop
zcDay1 Oct 21, 2023
027f8fe
dev/course-channel-fix-5 (#160)
abe123442 Oct 22, 2023
a2cafe4
Merge branch 'projects-bot' into develop
zcDay1 Oct 22, 2023
4bac7ae
Update rolesPermOverride.js
zcDay1 Oct 24, 2023
b9576b5
Course Command Fixing - Collection Null Value Error (#162)
Domin0de Oct 31, 2023
0f34280
Dev/upgrade handbook url (#164)
abe123442 Nov 3, 2023
35f1f3b
Fixed bug for courses that do not yet have an offering term (Default:…
abe123442 Nov 3, 2023
34e2f53
Implementation of the Lunch Buddy feature (#167)
Domin0de Jan 21, 2024
6da7e8e
[DISC-107] Adding csesocLinks to get CSESoc related links (#170)
chlowoee Apr 21, 2024
dc2088f
[DISC-109] Adding bot-status for events and member count (#169)
ericwu2205 May 5, 2024
e4e3aa1
Update dependency nodemailer to v6.9.9 [SECURITY] (#168)
renovate[bot] May 15, 2024
28dad18
Update dependency axios to v0.28.0 [SECURITY] (#166)
renovate[bot] May 15, 2024
e02999a
fix(deps): update dependency yaml to v2.2.2 [security] (#147)
renovate[bot] May 15, 2024
1d16f9d
Update dependency dotenv to v16 (#141)
renovate[bot] May 15, 2024
ed9e422
chore(deps): update actions/checkout action to v4 (#157)
renovate[bot] May 15, 2024
ea0b2f8
fix(deps): update dependency discordjs-button-pagination to v3 (#140)
renovate[bot] May 15, 2024
e9cc79b
Remove unused discord-tictactoe dependency and updated canvas (#173)
Domin0de May 15, 2024
90a3e00
fix(deps): update weekly patch updates (#142)
renovate[bot] May 15, 2024
a1c4112
fix(deps): update dependency @discordjs/builders to v1 (#135)
renovate[bot] May 15, 2024
720e1c6
fix(deps): update dependency discord.js to v14 (#139)
renovate[bot] May 15, 2024
b2c1a88
Update to fix v14 breaking changes (#176)
Domin0de May 15, 2024
05f2dd7
chore(deps): update actions/setup-node action to v4 (#172)
renovate[bot] May 15, 2024
1b1ba66
Nitpick refactor for courses command (#126)
XenocidePC May 25, 2024
14d467c
fix(deps): update dependency mathjs to v12 (#182)
renovate[bot] May 27, 2024
dead83e
fix(deps): update dependency axios to v1 (#181)
renovate[bot] May 27, 2024
31a2eb0
fix(deps): update dependency @discordjs/rest to v2 (#179)
renovate[bot] May 27, 2024
0269b1c
chore(deps): update dependency eslint-config-prettier to v9 (#175)
renovate[bot] May 27, 2024
eeb06f1
fix(deps): update dependency nodemon to v3 (#183)
renovate[bot] May 27, 2024
3848496
chore(deps): update node.js to v20 (#171)
renovate[bot] May 27, 2024
8e1acf4
fix(deps): update dependency mathjs to v13 (#184)
renovate[bot] Jun 5, 2024
0762214
DISC-119-unielectives-review (#188)
h34312575s Jun 16, 2024
a586bb2
[DISC-120] Update eslint dependency and nodejs to v20
renovate[bot] Jun 27, 2024
7bebb5f
[DISC-120] Update to prettier and corresponding eslint plugin
renovate[bot] Jun 27, 2024
ab156e2
chore(deps): lock file maintenance (#186)
renovate[bot] Jun 27, 2024
0478938
chore(deps): update weekly minor updates (#143)
renovate[bot] Jun 27, 2024
84d63f4
[DISC-120] Fix to renovate.json file (#190)
Domin0de Jun 27, 2024
d2ff9ac
[DISC-120] Declare file type for requiring data (#192)
Domin0de Jun 28, 2024
719f36d
[DISC-120] Adjust data type for file (#193)
Domin0de Jun 28, 2024
c7f335f
[DISC-120] Move to using fs for configuration (#194)
Domin0de Jun 28, 2024
56701c8
Move file to config
Domin0de Jun 28, 2024
5fa634f
Fix spelling error
Domin0de Jun 28, 2024
f4b82ae
Append setup command for puppeteer browser
Domin0de Jun 28, 2024
132b068
Downloading dependencies and requirements for puppeteer
Domin0de Jun 29, 2024
da4e542
Modification to installation order
Domin0de Jun 29, 2024
36d43cd
Affirm installation
Domin0de Jun 29, 2024
6e593c8
Revert prior changes and set to use alternate folder for chromium ins…
Domin0de Jul 8, 2024
804c65f
Manually ignore puppeteer config file in eslint
Domin0de Jul 8, 2024
54dc641
Attempt fix to eslint hanging
Domin0de Jul 8, 2024
e65eb61
[DISC-117] Adding travelguides command (#187)
chlowoee Jul 9, 2024
7028f56
Modify location and method for chromium install
Domin0de Jul 9, 2024
ada9f90
Alter setup to use chromium base
Domin0de Jul 9, 2024
d8f9e47
Update to puppeteer version
Domin0de Jul 9, 2024
c651c4c
Replace secondary node image with puppeteer
Domin0de Jul 14, 2024
0c17f44
Fix capitalisation inconsistency and assume permission set
Domin0de Jul 14, 2024
dff8d4b
Reappend entrypoint permission modification
Domin0de Jul 14, 2024
a34fca4
Reset user from image setup
Domin0de Jul 14, 2024
5298768
Attempt return to puppeteer user after setup
Domin0de Jul 17, 2024
eecb1b5
[DISC-110] Adding Course Chats 1-year "Subscription" (#191)
ericwu2205 Jul 17, 2024
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
48 changes: 0 additions & 48 deletions .eslintrc.json

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- run: npm ci
- run: npm run format:check
- run: npm run lint
Expand All @@ -25,7 +25,7 @@ jobs:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
Expand Down Expand Up @@ -59,12 +59,12 @@ jobs:
name: production (projects-bot)
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: csesoc/deployment
token: ${{ secrets.GH_TOKEN }}
- name: Install yq - portable yaml processor
uses: mikefarah/yq@v4.27.5
uses: mikefarah/yq@v4.44.2
- name: Determine file to update
id: get_manifest
env:
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build layer template for an eventual TS migration
FROM node:16.17.0-slim as builder
FROM node:20.15.0-slim AS builder
ENV NODE_ENV=production

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

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

USER root

# Set working directory
WORKDIR /app

Expand All @@ -23,5 +25,7 @@ COPY . .

RUN chmod +x entrypoint.sh

USER pptruser

# Run bot
ENTRYPOINT [ "./entrypoint.sh" ]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
- `DISCORD_TOKEN` with the token of the bot
- `APP_ID` with the ID of the bot application
- Install dependencies with `npm install`
- Register slash commands with `node deploy-commands.js`
- Register slash commands with `npm run deploy` or `node deploy-commands.js`
- Ensure a PostgreSQL database is setup according to "config/database.yml"
- Start the bot with `node index.js`

## Running the bot with Nodemon

- Nodemon has been installed, this addition allows for continuous integration with and hot reloads the bot upon saving.
- Run the bot with Nodemon using `npm run server`
12 changes: 6 additions & 6 deletions commands/admin-standup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed, MessageButton, Permissions } = require("discord.js");
const { EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js");
const paginationEmbed = require("discordjs-button-pagination");

module.exports = {
Expand Down Expand Up @@ -104,7 +104,7 @@ module.exports = {
if (notDone.length == 0) {
standupEmbeded.forEach((el) => {
embedList.push(
new MessageEmbed()
new EmbedBuilder()
.setTitle("Standups (" + role.name + ")")
.setDescription(
el + "\n\n" + "_Everyone has done their standup_\n",
Expand All @@ -114,7 +114,7 @@ module.exports = {
} else {
standupEmbeded.forEach((el) => {
embedList.push(
new MessageEmbed()
new EmbedBuilder()
.setTitle("Standups (" + role.name + ")")
.setDescription(
el +
Expand All @@ -127,7 +127,7 @@ module.exports = {
}

if (thisTeamStandups.length == 0) {
const embed = new MessageEmbed()
const embed = new EmbedBuilder()
.setTitle("Standups (" + role.name + ")")
.setDescription(
"No standups recorded\n\n" +
Expand All @@ -138,11 +138,11 @@ module.exports = {
}

const buttonList = [
new MessageButton()
new ButtonBuilder()
.setCustomId("previousbtn")
.setLabel("Previous")
.setStyle("DANGER"),
new MessageButton().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
new ButtonBuilder().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
];

paginationEmbed(interaction, embedList, buttonList);
Expand Down
12 changes: 6 additions & 6 deletions commands/anonymouspost.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { allowedChannels } = require("../config/anon_channel.json");
const paginationEmbed = require("discordjs-button-pagination");
const fs = require("fs");
const { Util, MessageEmbed, MessageButton, Permissions } = require("discord.js");
const { Util, EmbedBuilder, ButtonBuilder, Permissions } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("anonymouspost")
Expand Down Expand Up @@ -223,7 +223,7 @@ module.exports = {
} else if (interaction.options.getSubcommand() === "whitelist") {
// No allowed roles
if (allowedChannels.length == 0) {
const embed = new MessageEmbed()
const embed = new EmbedBuilder()
.setTitle("Allowed Channels")
.setDescription("No allowed channels");
return await interaction.reply({ embeds: [embed] });
Expand All @@ -239,7 +239,7 @@ module.exports = {
}

if (channels.length == 0) {
const embed = new MessageEmbed()
const embed = new EmbedBuilder()
.setTitle("Allowed Channels")
.setDescription("No allowed channels");
return await interaction.reply({ embeds: [embed] });
Expand All @@ -250,18 +250,18 @@ module.exports = {
const embedList = [];
for (let i = 0; i < channels.length; i += channelsPerPage) {
embedList.push(
new MessageEmbed()
new EmbedBuilder()
.setTitle("Allowed Channels")
.setDescription(channels.slice(i, i + channelsPerPage).join("\n")),
);
}

const buttonList = [
new MessageButton()
new ButtonBuilder()
.setCustomId("previousbtn")
.setLabel("Previous")
.setStyle("DANGER"),
new MessageButton().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
new ButtonBuilder().setCustomId("nextbtn").setLabel("Next").setStyle("SUCCESS"),
];

paginationEmbed(interaction, embedList, buttonList);
Expand Down
4 changes: 2 additions & 2 deletions commands/coinFlip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { MessageEmbed } = require("discord.js");
const { EmbedBuilder } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder().setName("coinflip").setDescription("Tosses a coin 💰"),
Expand All @@ -13,7 +13,7 @@ module.exports = {
: 'http://assets.stickpng.com/thumbs/5a521f522f93c7a8d5137fc7.png';
*/
const img = coinNum === 0 ? "attachment://heads.png" : "attachment://tails.png";
const embed = new MessageEmbed().setTitle(`it's ${coin}!`).setImage(img);
const embed = new EmbedBuilder().setTitle(`it's ${coin}!`).setImage(img);
if (coinNum == 0) {
return await interaction.reply({
embeds: [embed],
Expand Down
50 changes: 33 additions & 17 deletions commands/course.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { ChannelType } = require("discord.js");

const COMMAND_JOIN = "join";
const COMMAND_LEAVE = "leave";
Expand Down Expand Up @@ -35,20 +36,26 @@ const get_real_course_name = (course) => {
};

const is_valid_course = (course) => {
const reg_comp_course = /^comp\d{4}$/;
const reg_math_course = /^math\d{4}$/;
const reg_binf_course = /^binf\d{4}$/;
const reg_engg_course = /^engg\d{4}$/;
const reg_seng_course = /^seng\d{4}$/;
const reg_desn_course = /^desn\d{4}$/;
const reg_valid_course = /^[a-zA-Z]{4}\d{4}$/;

return reg_valid_course.test(course);
};

const is_supported_course = (course) => {
const reg_comp_course = /^comp\d{4}$/i;
const reg_math_course = /^math\d{4}$/i;
const reg_binf_course = /^binf\d{4}$/i;
const reg_engg_course = /^engg\d{4}$/i;
const reg_seng_course = /^seng\d{4}$/i;
const reg_desn_course = /^desn\d{4}$/i;

return (
reg_comp_course.test(course.toLowerCase()) ||
reg_math_course.test(course.toLowerCase()) ||
reg_binf_course.test(course.toLowerCase()) ||
reg_engg_course.test(course.toLowerCase()) ||
reg_seng_course.test(course.toLowerCase()) ||
reg_desn_course.test(course.toLowerCase())
reg_comp_course.test(course) ||
reg_math_course.test(course) ||
reg_binf_course.test(course) ||
reg_engg_course.test(course) ||
reg_seng_course.test(course) ||
reg_desn_course.test(course)
);
};

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

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

const course_with_alias =
course != input_course
? `${course} (same course chat as ${input_course})`
: `${course}`;

if (!is_valid && other_courses.test(course.toLowerCase())) {
if (!is_supported && is_valid) {
return await interaction.reply({
content: `❌ | Course chats for other faculties are not supported.`,
ephemeral: true,
});
} else if (!is_valid) {
} else if (!is_supported) {
return await interaction.reply({
content: `❌ | You are not allowed to join this channel using this command.`,
ephemeral: true,
Expand All @@ -120,9 +127,14 @@ module.exports = {
ephemeral: true,
});
}
// // Add it to the existing database to track.
/** @type {DBuser} */
const userDB = global.userDB;
await userDB.add_user_role(interaction.user.id, role.name);

// If they don't, let's add the role to them
await interaction.member.roles.add(role);

return await interaction.reply({
content: `✅ | Added you to the chat for \`${course_with_alias}\`.`,
ephemeral: true,
Expand All @@ -138,7 +150,7 @@ module.exports = {
const input_course = await interaction.options.getString("course");
const course = get_real_course_name(input_course);

if (!is_valid_course(course)) {
if (!is_supported_course(course)) {
return await interaction.reply({
content: `❌ | Not a valid course.`,
ephemeral: true,
Expand All @@ -155,7 +167,7 @@ module.exports = {
content: `❌ | The course chat for \`${course}\` does not exist.`,
ephemeral: true,
});
} else if (channel.type !== "GUILD_TEXT") {
} else if (channel.type !== ChannelType.GuildText) {
return await interaction.reply({
content: `❌ | The course chat for \`${course}\` is not a text channel.`,
ephemeral: true,
Expand Down Expand Up @@ -183,6 +195,10 @@ module.exports = {
in_overwrites(permissions, role.id)
) {
// If they do remove the role
/** @type {DBuser} */
const userDB = global.userDB;
userDB.remove_user_role(interaction.user.id, role.name);

await interaction.member.roles.remove(role);
return await interaction.reply({
content: `✅ | Removed you from the role and chat for \`${course}\`.`,
Expand Down
Loading
Loading