This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
132 lines (114 loc) · 3.34 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const config = require("./config/config.json");
const Enmap = require("enmap");
const {Collection, Client} = require("discord.js");
const client = new Client({
partials: ["MESSAGE", "USER", "REACTION"],
disableMentions: "everyone"
});
const DisTube = require("distube");
client.config = config;
global.client = client;
global.nowyear = new Date().getFullYear();
global.emojis = require("./config/emoji.json");
const db = require("quick.db");
const { GiveawaysManager } = require("discord-giveaways");
const nz_date_string = new Date().toLocaleString("en-US", {
timeZone: "America/New_York"
});
client.commands = new Collection();
client.slcommands = new Collection();
client.aliases = new Collection();
client.emotes = emojis;
client.colors = client.config.colors;
client.snipes = new Collection();
client.mapss = new Collection();
client.mapss.set("uptimedate", nz_date_string);
["command", "event", "music"].forEach(x =>
require(`./handlers/${x}.js`)(client)
);
["alwaysOn", "http",].forEach(x => require(`./server/${x}`)());
client.settings = new Enmap({
name: "settings",
fetchAll: false,
autoFetch: true,
cloneLevel: "deep"
});
client.moderationdb = new Enmap("moderation");
client.distube = new DisTube(client, {
leaveOnFinish: true,
leaveOnEmpty: true,
leaveOnStop: true,
youtubeDL: true,
updateYouTubeDL: true,
youtubeCookie:
"GPS=1; YSC=w5dGoHzqQRI; VISITOR_INFO1_LIVE=B4ElBqxSDv4; PREF=tz=America/New_York"
});
if (!db.get("giveaways")) db.set("giveaways", []);
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
async getAllGiveaways() {
return db.get("giveaways");
}
async saveGiveaway(messageID, giveawayData) {
db.push("giveaways", giveawayData);
return true;
}
async editGiveaway(messageID, giveawayData) {
const giveaways = db.get("giveaways");
const newGiveawaysArray = giveaways.filter(
giveaway => giveaway.messageID !== messageID
);
newGiveawaysArray.push(giveawayData);
db.set("giveaways", newGiveawaysArray);
return true;
}
async deleteGiveaway(messageID) {
const newGiveawaysArray = db
.get("giveaways")
.filter(giveaway => giveaway.messageID !== messageID);
db.set("giveaways", newGiveawaysArray);
return true;
}
};
client.giveawaysManager = new GiveawayManagerWithOwnDatabase(client, {
storage: false,
updateCountdownEvery: 10000,
endedGiveawaysLifetime: 30000,
hasGuildMembersIntent: false,
default: {
botsCanWin: false,
exemptPermissions: ["MANAGE_MESSAGES", "ADMINISTRATOR"],
embedColor: "#ff6969",
embedColorEnd: "#505050",
reaction: "🎉"
}
});
client.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"}\``;
client.ws.on("INTERACTION_CREATE", async interaction => {
if (!client.slcommands.has(interaction.data.name)) return;
try {
client.slcommands.get(interaction.data.name).execute(interaction);
} catch (error) {
console.log(
`Error from command ${interaction.data.name} : ${error.message}`
);
console.log(`${error.stack}\n`);
client.api.interactions(interaction.id, interaction.token).callback.post({
data: {
type: 4,
data: {
content: "Sorry, error occurred when running this command!"
}
}
});
}
});
client.login(process.env.TOKEN);