-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
73 lines (63 loc) · 2.12 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const Discord = require('discord.js')
const path = require('path')
const {Client} = require('discord.js')
/**
* @async
* @param {Client} client
* @param {String} testOnly
* @param {String} commandsDir
* @param {String} token
* @param {String} eventsDir
* @param {Array} prefix
* @param {Array} guildID
* @param {String} buttonsDir
*/
const sdhandler = async({client , testOnly , commandsDir , token, eventsDir , prefix , guildID , buttonsDir })=> {
let commandsPath = ''
let eventsPath = ''
let buttonsPath = ''
let menusPath = ''
if(!prefix) prefix = ["!"]
if(!client) return console.log('Client object not provided.')
if(commandsDir){
commandsPath = path.join(__dirname , `../../${commandsDir}`)
}
else {
commandsPath = path.join(__dirname , '../../commands')
}
//
if(eventsDir){
eventsPath = path.join(__dirname , `../../${eventsDir}`)
}
else{
eventsPath = path.join(__dirname , `../../events`)
}
if(buttonsDir){
buttonsPath = path.join(__dirname , `../../${buttonsDir}`)
}
else{
buttonsPath = path.join(__dirname , '../../buttons' )
}
if(testOnly){
if(!guildID) return console.log('Please specify the Guild Id.')
}
// Defining all the Discord Collections.
client.slashcommands = new Discord.Collection()
client.commands = new Discord.Collection()
client.events = new Discord.Collection()
client.testOnly = testOnly
client.token = token
client.commandsPath = commandsPath
client.eventsPath = eventsPath
client.prefix = prefix
client.guildID = guildID
client.buttonsPath = buttonsPath
client.buttons = new Discord.Collection()
//Handlers
client.login(client.token)
const handlers = ['event_handler' , 'command_handler' , 'slash_handler' , 'button_handler' , 'menu_handler']
handlers.forEach(handler => {require(`./handlers/${handler}`)(client)})
const listeners = ['messageCreate' , 'interactionCreate' ]
listeners.forEach(listener => {require(`./listeners/${listener}`)(client)})
}
module.exports.sdhandler = sdhandler;