@@ -15,23 +15,27 @@ fs.readdirSync('./events').filter(file => file.endsWith('.js')).forEach(async (f
15
15
// Start the bot
16
16
client . login ( process . env . TOKEN )
17
17
18
- // start the API
19
- const app = express ( )
20
- const PORT = process . env . EXPRESS_PORT || 3001
21
-
22
- app . put ( '/users/:id/roles' , async ( req , res ) => {
23
- const { id } = req . params
24
- const { remove } = req . query
25
- await updateRoles ( client , id , null , remove === 'true' )
26
-
27
- res . status ( 200 ) . send ( )
28
- } )
29
-
30
- app . get ( '/guilds' , async ( req , res ) => {
31
- const guilds = client . guilds . cache
32
- res . status ( 200 ) . json ( guilds )
33
- } )
34
-
35
- app . listen ( PORT , ( ) => {
36
- console . log ( `🐉 API server is running on port ${ PORT } ` )
37
- } )
18
+ try {
19
+ // start the API
20
+ const app = express ( )
21
+ const PORT = process . env . EXPRESS_PORT || 3001
22
+
23
+ app . put ( '/users/:id/roles' , async ( req , res ) => {
24
+ const { id } = req . params
25
+ const { remove } = req . query
26
+ await updateRoles ( client , id , null , remove === 'true' )
27
+
28
+ res . status ( 200 ) . send ( )
29
+ } )
30
+
31
+ app . get ( '/guilds' , async ( req , res ) => {
32
+ const guilds = client . guilds . cache
33
+ res . status ( 200 ) . json ( guilds )
34
+ } )
35
+
36
+ app . listen ( PORT , ( ) => {
37
+ console . log ( `🐉 API server is running on port ${ PORT } ` )
38
+ } )
39
+ } catch ( error ) {
40
+ console . error ( 'Failed to start the API server:' , error )
41
+ }
0 commit comments