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

Major version update | 2.2.1 --> 2.3.0 #44

Draft
wants to merge 177 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
9fecc38
Move util and roleUtils into separate utils folder
schiltz3 Sep 7, 2022
c93c16c
WIP
schiltz3 Sep 7, 2022
19c4837
add is-docker
nathen418 Sep 7, 2022
adb3695
Detect running in a container
nathen418 Sep 7, 2022
6265df2
Feature/schiltz3/move utils (#36)
schiltz3 Sep 7, 2022
a8b95b3
Merge branch 'staging' of https://github.com/Antares-Network/CSSC-Bot…
nathen418 Sep 7, 2022
f1746fe
Update branch to be even with `staging`
nathen418 Sep 7, 2022
b0cd0ff
Apply auto formatting changes
nathen418 Sep 7, 2022
bf6395e
Merge branch 'staging' into feature/schiltz3/create-channels
schiltz3 Sep 7, 2022
b5dfd6e
Empty Commit
nathen418 Sep 7, 2022
62e5422
Merge branch 'feature/nathen418/detect-containerization' of https://g…
nathen418 Sep 7, 2022
805e4e9
Feature/nathen418/detect containerization (#37)
nathen418 Sep 7, 2022
8fc0485
WIP
schiltz3 Sep 8, 2022
0dda507
Merge branch 'staging' into feature/schiltz3/create-channels
schiltz3 Sep 8, 2022
952015a
WIP
schiltz3 Sep 8, 2022
1ddc599
Create channels rework
schiltz3 Sep 8, 2022
b102371
Apply auto formatting changes
schiltz3 Sep 8, 2022
ab67099
Archive old classes
schiltz3 Sep 8, 2022
f9b8c62
Deepsource fixes
schiltz3 Sep 8, 2022
8e4669c
Add ability to pass in category or category name
schiltz3 Sep 9, 2022
f7e166b
split more than 50 channels into separate categories
schiltz3 Sep 9, 2022
60e1daa
Clean up createTextChannel
schiltz3 Sep 9, 2022
068deba
Further clean up for createTextChannel
schiltz3 Sep 9, 2022
178acab
Deepsource
schiltz3 Sep 9, 2022
31e1d5f
Fixed issue where you could move a channel into a full category
schiltz3 Sep 9, 2022
be7fcdf
Prevent excessive moving
schiltz3 Sep 9, 2022
b4071fa
Clean strings in functions that need it
schiltz3 Sep 9, 2022
38c2a8d
Deepsource
schiltz3 Sep 9, 2022
ca6e279
Apply auto formatting changes
schiltz3 Sep 9, 2022
423bf8c
Bump typescript from 4.8.2 to 4.8.3
dependabot[bot] Sep 9, 2022
bd0bf85
Bump mongoose from 6.5.4 to 6.6.0
dependabot[bot] Sep 9, 2022
57d4e88
deepsource
schiltz3 Sep 9, 2022
74d1234
Change string cleaning
schiltz3 Sep 10, 2022
3395191
Only clean channel strings
schiltz3 Sep 10, 2022
cfcc963
WIP: Moving old channels not working
schiltz3 Sep 10, 2022
8cd44ed
Refresh cache, and lower max number of channels by 1
schiltz3 Sep 11, 2022
6529905
Update cleanString
schiltz3 Sep 11, 2022
27ab197
Change cleaned_courses data structure
schiltz3 Sep 11, 2022
b198737
Update existing channel descriptions
schiltz3 Sep 11, 2022
5b3a174
Ping members
schiltz3 Sep 11, 2022
3e34c37
Ping roles if you move the course from past courses
schiltz3 Sep 11, 2022
3dd3c6c
Bump typescript from 4.8.2 to 4.8.3 (#40)
nathen418 Sep 11, 2022
16d26f4
Bump mongoose from 6.5.4 to 6.6.0 (#41)
nathen418 Sep 11, 2022
4580aa4
Merge branch 'staging' into feature/schiltz3/create-channels
schiltz3 Sep 11, 2022
13564ba
Remove delete command
schiltz3 Sep 12, 2022
7d728e2
Remove unused code
schiltz3 Sep 12, 2022
df4e247
Deepsource
schiltz3 Sep 12, 2022
4efe07b
Deepsource
schiltz3 Sep 12, 2022
4afa13d
Deepsource
schiltz3 Sep 12, 2022
56431ad
Feature/schiltz3/create channels (#39)
schiltz3 Sep 12, 2022
e0dc1a4
Move utils to correct locations
schiltz3 Sep 13, 2022
76eee73
Add cleanCompSciString and remove functionality from cleanChannelString
schiltz3 Sep 13, 2022
25714bc
deepsource
schiltz3 Sep 13, 2022
324907b
Add migration command
schiltz3 Sep 14, 2022
ab7aeee
Update Schema and interfaces to reflect
schiltz3 Sep 14, 2022
f1e5bbd
remove test function
schiltz3 Sep 14, 2022
4db54ea
Replace string concatenation with template
schiltz3 Sep 14, 2022
639dc66
Update roles and channels from migrated db
schiltz3 Sep 14, 2022
9fba8bf
Add Missing DUPE field
schiltz3 Sep 14, 2022
b3fb122
get dupe name
schiltz3 Sep 14, 2022
48c33bb
Update string cleaning
schiltz3 Sep 14, 2022
ff798f7
Swap from CODE to NAME
schiltz3 Sep 14, 2022
beadc45
Replace string concatenation with template (#46)
schiltz3 Sep 15, 2022
5a7cbaa
Apply auto formatting changes
schiltz3 Sep 15, 2022
4c8db8f
Remove export
schiltz3 Sep 16, 2022
b7d41e3
use temp variable for current course in loop
schiltz3 Sep 16, 2022
59bb8a7
Bugfix: replace continuous hunks of whitespace with a dash
schiltz3 Sep 16, 2022
5d2a6d3
remove multiple -'s
schiltz3 Sep 16, 2022
0837955
remove brackets that match singular items
schiltz3 Sep 16, 2022
d60803a
group contiguous characters
schiltz3 Sep 16, 2022
e243cf1
catch newlines
schiltz3 Sep 16, 2022
d78e189
use rate limiter
schiltz3 Sep 16, 2022
f2c39eb
Don't drop ROLE_NAME
schiltz3 Sep 16, 2022
4ca6a21
Create correct course name
schiltz3 Sep 16, 2022
e83e57d
limit names to 100 characters
schiltz3 Sep 16, 2022
363a6b1
Create channels with both title and info
schiltz3 Sep 16, 2022
1a3e707
Use limiter
schiltz3 Sep 16, 2022
cec4660
Add get Topic function
schiltz3 Sep 16, 2022
1c997ed
Deepsource
schiltz3 Sep 16, 2022
c148db8
Clean course and rewrite createRoles
schiltz3 Sep 16, 2022
3b1f9fe
Fix message
schiltz3 Sep 16, 2022
5820739
Fix Schema
schiltz3 Sep 16, 2022
e68ae43
use defered reply
schiltz3 Sep 16, 2022
7c07cb0
Only reply if the role is actually assigned
schiltz3 Sep 16, 2022
e491d49
Filter on ROLE_NAME rather than NAME
schiltz3 Sep 16, 2022
654d4a3
Merge branch 'staging' into feature/schiltz3/db-migrate
schiltz3 Sep 16, 2022
ce714f9
use defered reply
schiltz3 Sep 16, 2022
7c6981b
Revert "use defered reply"
schiltz3 Sep 16, 2022
b2f12bf
only add new role if class poll is picked
schiltz3 Dec 27, 2022
2bb9fb9
revert
schiltz3 Dec 27, 2022
5037366
reword embed utils
schiltz3 Dec 27, 2022
cfe4100
renamed channel utils
schiltz3 Dec 27, 2022
7d924a1
renamed role utils
schiltz3 Dec 27, 2022
d1a0296
Apply auto formatting changes
schiltz3 Dec 27, 2022
10ce1e0
Auto stash before merge of "feature/schiltz3/db-migrate" and "origin/…
schiltz3 Dec 27, 2022
5f23810
Apply auto formatting changes
schiltz3 Dec 27, 2022
6a4a3fc
break out utils into separate files
schiltz3 Dec 27, 2022
df1d6a0
Apply auto formatting changes
schiltz3 Dec 27, 2022
aabe656
use defered reply (#85)
nathen418 Dec 27, 2022
d37eee3
break out utils into separate files (#86)
nathen418 Dec 27, 2022
83e64fd
Bugfix/schiltz3/add class role (#83)
schiltz3 Dec 28, 2022
b3d5339
Merge branch 'staging' into feature/schiltz3/db-migrate
schiltz3 Dec 29, 2022
db672ee
Ingore specific dev commands not allowed on prod
schiltz3 Dec 29, 2022
e55af2b
fix merge issue
schiltz3 Dec 29, 2022
28a198d
Apply auto formatting changes
schiltz3 Dec 29, 2022
2d9a79e
unused variable
schiltz3 Dec 29, 2022
065d073
used == where should have used ===
schiltz3 Dec 29, 2022
4e47906
avoid improper shadowing
schiltz3 Dec 29, 2022
6ad2cc0
use object literal shorthand.
schiltz3 Dec 29, 2022
870f727
Ignore, no need to return from map
schiltz3 Dec 29, 2022
006d049
remove unnecessary escape characters
schiltz3 Dec 29, 2022
7df1e41
Apply auto formatting changes
schiltz3 Dec 29, 2022
f12b06f
Add jest to the project
schiltz3 Jan 4, 2023
51bf134
Add tests for cleanChannelString
schiltz3 Jan 4, 2023
ca8e24f
Prevent error when statuspage env vars are not set
nathen418 Jan 4, 2023
c00be5e
Apply auto formatting changes
nathen418 Jan 4, 2023
6606b40
Feature/schiltz3/testing (#92)
schiltz3 Jan 4, 2023
5b6dbf4
Merge branch 'staging' into bugfix/schiltz3/deepsource
schiltz3 Jan 4, 2023
63463bd
Apply auto formatting changes
schiltz3 Jan 4, 2023
3b95e71
update tests to reflect cleanChannelString
schiltz3 Jan 5, 2023
545b98c
Apply auto formatting changes
schiltz3 Jan 5, 2023
6c10137
Bugfix/schiltz3/deepsource (#88)
schiltz3 Jan 5, 2023
84f6b9f
Merge branch 'staging' into feature/schiltz3/db-migrate
schiltz3 Jan 5, 2023
4f8280c
Apply auto formatting changes
schiltz3 Jan 5, 2023
5fd5bcb
remove incorrect tests , fix broken ones, and add new tests to reflec…
schiltz3 Jan 5, 2023
89fe708
Apply auto formatting changes
schiltz3 Jan 5, 2023
cf09808
deepsource
schiltz3 Jan 5, 2023
6f82202
Deepsource
schiltz3 Jan 5, 2023
ab13052
use === instead of ==
schiltz3 Jan 5, 2023
cfb8b86
Move ignore comment
schiltz3 Jan 5, 2023
4db0ca7
Bugfix/schiltz3/deepsource2 (#94)
schiltz3 Jan 5, 2023
fd8e9e7
Merge branch 'staging' into feature/schiltz3/db-migrate
schiltz3 Jan 6, 2023
d103b7c
rename and add jsdoc
schiltz3 Jan 7, 2023
a9fc225
move all files to src
schiltz3 Jan 8, 2023
f88849d
point to index
schiltz3 Jan 8, 2023
50fcf66
Prevent error when statuspage env vars are not set (#93)
schiltz3 Jan 9, 2023
9761ccf
update run command
schiltz3 Jan 9, 2023
7ddd08c
Merge branch 'staging' into feature/schiltz3/move-files
schiltz3 Jan 9, 2023
a07bb49
Feature/schiltz3/move files (#95)
schiltz3 Jan 9, 2023
b45e2b5
Merge branch 'staging' into feature/schiltz3/db-migrate
schiltz3 Jan 9, 2023
aaf5b57
fix typo
schiltz3 Jan 10, 2023
2b7632e
fix getTopic
schiltz3 Jan 10, 2023
e7a660e
Add tests
schiltz3 Jan 10, 2023
e5f8073
move migrateDB to the new folder
schiltz3 Jan 10, 2023
3d35a4c
move embeds
schiltz3 Jan 13, 2023
ce46502
rework regex for cleaning strings
schiltz3 Jan 13, 2023
55d394a
allow to match contiguous special characters
schiltz3 Jan 14, 2023
5c7df0e
fix import
schiltz3 Jan 14, 2023
7d3cb66
keep tests in order
schiltz3 Jan 14, 2023
53faf2f
cleanRoleString tests
schiltz3 Jan 14, 2023
cb6ace2
Apply auto formatting changes
schiltz3 Jan 14, 2023
e3f9ac9
start mocking discord.js
schiltz3 Jan 14, 2023
e896a0d
remove mocks
schiltz3 Jan 15, 2023
1ab5f05
fix regex
schiltz3 Jan 15, 2023
0311a5b
add active flag
schiltz3 Jan 15, 2023
9b11092
deepsource
schiltz3 Jan 15, 2023
62fac09
document
schiltz3 Jan 15, 2023
dbc4c2b
fix spelling
schiltz3 Jan 15, 2023
6743ddb
prefer Channel ID's over channel names
schiltz3 Jan 15, 2023
1e11a67
use === instead of ==
schiltz3 Jan 15, 2023
3c866ab
replace playantares with antaresnetwork
schiltz3 Jan 15, 2023
48e8700
Clean up and document roles
schiltz3 Jan 17, 2023
7f0af11
add documentation
schiltz3 Jan 17, 2023
d6f0999
swap to using name instead of ROLE_NAME
schiltz3 Jan 17, 2023
54d4a64
fix name
schiltz3 Jan 17, 2023
606276e
more documentation
schiltz3 Jan 17, 2023
f3a0597
Feature/schiltz3/db migrate (#48)
schiltz3 Jan 18, 2023
dc1b3fe
use === instead of ==
schiltz3 Jan 18, 2023
98794ae
use === instead of == (#103)
schiltz3 Jan 18, 2023
7352a77
Sort channels before creating them
schiltz3 Jan 21, 2023
4395e61
Report name of matching channel not id
schiltz3 Jan 21, 2023
d1e71e5
Found second spot
schiltz3 Jan 21, 2023
b10f93f
fix colors
schiltz3 Jan 21, 2023
01bcc36
check against roles not channels
schiltz3 Jan 21, 2023
8c7ff07
Bugfix/schiltz3/sort channels (#106)
schiltz3 Jan 21, 2023
03b7fd4
check against roles not channels (#108)
schiltz3 Jan 21, 2023
6c1de19
Report name of matching channel not id (#107)
schiltz3 Jan 21, 2023
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
*.env
node_modules
unused-commands
d.py/
d.py/

# Ignore specific dev commands not allowed in production
commands/owner/deleteChannels.ts
commands/owner/deleteRoles.ts
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ COPY . .

RUN npm install -g typescript ts-node

CMD [ "ts-node", "index.ts" ]
CMD [ "ts-node", "src/index.ts" ]

LABEL org.opencontainers.image.source="https://github.com/Antares-Network/CSSC-Bot"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ The bot should become responsive. You can check for errors in the console.
- [Discord.js Docs](https://discord.js.org/#/docs)
- [Discord.js Guide](https://discordjs.guide/)
- [WOKcommands Docs](https://docs.wornoffkeys.com/)
- [AntaresBot Codebase](https://playantares.com/antaresbot)
- [Antares Status Tracking](https://status.playantares.com/)
- [AntaresBot Codebase](https://antaresnetwork.com/antaresbot)
- [Antares Status Tracking](https://status.antaresnetwork.com/)

## Credits

Expand Down
153 changes: 153 additions & 0 deletions __tests__/utils/channels.tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import {
cleanChannelString,
concatCategoryName,
moveChannel,
getCourseName,
getTopic,
} from "../../src/utils/channels";
import { expect, describe, it, beforeEach } from "@jest/globals";
import { Guild, GuildChannel } from "discord.js";
import { IClass } from "../../src/models/classModel";

//cleanChannelString
describe("cleanChannelString", () => {
it("should lowercase the string", () => {
expect(cleanChannelString("ABCD")).toEqual("abcd");
});

it("should remove special characters", () => {
expect(cleanChannelString("a!b@c#d$")).toEqual("abcd");
});

it("should replace whitespace with a hyphen", () => {
expect(cleanChannelString("a b c")).toEqual("a-b-c");
});

it("should remove consecutive hyphens", () => {
expect(cleanChannelString("a--b--c")).toBe("a-b-c");
});

it("should return an empty string for an empty input", () => {
expect(cleanChannelString("")).toBe("");
});

it("cleanChannelString should return an empty string for a string with only special characters", () => {
expect(cleanChannelString("!@#$%^&*")).toBe("");
});

it("should truncate the string to 100 characters", () => {
expect(cleanChannelString("a".repeat(200))).toHaveLength(100);
});
});

describe("getTopic", () => {
const default_string = "This is a test";
let course: IClass = {
TITLE: default_string,
INFO: default_string,
id: default_string,
NAME: default_string,
DUPE: false,
ACTIVE: true,
ROLE_NAME: default_string,
ROLE_ID: default_string,
CHANNEL_ID: default_string,
};
const extra_characters = 3;
beforeEach(() => {
course = {
TITLE: default_string,
INFO: default_string,
id: default_string,
NAME: default_string,
DUPE: false,
ACTIVE: true,
ROLE_NAME: default_string,
ROLE_ID: default_string,
CHANNEL_ID: default_string,
};
});

it("should return a truncated string of the concatenated title and info", () => {
course.TITLE = "Introduction to Mathematics";
expect(getTopic(course)).toHaveLength(
course.TITLE.length + course.INFO.length + extra_characters
);
});

it("should not return a string longer than 1024 characters", () => {
course.TITLE = "a".repeat(600);
course.INFO = "b".repeat(600);
expect(getTopic(course)).toHaveLength(1024);
});

it("should return a string of length 1024 if TITLE is 1025 characters", () => {
course.TITLE = "a".repeat(1025);
course.INFO = "";
expect(getTopic(course)).toHaveLength(1024);
});

it("should return a string of length 1024 if INFO is 1025 characters", () => {
course.TITLE = "";
course.INFO = "b".repeat(1025);
expect(getTopic(course)).toHaveLength(1024);
});
});

// getCourseName
describe("getCourseName", () => {
const default_string = "This is a test";
it("should return the course name if DUPE is false", () => {
const course: IClass = {
id: default_string,
NAME: "Math 101",
TITLE: "Introduction to Mathematics",
INFO: default_string,
DUPE: false,
ACTIVE: true,
ROLE_NAME: default_string,
ROLE_ID: default_string,
CHANNEL_ID: default_string,
};
expect(getCourseName(course)).toBe("Math 101");
});

it("should return the concatenated course name and title if DUPE is true", () => {
const course: IClass = {
id: default_string,
NAME: "Math 101",
TITLE: "Introduction to Mathematics",
INFO: default_string,
DUPE: true,
ACTIVE: true,
ROLE_NAME: default_string,
ROLE_ID: default_string,
CHANNEL_ID: default_string,
};
expect(getCourseName(course)).toBe("Math 101-Introduction to Mathematics");
});
});

//moveChannel
// Can only test pure functionality
describe("moveChannel", () => {
it("should not move the channel if it is already in the specified category", async () => {
// Set up the test so that the channel is already in the specified category
const guild = {} as Guild;
const category_name = "abcd";
const channel = { parent: { name: category_name } } as GuildChannel;
// Ensure that the channel was not moved
expect(await moveChannel(guild, channel, category_name)).toBe(0);
});
});

//concatCategoryName
describe("concatCategoryName", () => {
it("should return the category name if the category number is 0", () => {
expect(concatCategoryName("abcd", 0)).toBe("abcd");
});

it("should return the category name and number if the category number is not 0", () => {
expect(concatCategoryName("abcd", 1)).toBe("abcd 1");
});
});
40 changes: 40 additions & 0 deletions __tests__/utils/roles.tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { expect, describe, it } from "@jest/globals";
import { cleanRoleString } from "../../src/utils/roles";

//cleanRoleString
describe("cleanRoleString", () => {
it("should lowercase the string", () => {
expect(cleanRoleString("ABCD")).toEqual("abcd");
});

it("should remove special characters", () => {
expect(cleanRoleString("a!b@c#d$")).toEqual("abcd");
});

it("should remove newlines", () => {
expect(cleanRoleString("\na\n")).toEqual("a");
});

it("should replace whitespace with a hyphen", () => {
expect(cleanRoleString("a b c")).toEqual("a-b-c");
});

it("should remove consecutive hyphens", () => {
expect(cleanRoleString("a--b--c")).toBe("a-b-c");
});

it("should return an empty string for an empty input", () => {
expect(cleanRoleString("")).toBe("");
});

it("cleanRoleString should return an empty string for a string with only special characters", () => {
expect(cleanRoleString("!@#$%^&*")).toBe("");
});

it("should truncate the string to 100 characters", () => {
expect(cleanRoleString("a".repeat(200))).toHaveLength(100);
});
it("should be able to handle a comboination of everything", () => {
expect(cleanRoleString("a! -- b@c\n#d$e%")).toEqual("a-bcde");
});
});
17 changes: 1 addition & 16 deletions env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,4 @@ MONGODB_URI=
BOT_DEFAULT_PREFIX=
VERSION=
UPTIME_KUMA_MONITOR_DOMAIN=
UPTIME_KUMA_MONITOR_ID=


# Fill out these values with the role id's of the roles you have in your server

Prefrosh=
Freshman=
Sophomore=
Junior=
Senior=
Graduatestudent=
Alumni=
Sileader=
Ta=
Studentemployee=
Professor=
UPTIME_KUMA_MONITOR_ID=
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
Loading