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

Commit 979e6b2

Browse files
committed
1.9.1
Added Prune
1 parent 07f1419 commit 979e6b2

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed

commands/prole.js

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
require ('dotenv').config()
2+
const Discord = require('discord.js');
3+
const usedCommand = new Set();
4+
const config = process.env;
5+
6+
module.exports.run = async (bot, message, args) => {
7+
if(usedCommand.has(message.author.id)){
8+
message.reply("You cannot use " + config.prefix + "prole command beacuse of the cooldown.")
9+
} else {
10+
11+
if(!message.member.hasPermission("ADMINISTRATOR")){
12+
return message.reply("You don't have `ADMINISTRATOR` permission to do that!");
13+
}
14+
let mentionedrole = message.mentions.roles.firstKey()
15+
const withoutPrefix = message.content.slice(config.prefix.length);
16+
const split = withoutPrefix.split(/ +/);
17+
const command = split[0];
18+
const args = split.slice(1);
19+
let id = args[0];
20+
21+
if (!args.length){
22+
return message.channel.send(` ${message.author}, please kindly input a role!`);
23+
}
24+
else if (!id.startsWith('<@&') && id.endsWith('>')) {
25+
return message.channel.send(` ${message.author}, You didn't mention a role!`);
26+
}
27+
28+
29+
const therole = message.guild.roles.cache.find(role => role.id == mentionedrole);
30+
var memberscount = message.guild.roles.cache.get(mentionedrole).members.size;
31+
32+
const ListEmbed = new Discord.MessageEmbed()
33+
.setTitle('Prune Bot | Total of '+ memberscount +' User(s)')
34+
.setDescription(`Users that has ${therole} role: \n` + getUsers(page))
35+
.setAuthor('Join our Discord Server', 'https://i.imgur.com/hKeHeEy.gif', 'https://discord.io/LIMYAW')
36+
.setThumbnail('https://i.imgur.com/ypxq7B9.png')
37+
.setColor('#b491c8')
38+
.setFooter('| ◀️ Back | ▶️ Next | 👍 Confirm | 👎 Cancel', 'https://i.imgur.com/DxWDaGv.png');
39+
var listMsg = await message.channel.send(ListEmbed);
40+
var page = parseInt(args[0]);
41+
if (!page) {
42+
page = 1;
43+
};
44+
await listMsg.react("◀️");
45+
await listMsg.react("▶️");
46+
await listMsg.react("👍");
47+
await listMsg.react("👎");
48+
const filter = (reaction, user) => ["◀️", "▶️", "👍","👎"].includes(reaction.emoji.name) && user.id === message.author.id;
49+
const collector = listMsg.createReactionCollector(filter, {
50+
time: 120000
51+
});
52+
collector.on('collect', (reaction, user) => {
53+
reaction.emoji.reaction.users.remove(user.id);
54+
switch (reaction.emoji.name) {
55+
case "◀️":
56+
--page;
57+
if (page < 1) {
58+
page = 1;
59+
};
60+
const newlistMsga = new Discord.MessageEmbed()
61+
.setTitle('Prune Bot | Total of '+ memberscount +' User(s)')
62+
.setDescription(`Users that has ${therole} role: \n` + getUsers(page))
63+
.setAuthor('Join our Discord Server', 'https://i.imgur.com/hKeHeEy.gif', 'https://discord.io/LIMYAW')
64+
.setThumbnail('https://i.imgur.com/ypxq7B9.png')
65+
.setColor('#b491c8')
66+
.setFooter('| ◀️ Back | ▶️ Next | 👍 Confirm | 👎 Cancel', 'https://i.imgur.com/DxWDaGv.png');
67+
listMsg.edit(newlistMsga);
68+
break;
69+
case "▶️":
70+
71+
++page;
72+
const newlistMsgb = new Discord.MessageEmbed()
73+
.setTitle('Prune Bot | Total of '+ memberscount +' User(s)')
74+
.setDescription(`Users that has ${therole} role: \n` + getUsers(page))
75+
.setAuthor('Join our Discord Server', 'https://i.imgur.com/hKeHeEy.gif', 'https://discord.io/LIMYAW')
76+
.setThumbnail('https://i.imgur.com/ypxq7B9.png')
77+
.setColor('#b491c8')
78+
.setFooter('| ◀️ Back | ▶️ Next | 👍 Confirm | 👎 Cancel', 'https://i.imgur.com/DxWDaGv.png');
79+
listMsg.edit(newlistMsgb);
80+
break;
81+
case "👍":
82+
83+
guild.members.prune({ days: 0, roles: [mentionedrole] })
84+
.then(pruned => console.log(`I just pruned ${pruned} people!`))
85+
.catch(console.error);
86+
87+
const ukicked = new Discord.MessageEmbed()
88+
.setTitle('Prune Bot | Total of '+ memberscount +' User(s)')
89+
.setDescription(`Users that has ${therole} role.`)
90+
.setAuthor('Join our Discord Server', 'https://i.imgur.com/hKeHeEy.gif', 'https://discord.io/LIMYAW')
91+
.setThumbnail('https://i.imgur.com/ypxq7B9.png')
92+
.setColor('#b491c8')
93+
.addFields(
94+
{ name: 'Operation Successful', value: `I just pruned ${pruned} user(s)!`}
95+
)
96+
.setFooter('PruneBot is created by Mashwishi', 'https://i.imgur.com/DxWDaGv.png');
97+
98+
listMsg.reactions.removeAll();
99+
listMsg.edit(ukicked);
100+
101+
break;
102+
case "👎":
103+
const cancel = new Discord.MessageEmbed()
104+
.setTitle('Prune Bot | Total of '+ memberscount +' User(s)')
105+
.setDescription(`Users that has ${therole} role.`)
106+
.setAuthor('Join our Discord Server', 'https://i.imgur.com/hKeHeEy.gif', 'https://discord.io/LIMYAW')
107+
.setThumbnail('https://i.imgur.com/ypxq7B9.png')
108+
.setColor('#b491c8')
109+
.addFields(
110+
{ name: 'Operation Cancelled', value: "No users has been kicked."}
111+
)
112+
.setFooter('PruneBot is created by Mashwishi', 'https://i.imgur.com/DxWDaGv.png');
113+
114+
listMsg.reactions.removeAll();
115+
listMsg.edit(cancel);
116+
break;
117+
};
118+
});
119+
collector.on('end', collected => {
120+
121+
const done = new Discord.MessageEmbed()
122+
.setTitle('Prune Bot | Total of '+ memberscount +' User(s)')
123+
.setDescription(`Users that has ${therole} role.`)
124+
.setAuthor('Join our Discord Server', 'https://i.imgur.com/hKeHeEy.gif', 'https://discord.io/LIMYAW')
125+
.setThumbnail('https://i.imgur.com/ypxq7B9.png')
126+
.setColor('#b491c8')
127+
.addFields(
128+
{ name: 'Reaction Timeout', value: "I'm done looking for reactions on the message!"}
129+
)
130+
.setFooter('PruneBot is created by Mashwishi', 'https://i.imgur.com/DxWDaGv.png');
131+
132+
listMsg.reactions.removeAll();
133+
listMsg.edit(done);
134+
});
135+
function getUsers(n) {
136+
const list = message.guild.roles.cache.get(mentionedrole).members.map(m => m.user.tag);
137+
138+
var pageNum = (n * 10) - 10;
139+
if (!pageNum) {
140+
pageNum = 0;
141+
};
142+
return list.slice(pageNum, pageNum + 9).join("\n");
143+
};
144+
145+
146+
usedCommand.add(message.author.id);
147+
setTimeout(() => {
148+
usedCommand.delete(message.author.id);
149+
}, 5000);
150+
}
151+
}
152+
153+
module.exports.config = {
154+
name: "prole",
155+
description: "",
156+
usage: "?prole",
157+
accessableby: "Admins",
158+
aliases: []
159+
}

0 commit comments

Comments
 (0)