Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 648e497

Browse files
committed
2.0.0
1 parent 29661e1 commit 648e497

File tree

4 files changed

+138
-78
lines changed

4 files changed

+138
-78
lines changed

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

index.js

Lines changed: 132 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,132 @@
1-
require ('dotenv').config()
2-
const Discord = require('discord.js');
3-
const { readdirSync } = require("fs");
4-
const handleEvents = require("./events");
5-
6-
const config = process.env;
7-
const bot = new Discord.Client({disableEveryone: true});
8-
9-
handleEvents(bot);
10-
11-
bot.commands = new Discord.Collection();
12-
bot.aliases = new Discord.Collection();
13-
14-
try
15-
{
16-
let files = readdirSync("./commands/");
17-
let jsfiles = files.filter(f => f.split(".").pop() === "js")
18-
if(jsfiles.length <= 0) {
19-
return console.log("[LOGS] Couldn't Find Commands!");
20-
}
21-
22-
jsfiles.forEach(f => {
23-
let pull = require(`./commands/${f}`);
24-
bot.commands.set(pull.config.name, pull);
25-
pull.config.aliases.forEach(alias => {
26-
bot.aliases.set(alias, pull.config.name)
27-
});
28-
});
29-
30-
bot.on("message", message => {
31-
if(message.author.bot || message.channel.type === "dm") return;
32-
33-
let { content } = message;
34-
let { prefix } = config;
35-
if(!content.startsWith(prefix)) return;
36-
37-
let [ cmd, args ] = content.split(/\s(.+)/);
38-
cmd = cmd.slice(prefix.length);
39-
40-
let commandfile = bot.commands.get(cmd) || bot.commands.get(bot.aliases.get(cmd))
41-
if(commandfile) commandfile.run(bot, message, args)
42-
})
43-
44-
bot.login(process.env.TOKEN);
45-
}
46-
catch(error)
47-
{
48-
console.log("Cannot load command files");
49-
console.log(error);
50-
}
1+
require("dotenv").config();
2+
const config = require("./config/config.json");
3+
const Enmap = require("enmap");
4+
const Discord = require("discord.js");
5+
6+
const client = new Discord.Client({
7+
partials: ["MESSAGE", "USER", "REACTION"],
8+
disableMentions: "everyone"
9+
});
10+
const DisTube = require("distube");
11+
12+
client.config = config;
13+
global.client = client;
14+
client.login(process.env.TOKEN);
15+
global.nowyear = new Date().getFullYear();
16+
global.emojis = require("./config/emoji.json");
17+
18+
const db = require("quick.db");
19+
const { GiveawaysManager } = require("discord-giveaways");
20+
21+
const nz_date_string = new Date().toLocaleString("en-US", {
22+
timeZone: "Asia/Hong_Kong"
23+
});
24+
25+
client.commands = new Discord.Collection();
26+
client.slcommands = new Discord.Collection();
27+
client.aliases = new Discord.Collection();
28+
client.emotes = emojis;
29+
client.colors = client.config.colors;
30+
client.snipes = new Map();
31+
client.mapss = new Map();
32+
client.mapss.set("uptimedate", nz_date_string);
33+
34+
["command", "event", "music"].forEach(x =>
35+
require(`./handlers/${x}.js`)(client)
36+
);
37+
["alwaysOn", "http"].forEach(x => require(`./server/${x}`)());
38+
39+
client.settings = new Enmap({
40+
name: "settings",
41+
fetchAll: false,
42+
autoFetch: true,
43+
cloneLevel: "deep"
44+
});
45+
46+
client.moderationdb = new Enmap("moderation");
47+
48+
client.distube = new DisTube(client, {
49+
leaveOnFinish: true,
50+
leaveOnEmpty: true,
51+
leaveOnStop: true,
52+
youtubeDL: true,
53+
updateYouTubeDL: true,
54+
youtubeCookie:
55+
"GPS=1; YSC=w5dGoHzqQRI; VISITOR_INFO1_LIVE=B4ElBqxSDv4; PREF=tz=Asia.Hong_Kong"
56+
});
57+
58+
if (!db.get("giveaways")) db.set("giveaways", []);
59+
60+
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
61+
async getAllGiveaways() {
62+
return db.get("giveaways");
63+
}
64+
65+
async saveGiveaway(messageID, giveawayData) {
66+
db.push("giveaways", giveawayData);
67+
return true;
68+
}
69+
70+
async editGiveaway(messageID, giveawayData) {
71+
const giveaways = db.get("giveaways");
72+
const newGiveawaysArray = giveaways.filter(
73+
giveaway => giveaway.messageID !== messageID
74+
);
75+
newGiveawaysArray.push(giveawayData);
76+
db.set("giveaways", newGiveawaysArray);
77+
return true;
78+
}
79+
80+
async deleteGiveaway(messageID) {
81+
const newGiveawaysArray = db
82+
.get("giveaways")
83+
.filter(giveaway => giveaway.messageID !== messageID);
84+
db.set("giveaways", newGiveawaysArray);
85+
return true;
86+
}
87+
};
88+
89+
client.giveawaysManager = new GiveawayManagerWithOwnDatabase(client, {
90+
storage: false,
91+
updateCountdownEvery: 10000,
92+
endedGiveawaysLifetime: 30000,
93+
hasGuildMembersIntent: false,
94+
default: {
95+
botsCanWin: false,
96+
exemptPermissions: ["MANAGE_MESSAGES", "ADMINISTRATOR"],
97+
embedColor: "#ff6969",
98+
embedColorEnd: "#505050",
99+
reaction: "🎉"
100+
}
101+
});
102+
103+
client.status = queue =>
104+
`Volume: \`${queue.volume}%\` | Filter: \`${
105+
queue.filter || "Off"
106+
}\` | Loop: \`${
107+
queue.repeatMode
108+
? queue.repeatMode == 2
109+
? "All Queue"
110+
: "This Song"
111+
: "Off"
112+
}\` | Autoplay: \`${queue.autoplay ? "On" : "Off"}\``;
113+
114+
client.ws.on("INTERACTION_CREATE", async interaction => {
115+
if (!client.slcommands.has(interaction.data.name)) return;
116+
try {
117+
client.slcommands.get(interaction.data.name).execute(interaction);
118+
} catch (error) {
119+
console.log(
120+
`Error from command ${interaction.data.name} : ${error.message}`
121+
);
122+
console.log(`${error.stack}\n`);
123+
client.api.interactions(interaction.id, interaction.token).callback.post({
124+
data: {
125+
type: 4,
126+
data: {
127+
content: "Sorry, error occurred when running this command!"
128+
}
129+
}
130+
});
131+
}
132+
});

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"name": "PruneBot",
2+
"name": "Prune Bot",
33
"version": "1.0.0",
44
"main": "shard.js",
5-
"description": "Discord-Multi-Purpose Bot",
5+
"description": "A free open source solution to your server and user managing problems, built from scratch with code organization and quality in mind. Our goal is to cover as many functionalities as possible.",
66
"author": "Mashwishi",
77
"scripts": {
88
"start": "node shard.js",
99
"code-format": "npx prettier --write . && exit 0"
1010
},
1111
"email": "[email protected]",
12-
"url": "https://PruneBot.Mashwishi.tk/",
12+
"url": "https://github.com/mashwishi/PruneBot",
1313
"engines": {
1414
"node": ">=14.0.0"
1515
},
1616
"repository": {
17-
"url": "git+https://github.com/Mashwishi/PruneBot.git"
17+
"url": "git+https://github.com/mashwishi/PruneBot.git"
1818
},
1919
"bugs": {
20-
"url": "https://github.com/Mashwishi/PruneBot/issues"
20+
"url": "https://github.com/mashwishi/PruneBot/issues"
2121
},
22-
"homepage": "https://github.com/Mashwishi/PruneBot#readme",
22+
"homepage": "https://github.com/mashwishi/PruneBot#readme",
2323
"keywords": [],
2424
"license": "MIT",
2525
"dependencies": {

0 commit comments

Comments
 (0)