1- const { Collection, Client, Discord} = require ( 'discord.js' )
1+ const {
2+ Collection,
3+ Client,
4+ Discord
5+ } = require ( 'discord.js' )
26const fs = require ( 'fs' )
37const client = new Client ( {
4- disableEveryone : true
8+ disableEveryone : true
59} ) ;
610require ( 'discord-buttons' ) ( client ) ;
711require ( 'dotenv' ) . config ( ) ;
@@ -11,14 +15,16 @@ const mongo = process.env.MONGO
1115const disturn = process . env . DISTURN ;
1216const distoken = process . env . DISTOKEN ;
1317module . exports = client ;
14- if ( disturn === "true" ) {
18+ if ( disturn === "true" ) {
1519 const DB = require ( "disbots.net" ) ;
16- const db = new DB ( distoken , { statsInterval : 4000000 } , client ) ;
20+ const db = new DB ( distoken , {
21+ statsInterval : 4000000
22+ } , client ) ;
1723 db . on ( "postServers" , ( ) => {
18- console . log ( "Server count ✅" ) ;
24+ console . log ( "Server count ✅" ) ;
1925 } ) ;
2026 db . on ( "postShards" , ( ) => {
21- console . log ( "Shards count ✅" ) ;
27+ console . log ( "Shards count ✅" ) ;
2228 } ) ;
2329}
2430const mongoose = require ( 'mongoose' ) ;
@@ -32,131 +38,153 @@ const Timeout = new Collection();
3238const ms = require ( 'ms' )
3339Levels . setURL ( mongo ) ;
3440mongoose . connect ( mongo , {
35- useNewUrlParser : true ,
36- useUnifiedTopology : true ,
37- useFindAndModify : false ,
38- useCreateIndex : true
41+ useNewUrlParser : true ,
42+ useUnifiedTopology : true ,
43+ useFindAndModify : false ,
44+ useCreateIndex : true
3945} ) . then ( console . log ( 'Connected to mongo db!' ) ) ;
4046client . prefix = async function ( message ) {
41- let custom ;
42- const data = await prefixSchema . findOne ( { Guild : message . guild . id } )
43- . catch ( err => console . log ( err ) )
44- if ( data ) {
45- custom = data . Prefix ;
46- } else {
47- custom = prefix ;
48- }
49- return custom ;
47+ let custom ;
48+ const data = await prefixSchema . findOne ( {
49+ Guild : message . guild . id
50+ } )
51+ . catch ( err => console . log ( err ) )
52+ if ( data ) {
53+ custom = data . Prefix ;
54+ } else {
55+ custom = prefix ;
56+ }
57+ return custom ;
5058}
5159client . commands = new Collection ( ) ;
5260client . aliases = new Collection ( ) ;
5361client . categories = fs . readdirSync ( "./commands/" ) ;
5462[ "command" ] . forEach ( handler => {
55- require ( `./handlers/${ handler } ` ) ( client ) ;
63+ require ( `./handlers/${ handler } ` ) ( client ) ;
5664} ) ;
57- client . on ( 'ready' , ( ) => {
58- client . user . setPresence ( { status : 'dnd' , activity : { name : `DiamondGolurk on youtube.com` , type : "WATCHING" } } )
59- console . log ( `${ client . user . username } ✅` )
60- } )
61- client . on ( 'message' , async message => {
62- if ( message . author . bot ) return ;
63- const p = await client . prefix ( message )
64- if ( ! message . content . startsWith ( p ) ) return ;
65- if ( ! message . guild ) return ;
66- if ( ! message . member ) message . member = await message . guild . fetchMember ( message ) ;
67- const args = message . content . slice ( p . length ) . trim ( ) . split ( / + / g) ;
68- const cmd = args . shift ( ) . toLowerCase ( ) ;
69- if ( cmd . length == 0 ) return ;
70- const data = await customcom . findOne ( { Guild : message . guild . id , Command : cmd } ) ;
71- if ( data ) message . channel . send ( data . Response ) ;
72- let command = client . commands . get ( cmd )
73- if ( ! command ) command = client . commands . get ( client . aliases . get ( cmd ) ) ;
74- if ( command ) {
75- if ( ! message . member . permissions . has ( command . userPermission || [ ] ) ) return message . channel . send ( "You do not have permission to use this command!" ) ;
76- if ( ! message . guild . me . permissions . has ( command . botPermission || [ ] ) ) return message . channel . send ( "I do not have permission to use this command!" ) ;
77- const blacklisted = await blacklistserver . findOne ( { Server : message . guild . id } ) ;
78- if ( blacklisted ) return message . reply ( "This server has been blacklisted." )
79- if ( command . cooldown ) {
80- if ( Timeout . has ( `${ command . name } ${ message . author . id } ` ) ) return message . channel . send ( `You are on a \`${ ms ( Timeout . get ( `${ command . name } ${ message . author . id } ` ) - Date . now ( ) , { long : true } ) } \` cooldown.` )
81- command . run ( client , message , args )
82- Timeout . set ( `${ command . name } ${ message . author . id } ` , Date . now ( ) + command . cooldown )
83- setTimeout ( ( ) => {
84- Timeout . delete ( `${ command . name } ${ message . author . id } ` )
85- } , command . cooldown )
86- } else command . run ( client , message , args ) ;
87- }
65+
66+ client . on ( 'message' , async message => {
67+ if ( message . author . bot ) return ;
68+ const p = await client . prefix ( message )
69+ if ( ! message . content . startsWith ( p ) ) return ;
70+ if ( ! message . guild ) return ;
71+ if ( ! message . member ) message . member = await message . guild . fetchMember ( message ) ;
72+ const args = message . content . slice ( p . length ) . trim ( ) . split ( / + / g) ;
73+ const cmd = args . shift ( ) . toLowerCase ( ) ;
74+ if ( cmd . length == 0 ) return ;
75+ const data = await customcom . findOne ( {
76+ Guild : message . guild . id ,
77+ Command : cmd
78+ } ) ;
79+ if ( data ) message . channel . send ( data . Response ) ;
80+ let command = client . commands . get ( cmd )
81+ if ( ! command ) command = client . commands . get ( client . aliases . get ( cmd ) ) ;
82+ if ( command ) {
83+ if ( ! message . member . permissions . has ( command . userPermission || [ ] ) ) return message . channel . send ( "You do not have permission to use this command!" ) ;
84+ if ( ! message . guild . me . permissions . has ( command . botPermission || [ ] ) ) return message . channel . send ( "I do not have permission to use this command!" ) ;
85+ const blacklisted = await blacklistserver . findOne ( {
86+ Server : message . guild . id
87+ } ) ;
88+ if ( blacklisted ) return message . reply ( "This server has been blacklisted." )
89+ if ( command . cooldown ) {
90+ if ( Timeout . has ( `${ command . name } ${ message . author . id } ` ) ) return message . channel . send ( `You are on a \`${ ms ( Timeout . get ( `${ command . name } ${ message . author . id } ` ) - Date . now ( ) , { long : true } ) } \` cooldown.` )
91+ command . run ( client , message , args )
92+ Timeout . set ( `${ command . name } ${ message . author . id } ` , Date . now ( ) + command . cooldown )
93+ setTimeout ( ( ) => {
94+ Timeout . delete ( `${ command . name } ${ message . author . id } ` )
95+ } , command . cooldown )
96+ } else command . run ( client , message , args ) ;
97+ }
8898} ) ;
8999
90100const DisTube = require ( 'distube' ) ;
91- const player = new DisTube ( client , { searchSongs : true , emitNewSongOnly : true , leaveOnFinish : true } ) ;
101+ const player = new DisTube ( client , {
102+ searchSongs : true ,
103+ emitNewSongOnly : true ,
104+ leaveOnFinish : true
105+ } ) ;
92106
93107const status = ( queue ) => `Volume: \`${ queue . volume } %\` | Filter: \`${ queue . filter || "Off" } \` | Loop: \`${ queue . repeatMode ? queue . repeatMode == 2 ? "All Queue" : "This Song" : "Off" } \` | Autoplay: \`${ queue . autoplay ? "On" : "Off" } \`` ;
94108
95109player
96- . on ( "playSong" , ( message , queue , song ) => message . channel . send (
97- `Playing \`${ song . name } \` - \`${ song . formattedDuration } \`\nRequested by: ${ song . user } \n${ status ( queue ) } `
98- ) )
99- . on ( "addSong" , ( message , queue , song ) => message . channel . send (
100- `Added ${ song . name } - \`${ song . formattedDuration } \` to the queue by ${ song . user } `
101- ) )
102- . on ( "playList" , ( message , queue , playlist , song ) => message . channel . send (
103- `Play \`${ playlist . name } \` playlist (${ playlist . songs . length } songs).\nRequested by: ${ song . user } \nNow playing \`${ song . name } \` - \`${ song . formattedDuration } \`\n${ status ( queue ) } `
104- ) )
105- . on ( "addList" , ( message , queue , playlist ) => message . channel . send (
106- `Added \`${ playlist . name } \` playlist (${ playlist . songs . length } songs) to queue\n${ status ( queue ) } `
107- ) )
108- . on ( "searchResult" , ( message , result ) => {
109- let i = 0 ;
110- message . channel . send ( `**Choose an option from below**\n${ result . map ( song => `**${ ++ i } **. ${ song . name } - \`${ song . formattedDuration } \`` ) . join ( "\n" ) } \n*Enter anything else or wait 60 seconds to cancel*` ) ;
111- } )
112- . on ( "searchCancel" , ( message ) => message . channel . send ( `Searching canceled` ) )
113- . on ( "error" , ( message , e ) => {
114- console . error ( e )
115- message . channel . send ( "An error encountered: " + e ) ;
116- } )
117- . on ( "finish" , message => message . channel . send ( "No more song in queue" )
118- )
119- . on ( "empty" , message => message . channel . send ( "Channel is empty. Leaving the channel" )
120- ) ;
110+ . on ( "playSong" , ( message , queue , song ) => message . channel . send (
111+ `Playing \`${ song . name } \` - \`${ song . formattedDuration } \`\nRequested by: ${ song . user } \n${ status ( queue ) } `
112+ ) )
113+ . on ( "addSong" , ( message , queue , song ) => message . channel . send (
114+ `Added ${ song . name } - \`${ song . formattedDuration } \` to the queue by ${ song . user } `
115+ ) )
116+ . on ( "playList" , ( message , queue , playlist , song ) => message . channel . send (
117+ `Play \`${ playlist . name } \` playlist (${ playlist . songs . length } songs).\nRequested by: ${ song . user } \nNow playing \`${ song . name } \` - \`${ song . formattedDuration } \`\n${ status ( queue ) } `
118+ ) )
119+ . on ( "addList" , ( message , queue , playlist ) => message . channel . send (
120+ `Added \`${ playlist . name } \` playlist (${ playlist . songs . length } songs) to queue\n${ status ( queue ) } `
121+ ) )
122+ . on ( "searchResult" , ( message , result ) => {
123+ let i = 0 ;
124+ message . channel . send ( `**Choose an option from below**\n${ result . map ( song => `**${ ++ i } **. ${ song . name } - \`${ song . formattedDuration } \`` ) . join ( "\n" ) } \n*Enter anything else or wait 60 seconds to cancel*` ) ;
125+ } )
126+ . on ( "searchCancel" , ( message ) => message . channel . send ( `Searching canceled` ) )
127+ . on ( "error" , ( message , e ) => {
128+ console . error ( e )
129+ message . channel . send ( "An error encountered: " + e ) ;
130+ } )
131+ . on ( "finish" , message => message . channel . send ( "No more song in queue" ) )
132+ . on ( "empty" , message => message . channel . send ( "Channel is empty. Leaving the channel" ) ) ;
121133
122134Client . player = player ;
123135
124- const { DiscordTogether } = require ( 'discord-together' ) ;
136+ const {
137+ DiscordTogether
138+ } = require ( 'discord-together' ) ;
125139Client . discordTogether = new DiscordTogether ( client ) ;
126140
127141Client . dashboard = new botdash . APIclient ( "3856da55-f3b3-462f-9186-0bf72c9b35a7" ) ;
128142
129143client . bal = ( id , coins ) => new Promise ( async ful => {
130- const data = await eco . findOne ( { id } ) ;
131- if ( ! data ) return ful [ 0 ] ;
144+ const data = await eco . findOne ( {
145+ id
146+ } ) ;
147+ if ( ! data ) return ful [ 0 ] ;
132148 ful ( data . coins ) ;
133149} )
134150
135151client . add = ( id , coins ) => {
136- eco . findOne ( { id } , async ( err , data ) => {
137- if ( err ) throw err ;
138- if ( data ) {
152+ eco . findOne ( {
153+ id
154+ } , async ( err , data ) => {
155+ if ( err ) throw err ;
156+ if ( data ) {
139157 data . coins += coins ;
140158 } else {
141- data = new eco ( { id, coins } ) ;
159+ data = new eco ( {
160+ id,
161+ coins
162+ } ) ;
142163 }
143164 data . save ( ) ;
144165 } )
145166}
146167
147168client . rmv = ( id , coins ) => {
148- eco . findOne ( { id } , async ( err , data ) => {
149- if ( err ) throw err ;
150- if ( data ) {
169+ eco . findOne ( {
170+ id
171+ } , async ( err , data ) => {
172+ if ( err ) throw err ;
173+ if ( data ) {
151174 data . coins -= coins ;
152175 } else {
153- data = new eco ( { id, coins : - coins } ) ;
176+ data = new eco ( {
177+ id,
178+ coins : - coins
179+ } ) ;
154180 }
155181 data . save ( ) ;
156182 } )
157183}
158184
159- const { DiscordUNO } = require ( "discord-uno" ) ;
185+ const {
186+ DiscordUNO
187+ } = require ( "discord-uno" ) ;
160188client . discordUNO = new DiscordUNO ( ) ;
161189
162190client . login ( token )
0 commit comments