-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
75 lines (51 loc) · 2.29 KB
/
index.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
73
74
75
const discord = require('discord.js');
const config = require('./config.json')
const fs = require('fs');
const discordModals = require('discord-modals')
const Client = new discord.Client({
intents: [discord.Intents.FLAGS.GUILDS, discord.Intents.FLAGS.GUILD_MESSAGES, discord.Intents.FLAGS.DIRECT_MESSAGES, discord.Intents.FLAGS.GUILD_INTEGRATIONS, discord.Intents.FLAGS.GUILD_MEMBERS, discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS],
allowedMentions: { parse: ['users', 'roles'], repliedUser: true }
});
Client.commands = new discord.Collection();
Client.aliases = new discord.Collection();
Client.premium = new discord.Collection();
Client.events = new discord.Collection();
Client.SlachCmds = new discord.Collection();
module.exports.Client = Client
discordModals(Client);
// command Handler
fs.readdirSync('./commands/').forEach(dir => {
fs.readdir(`./commands/${dir}`, (err, files) => {
var jsFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
if (jsFiles.length <= 0) return console.log('Kan ikke finde nogen kommandoer!');
jsFiles.forEach(file => {
var fileget = require(`./commands/${file}`);
console.log(`File ${file} blev loaded`)
try{
Client.commands.set(fileget.help.name, fileget);
fileget.help.aliases.forEach(alias => {
Client.aliases.set(alias, fileget.help.name);
})
}catch (err) {
return console.log(err)
}
})
})
})
// event handler
fs.readdirSync('./events/').forEach(dir => {
fs.readdir(`./events/${dir}`, (err, files) => {
var jsFiles = fs.readdirSync('./events/').filter(file => file.endsWith('.js'));
if (jsFiles.length <= 0) return console.log('Kan ikke finde nogen Events!');
jsFiles.forEach(file => {
const eventget = require(`./events/${file}`);
console.log(`File ${file} blev loaded`)
try{
Client.events.set(eventget.name, eventget);
}catch (err) {
return console.log(err)
}
})
})
})
Client.login(config.Token)