@@ -2,28 +2,7 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
22const { Permissions } = require ( "discord.js" ) ;
33
44const COMMAND_KICKUNVERIFIED = "kickunverified" ;
5- const COMMAND_MIGRATE = "migratecourses" ;
6- const COMMAND_REMOVECOURSEROLES = "nukeremovecourseroles" ;
7-
8- // yeah i know this code is copy pasted from the other file
9- // but whatever, the migration command is temporary!
10- const is_valid_course = ( course ) => {
11- const reg_comp_course = / ^ c o m p \d { 4 } $ / ;
12- const reg_math_course = / ^ m a t h \d { 4 } $ / ;
13- const reg_binf_course = / ^ b i n f \d { 4 } $ / ;
14- const reg_engg_course = / ^ e n g g \d { 4 } $ / ;
15- const reg_seng_course = / ^ s e n g \d { 4 } $ / ;
16- const reg_desn_course = / ^ d e s n \d { 4 } $ / ;
17-
18- return (
19- reg_comp_course . test ( course . toLowerCase ( ) ) ||
20- reg_math_course . test ( course . toLowerCase ( ) ) ||
21- reg_binf_course . test ( course . toLowerCase ( ) ) ||
22- reg_engg_course . test ( course . toLowerCase ( ) ) ||
23- reg_seng_course . test ( course . toLowerCase ( ) ) ||
24- reg_desn_course . test ( course . toLowerCase ( ) )
25- ) ;
26- } ;
5+ const COMMAND_DROPUSERTABLE = "dropusertable" ;
276
287module . exports = {
298 data : new SlashCommandBuilder ( )
@@ -36,19 +15,8 @@ module.exports = {
3615 )
3716 . addSubcommand ( ( subcommand ) =>
3817 subcommand
39- . setName ( COMMAND_MIGRATE )
40- . setDescription ( "Migrates a course role to permission overwrites." )
41- . addStringOption ( ( option ) =>
42- option
43- . setName ( "course" )
44- . setDescription ( "Course role to remove" )
45- . setRequired ( true ) ,
46- ) ,
47- )
48- . addSubcommand ( ( subcommand ) =>
49- subcommand
50- . setName ( COMMAND_REMOVECOURSEROLES )
51- . setDescription ( "WARNING: Removes course roles from the server." ) ,
18+ . setName ( COMMAND_DROPUSERTABLE )
19+ . setDescription ( "Deletes the user table and reliant tables." ) ,
5220 ) ,
5321 async execute ( interaction ) {
5422 try {
@@ -93,50 +61,11 @@ module.exports = {
9361 } ) ;
9462 } ) ;
9563 return await interaction . reply ( "Removed unverified members." ) ;
96- } else if ( interaction . options . getSubcommand ( ) === COMMAND_MIGRATE ) {
97- const course = interaction . options . getString ( "course" ) ;
98- if ( ! is_valid_course ( course ) ) {
99- return await interaction . reply ( "Error: invalid course." ) ;
100- }
101-
102- const role = await interaction . guild . roles . cache . find (
103- ( course_role ) => course_role . name . toLowerCase ( ) === course . toLowerCase ( ) ,
104- ) ;
105-
106- if ( role === undefined ) {
107- return await interaction . reply ( "Error: no role exists for course " + course ) ;
108- }
109-
110- const channel = await interaction . guild . channels . cache . find (
111- ( role_channel ) => role_channel . name . toLowerCase ( ) === role . name . toLowerCase ( ) ,
112- ) ;
113-
114- if ( channel === undefined ) {
115- return await interaction . reply ( "Error: no channel exists for course " + course ) ;
116- }
117-
118- await interaction . deferReply ( ) ;
119- for ( const member of role . members . values ( ) ) {
120- await channel . permissionOverwrites . create ( member , {
121- VIEW_CHANNEL : true ,
122- } ) ;
123- }
124- return await interaction . editReply (
125- "Migrated course role to permission overwrites." ,
126- ) ;
127- } else if ( interaction . options . getSubcommand ( ) === COMMAND_REMOVECOURSEROLES ) {
128- // get all roles, and find courses which match the regex
129- const course_roles = await interaction . guild . roles . cache . filter ( ( role ) =>
130- is_valid_course ( role . name ) ,
131- ) ;
132-
133- await interaction . deferReply ( ) ;
134-
135- for ( const role of course_roles . values ( ) ) {
136- await role . delete ( ) ;
137- }
64+ } else if ( interaction . options . getSubcommand ( ) === COMMAND_DROPUSERTABLE ) {
65+ const userDB = global . userDB ;
66+ await userDB . drop_table ( ) ;
13867
139- return await interaction . editReply ( "Removed all course roles ." ) ;
68+ return await interaction . editReply ( "Deleted user table ." ) ;
14069 }
14170
14271 return await interaction . reply ( "Error: unknown subcommand." ) ;
0 commit comments