1
- const Discord = require ( ' discord.js' ) ;
1
+ const Discord = require ( " discord.js" ) ;
2
2
const client = new Discord . Client ( ) ;
3
- const prefix = ' !imp' ;
4
- const mongoose = require ( ' mongoose' ) ;
5
- require ( ' dotenv' ) . config ( ) ;
3
+ const prefix = " !imp" ;
4
+ const mongoose = require ( " mongoose" ) ;
5
+ require ( " dotenv" ) . config ( ) ;
6
6
7
7
// Modules
8
- const postCode = require ( ' ./modules/postCode' ) ;
9
- const saveMessages = require ( ' ./modules/saveMessages' ) ;
10
- const getCode = require ( ' ./modules/getCode' ) ;
11
- const setApiToken = require ( ' ./modules/setApiToken' ) ;
12
- const help = require ( ' ./modules/help' ) ;
8
+ const postCode = require ( " ./modules/postCode" ) ;
9
+ const saveMessages = require ( " ./modules/saveMessages" ) ;
10
+ const getCode = require ( " ./modules/getCode" ) ;
11
+ const setApiToken = require ( " ./modules/setApiToken" ) ;
12
+ const help = require ( " ./modules/help" ) ;
13
13
14
14
// Utilities
15
- const throwError = require ( ' ./utils/throwError' ) ;
15
+ const throwError = require ( " ./utils/throwError" ) ;
16
16
17
- client . on ( 'ready' , ( ) => {
18
- client . user . setActivity ( '!imp help | https://imperialb.in/' , { type : 'PLAYING' } ) ;
19
- console . log ( 'READY' ) ;
20
- mongoose . connect ( `mongodb+srv://${ process . env . DB_NAME } :${ process . env . DB_PASS } @discordusers.hy2f3.mongodb.net/users?retryWrites=true&w=majority` , { useNewUrlParser : true , useUnifiedTopology : true } , ( err ) => {
21
- if ( err ) return console . log ( err ) ;
22
- console . log ( 'CONNECTED DATABASE' ) ;
23
- } )
24
- } )
17
+ client . on ( "ready" , ( ) => {
18
+ client . user . setActivity ( "!imp help | https://imperialb.in/" , {
19
+ type : "PLAYING" ,
20
+ } ) ;
21
+ console . log ( "READY" ) ;
22
+ mongoose . connect (
23
+ process . env . DB_URI ,
24
+ { useNewUrlParser : true , useUnifiedTopology : true } ,
25
+ ( err ) => {
26
+ if ( err ) return console . log ( err ) ;
27
+ console . log ( "CONNECTED DATABASE" ) ;
28
+ }
29
+ ) ;
30
+ } ) ;
25
31
26
- client . on ( ' message' , async msg => {
27
- if ( msg . channel . type == 'dm' && ! msg . author . bot ) setApiToken ( msg , client ) ;
32
+ client . on ( " message" , async ( msg ) => {
33
+ if ( msg . channel . type == "dm" && ! msg . author . bot ) setApiToken ( msg , client ) ;
28
34
if ( msg . author . bot ) return ;
29
35
if ( msg . content . indexOf ( prefix ) !== 0 ) return ;
30
36
const command = msg . content
@@ -34,32 +40,43 @@ client.on('message', async msg => {
34
40
. shift ( )
35
41
. toLowerCase ( ) ;
36
42
switch ( true ) {
37
- case ( command === ' help' || command === 'h' ) :
43
+ case command === " help" || command === "h" :
38
44
help ( msg ) ;
39
45
break ;
40
- case ( command === 'paste' || command === 'postcode' || command === 'post' || command === 'p' ) :
46
+ case command === "paste" ||
47
+ command === "postcode" ||
48
+ command === "post" ||
49
+ command === "p" :
41
50
postCode ( msg ) ;
42
51
break ;
43
- case ( command === 'save' || command === 'savemessages' || command === 'savemessages' || command === 'sm' ) :
52
+ case command === "save" ||
53
+ command === "savemessages" ||
54
+ command === "savemessages" ||
55
+ command === "sm" :
44
56
saveMessages ( msg ) ;
45
57
break ;
46
- case ( command === 'getcode' || command === 'get' || command === 'code' || command === 'g' ) :
58
+ case command === "getcode" ||
59
+ command === "get" ||
60
+ command === "code" ||
61
+ command === "g" :
47
62
getCode ( msg ) ;
48
63
break ;
49
- case ( command === 'setapi' || command === 'setapitoken' || command === 'api' || command === 'setup' ) :
64
+ case command === "setapi" ||
65
+ command === "setapitoken" ||
66
+ command === "api" ||
67
+ command === "setup" :
50
68
setApiToken ( msg ) ;
51
69
break ;
52
70
default :
53
- throwError ( msg , ' Unknown command!' )
71
+ throwError ( msg , " Unknown command!" ) ;
54
72
break ;
55
73
}
56
- } )
74
+ } ) ;
57
75
58
-
59
- if ( process . env . ENVIRONMENT === 'DEVELOPMENT' ) {
60
- client . login ( process . env . BOT_TOKEN_DEV )
61
- console . log ( 'DEV TOKEN BEING USED!' )
76
+ if ( process . env . ENVIRONMENT === "DEVELOPMENT" ) {
77
+ client . login ( process . env . BOT_TOKEN_DEV ) ;
78
+ console . log ( "DEV TOKEN BEING USED!" ) ;
62
79
} else {
63
- client . login ( process . env . BOT_TOKEN )
64
- console . log ( ' PROD TOKEN BEING USED!' )
65
- }
80
+ client . login ( process . env . BOT_TOKEN ) ;
81
+ console . log ( " PROD TOKEN BEING USED!" ) ;
82
+ }
0 commit comments