-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
84 lines (70 loc) · 2.35 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
process.on("unhandledRejection", (reason, promise) => {
console.log("Unhandled Rejection at:", promise, "reason:", reason);
// Application specific logging, throwing an error, or other logic here
});
process.on("uncaughtException", (err, origin) => {
console.log(`Caught exception: ${err}\n` + `Exception origin: ${origin}`);
});
require("module-alias/register");
const Discord = require("discord.js");
const client = new Discord.Client();
const Distube = require("distube");
const distube = new Distube(client, {
searchSongs: true,
emitNewSongOnly: true
});
require('discord-buttons')(client);
const dotenv = require('dotenv');
dotenv.config();
const config = require("./config.json");
const prefix = config.prefix;
const commandBase = require("@commands/command-base");
const loadCommands = require("@commands/load-commands.js");
const loadEvents = require("@events/load-events.js")
const topGgApiToken = process.env.TOPGGAPITOKEN;
const token = process.env.BOT_TOKEN;
const Topgg = require(`@top-gg/sdk`);
const api = new Topgg.Api(topGgApiToken);
const {
playSong
} = require("@conf/colors.json")
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
client.once("ready", async () => {
var startTime = new Date();
var startTimeUnix = startTime.getTime();
console.log("Musicon is online!");
console.log(
"Current time: " +
startTime.toLocaleDateString() +
" " +
startTime.toLocaleTimeString() +
" " +
startTimeUnix
);
const guildsSize = client.guilds.cache.size;
client.user.setActivity(
`for ${prefix}help | Currently in ${guildsSize} server${guildsSize == 1 ? "" : "s"}`, {
type: "WATCHING"
}
);
});
client.on("ready", async () => {
commandBase.loadPrefixes(client);
loadCommands(client, distube);
loadEvents(client, distube);
setInterval(() => {
const guildsSize = client.guilds.cache.size;
client.user.setActivity(
`for ${prefix}help | Currently in ${guildsSize} server${guildsSize == 1 ? "" : "s"}`, {
type: "WATCHING"
}
);
}, 60000);
//Only use this if you have your top gg api token
/*setInterval(async () => {
await api.postStats({
serverCount: client.guilds.cache.size,
});
}, 300000);*/
});
client.login(token);