-
Notifications
You must be signed in to change notification settings - Fork 76
/
index.js
84 lines (72 loc) · 2.2 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
76
77
78
79
80
81
82
83
84
const Discord = require("discord.js-selfbot-v13");
const client = new Discord.Client({
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_VOICE_STATES
],
checkUpdate: false,
});
const fs = require('fs');
const Enmap = require('enmap');
const utils = require('./utils');
const { Player } = require("discord-player")
if (!process.env.TOKEN){
try{
const config = require("./config");
global.config = {'token': config.token, 'prefix': config.prefix};
} catch (e){
console.error("No config file found, create it or use environnement variables.");
process.exit(1);
};
} else{
if (!process.env.PREFIX) process.env.PREFIX="$";
global.config = {'token': process.env.TOKEN, 'prefix': process.env.PREFIX};
}
if (!process.env.ALLOWED){
try {global.config.allowed=require("./allowed.json").allowed}
catch (e){
global.config.allowed=[]
}
} else{
global.config.allowed=process.env.ALLOWED
}
client.login(config.token)
utils.log("Logging in...");
/* ----------------------------------------------- */
global.queue = new Map();
client.commands = new Enmap();
client.player = new Player(client, {
ytdlOptions: {
quality: "highestaudio",
highWaterMark: 1 << 25
}
})
/* ----------------------------------------------- */
var loaded = {events: [], commands: []};
var promise = new Promise((resolve) => {
fs.readdir('./events/', (err, files) => {
if (err) return console.error;
files.forEach(file => {
if (!file.endsWith('.js')) return;
const evt = require(`./events/${file}`);
let evtName = file.split('.')[0];
loaded.events.push(evtName)
client.on(evtName, evt.bind(null, client));
});
resolve();
});
});
fs.readdir('./commands/', async (err, files) => {
if (err) return console.error;
files.forEach(file => {
if (!file.endsWith('.js')) return;
let props = require(`./commands/${file}`);
props.names.list.forEach(name => {
client.commands.set(name, props);
})
let cmdName = file.split('.')[0];
loaded.commands.push(cmdName)
});
promise.then(() => {utils.log(`Table of commands and events :\n${utils.showTable(loaded)}`)});
});
/* ----------------------------------------------- */