1
- const Discord = require ( "discord.js" ) ;
1
+ // Discord Library
2
+ const { Client, Collection } = require ( 'discord.js' )
3
+ const client = new Client ( ) ;
4
+
5
+ // fs ffs!
2
6
const fs = require ( "fs" ) ;
3
- const client = new Discord . Client ( ) ;
4
7
const { keep_alive } = require ( "./keep_alive" ) ;
5
- const { Prefix, Token, Color } = require ( "./config.js" ) ;
6
- client . commands = new Discord . Collection ( ) ;
7
- client . aliases = new Discord . Collection ( ) ;
8
- client . db = require ( "quick.db" ) ;
9
8
10
- client . on ( "ready" , async ( ) => {
11
- console . log ( `DVS Tech Bot has Been Deployed!!` ) ;
12
- client . user
13
- . setActivity ( `$help` , { type : "LISTENING" } )
14
- . catch ( error => console . log ( error ) ) ;
15
- } ) ;
9
+ // Parsing Settings
10
+ const JSON5 = require ( 'json5' ) ;
11
+ const settings = JSON5 . parse ( process . env . settings )
16
12
17
- client . on ( "message" , async message => {
18
- if ( message . channel . type === "dm" ) return ;
19
- if ( message . author . bot ) return ;
20
- if ( ! message . guild ) return ;
21
- if ( ! message . member )
22
- message . member = await message . guild . fetchMember ( message ) ;
13
+ // Secret Vars
14
+ const botToken = settings . bot . token ;
15
+ const botPrefix = settings . bot . prefix ;
16
+ const embedColor = settings . embeds . color ;
23
17
24
- if ( message . content . match ( new RegExp ( `^<@!?${ client . user . id } >` ) ) ) {
25
- return message . channel . send ( `Bot Prefix : ${ Prefix } ` ) ;
26
- }
27
- } ) ;
18
+ // Exporting Secrets
19
+ module . exports = {
20
+ token : botToken ,
21
+ Prefix : botPrefix ,
22
+ Color : embedColor
23
+ }
28
24
29
- let modules = [ "fun" , "info" , "moderation" ] ;
25
+ // Collection
26
+ client . commands = new Collection ( ) ;
27
+ client . aliases = new Collection ( ) ;
30
28
31
- modules . forEach ( function ( module ) {
32
- fs . readdir ( `./commands/${ module } ` , function ( err , files ) {
33
- if ( err )
34
- return new Error (
35
- "Missing Folder Of Commands! Example : Commands/<Folder>/<Command>.js"
36
- ) ;
37
- files . forEach ( function ( file ) {
38
- if ( ! file . endsWith ( ".js" ) ) return ;
39
- let command = require ( `./commands/${ module } /${ file } ` ) ;
40
- console . log ( `${ command . name } Command Has Been Loaded - ✅` ) ;
41
- if ( command . name ) client . commands . set ( command . name , command ) ;
42
- if ( command . aliases ) {
43
- command . aliases . forEach ( alias =>
44
- client . aliases . set ( alias , command . name )
45
- ) ;
46
- }
47
- if ( command . aliases . length === 0 ) command . aliases = null ;
48
- } ) ;
49
- } ) ;
29
+ // On Ready
30
+ client . on ( "ready" , ( ) => {
31
+ console . log ( `[!]: The Bot is ready, logged in as ${ client . user . tag } ` ) ;
32
+ client . user . setActivity ( `$help` , { type : "LISTENING" } )
50
33
} ) ;
51
34
35
+ // On Message
52
36
client . on ( "message" , async message => {
53
37
if ( message . channel . type === "dm" ) return ;
54
38
if ( message . author . bot ) return ;
55
39
if ( ! message . guild ) return ;
56
- if ( ! message . member )
40
+ if ( ! message . member ) {
57
41
message . member = await message . guild . fetchMember ( message ) ;
42
+ }
58
43
44
+ if ( message . content . match ( new RegExp ( `^<@!?${ client . user . id } >` ) ) ) {
45
+ return message . channel . send ( `Bot Prefix : ${ Prefix } ` ) ;
46
+ }
47
+ const Prefix = botPrefix ;
59
48
if ( ! message . content . startsWith ( Prefix ) ) return ;
60
49
61
50
const args = message . content
62
51
. slice ( Prefix . length )
63
52
. trim ( )
64
53
. split ( " " ) ;
65
54
const cmd = args . shift ( ) . toLowerCase ( ) ;
66
-
67
55
if ( cmd . length === 0 ) return ;
68
56
69
- let command =
70
- client . commands . get ( cmd ) || client . commands . get ( client . aliases . get ( cmd ) ) ;
57
+ let command = client . commands . get ( cmd ) || client . commands . get ( client . aliases . get ( cmd ) ) ;
71
58
72
59
if ( ! command ) return ;
73
-
74
60
if ( command ) {
75
61
if ( ! message . guild . me . hasPermission ( "ADMINISTRATOR" ) )
76
- return message . channel . send (
77
- "I Don't Have Enough Permission To Use This Or Any Of My Commands | Require : Administrator"
78
- ) ;
62
+ return message . channel . send ( "I Don't Have Enough Permission To Use This Or Any Of My Commands | Require : Administrator" ) ;
79
63
command . run ( client , message , args ) ;
80
64
}
81
65
console . log (
82
66
`User : ${ message . author . tag } (${ message . author . id } ) Server : ${ message . guild . name } (${ message . guild . id } ) Command : ${ command . name } `
83
67
) ;
84
68
} ) ;
85
69
86
- client . login ( Token ) ;
70
+ const modules = [ "fun" , "info" , "moderation" ] ;
71
+
72
+ modules . forEach ( ( module ) => {
73
+ fs . readdir ( `./commands/${ module } ` , ( err , files ) => {
74
+ if ( err )
75
+ return new Error (
76
+ "Missing Folder Of Commands! Example : Commands/<Folder>/<Command>.js"
77
+ ) ;
78
+ files . forEach ( ( file ) => {
79
+ if ( ! file . endsWith ( ".js" ) ) return ;
80
+ let command = require ( `./commands/${ module } /${ file } ` ) ;
81
+ console . log ( `${ command . name } Command Has Been Loaded - ✅` ) ;
82
+ if ( command . name ) client . commands . set ( command . name , command ) ;
83
+ if ( command . aliases ) {
84
+ command . aliases . forEach ( alias =>
85
+ client . aliases . set ( alias , command . name )
86
+ ) ;
87
+ }
88
+ if ( command . aliases . length === 0 ) command . aliases = null ;
89
+ } ) ;
90
+ } ) ;
91
+ } ) ;
92
+
93
+ client . login ( botToken ) . catch ( ( e ) => { console . log ( `the token is invalid!` ) } )
87
94
88
- //Bot Coded by DVS Tech DONOT share WITHOUT credits!!
95
+ /*
96
+ Bot Coded by DVS Tech
97
+ DONOT share WITHOUT credits!!
98
+ */
0 commit comments