@@ -7,7 +7,7 @@ const COMMAND_LEAVE = "leave";
7
7
8
8
// map of course aliases to their actual names
9
9
const course_aliases = {
10
- comp6841 : "comp6841 " ,
10
+ comp6841 : "comp6441 " ,
11
11
comp9044 : "comp2041" ,
12
12
comp3891 : "comp3231" ,
13
13
comp9201 : "comp3231" ,
@@ -91,7 +91,7 @@ module.exports = {
91
91
92
92
const course_with_alias =
93
93
course != input_course
94
- ? `${ course } (same course chat as \` ${ input_course } \` )`
94
+ ? `${ course } (same course chat as ${ input_course } )`
95
95
: `${ course } ` ;
96
96
97
97
if ( ! is_valid && other_courses . test ( course . toLowerCase ( ) ) ) {
@@ -187,12 +187,34 @@ module.exports = {
187
187
} ) ;
188
188
}
189
189
190
+ // First, let's see if there's a role that matches the name of the course
191
+ const role = await interaction . guild . roles . cache . find (
192
+ ( r ) => r . name . toLowerCase ( ) === course . toLowerCase ( ) ,
193
+ ) ;
194
+
195
+ // If there is, let's see if the member already has that role
196
+ if ( role !== undefined ) {
197
+ if ( ! interaction . member . roles . cache . has ( role . id ) ) {
198
+ return await interaction . reply ( {
199
+ content : `❌ | You are not in the course chat for \`${ course } \`.` ,
200
+ ephemeral : true ,
201
+ } ) ;
202
+ }
203
+
204
+ // If they do, let's remove the role from them
205
+ await interaction . member . roles . remove ( role ) ;
206
+ return await interaction . reply ( {
207
+ content : `✅ | Removed you from the chat for \`${ course } \`.` ,
208
+ ephemeral : true ,
209
+ } ) ;
210
+ }
211
+
190
212
// Find a channel with the same name as the course
191
213
const channel = await interaction . guild . channels . cache . find (
192
214
( c ) => c . name . toLowerCase ( ) === course . toLowerCase ( ) ,
193
215
) ;
194
216
195
- // Make sure that the channel exists, and is a text channel
217
+ // Otherwise, make sure that the channel exists, and is a text channel
196
218
if ( channel === undefined ) {
197
219
return await interaction . reply ( {
198
220
content : `❌ | The course chat for \`${ course } \` does not exist.` ,
0 commit comments