@@ -8,55 +8,135 @@ module.exports.run = async (bot, message, args) => {
88 message . reply ( "You cannot use " + config . prefix + "knorole command beacuse of the cooldown." )
99 } else {
1010 if ( message . content . toLowerCase ( ) . startsWith ( config . prefix + "knorole" ) ) {
11- //check if no perm
11+
1212 if ( ! message . member . hasPermission ( "ADMINISTRATOR" ) ) {
1313 return message . reply ( "You don't have `ADMINISTRATOR` permission to do that!" ) ;
1414 }
15- //count members will be kicked
15+
1616 var memberscount = message . guild . members . cache . filter ( member => member . roles . cache . array ( ) . length < 2 ) . size ;
1717
1818 if ( memberscount == 0 ) {
1919 message . reply ( 'Looks like everyone has a role already.' )
2020 }
2121 else {
22+ const ListEmbed = new Discord . MessageEmbed ( )
23+ . setTitle ( 'Prune Bot | Total of ' + memberscount + ' User(s)' )
24+ . setDescription ( `Users that has no role: \n` + getUsers ( page ) )
25+ . setAuthor ( 'Join our Discord Server' , 'https://i.imgur.com/hKeHeEy.gif' , 'https://discord.io/LIMYAW' )
26+ . setThumbnail ( 'https://i.imgur.com/ypxq7B9.png' )
27+ . setColor ( '#b491c8' )
28+ . setFooter ( '| ◀️ Back | ▶️ Next | 👍 Confirm | 👎 Cancel' , 'https://i.imgur.com/DxWDaGv.png' ) ;
29+ var listMsg = await message . channel . send ( ListEmbed ) ;
30+ var page = parseInt ( args [ 0 ] ) ;
31+ if ( ! page ) {
32+ page = 1 ;
33+ } ;
34+ await listMsg . react ( "◀️" ) ;
35+ await listMsg . react ( "▶️" ) ;
36+ await listMsg . react ( "👍" ) ;
37+ await listMsg . react ( "👎" ) ;
38+ const filter = ( reaction , user ) => [ "◀️" , "▶️" , "👍" , "👎" ] . includes ( reaction . emoji . name ) && user . id === message . author . id ;
39+ const collector = listMsg . createReactionCollector ( filter , {
40+ time : 120000
41+ } ) ;
42+ collector . on ( 'collect' , ( reaction , user ) => {
43+ reaction . emoji . reaction . users . remove ( user . id ) ;
44+ switch ( reaction . emoji . name ) {
45+ case "◀️" :
46+ -- page ;
47+ if ( page < 1 ) {
48+ page = 1 ;
49+ } ;
50+ const newlistMsga = new Discord . MessageEmbed ( )
51+ . setTitle ( 'Prune Bot | Total of ' + memberscount + ' User(s)' )
52+ . setDescription ( `Users that has no role: \n` + getUsers ( page ) )
53+ . setAuthor ( 'Join our Discord Server' , 'https://i.imgur.com/hKeHeEy.gif' , 'https://discord.io/LIMYAW' )
54+ . setThumbnail ( 'https://i.imgur.com/ypxq7B9.png' )
55+ . setColor ( '#b491c8' )
56+ . setFooter ( '| ◀️ Back | ▶️ Next | 👍 Confirm | 👎 Cancel' , 'https://i.imgur.com/DxWDaGv.png' ) ;
57+ listMsg . edit ( newlistMsga ) ;
58+ break ;
59+ case "▶️" :
60+
61+ ++ page ;
62+ const newlistMsgb = new Discord . MessageEmbed ( )
63+ . setTitle ( 'Prune Bot | Total of ' + memberscount + ' User(s)' )
64+ . setDescription ( `Users that has no role: \n` + getUsers ( page ) )
65+ . setAuthor ( 'Join our Discord Server' , 'https://i.imgur.com/hKeHeEy.gif' , 'https://discord.io/LIMYAW' )
66+ . setThumbnail ( 'https://i.imgur.com/ypxq7B9.png' )
67+ . setColor ( '#b491c8' )
68+ . setFooter ( '| ◀️ Back | ▶️ Next | 👍 Confirm | 👎 Cancel' , 'https://i.imgur.com/DxWDaGv.png' ) ;
69+ listMsg . edit ( newlistMsgb ) ;
70+ break ;
71+ case "👍" :
72+ const ukicked = new Discord . MessageEmbed ( )
73+ . setTitle ( 'Prune Bot | Total of ' + memberscount + ' User(s)' )
74+ . setDescription ( `Users that has no role.` )
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+ . addFields (
79+ { name : 'Operation Successful' , value : memberscount + " user(s) has been kicked." }
80+ )
81+ . setFooter ( 'PruneBot is created by Mashwishi' , 'https://i.imgur.com/DxWDaGv.png' ) ;
82+ let members = message . guild . members . cache . filter ( member => member . roles . cache . array ( ) . length < 2 )
83+ members . forEach ( m => {
84+ m . kick ( )
85+ . catch ( console . error ) ;
86+ } ) ;
87+ listMsg . reactions . removeAll ( ) ;
88+ listMsg . edit ( ukicked ) ;
89+ break ;
90+ case "👎" :
91+ const cancel = new Discord . MessageEmbed ( )
92+ . setTitle ( 'Prune Bot | Total of ' + memberscount + ' User(s)' )
93+ . setDescription ( `Users that has no role.` )
94+ . setAuthor ( 'Join our Discord Server' , 'https://i.imgur.com/hKeHeEy.gif' , 'https://discord.io/LIMYAW' )
95+ . setThumbnail ( 'https://i.imgur.com/ypxq7B9.png' )
96+ . setColor ( '#b491c8' )
97+ . addFields (
98+ { name : 'Operation Cancelled' , value : "No users has been kicked." }
99+ )
100+ . setFooter ( 'PruneBot is created by Mashwishi' , 'https://i.imgur.com/DxWDaGv.png' ) ;
101+
102+ listMsg . reactions . removeAll ( ) ;
103+ listMsg . edit ( cancel ) ;
104+ break ;
105+ } ;
106+ } ) ;
107+ collector . on ( 'end' , collected => {
108+
109+ const done = new Discord . MessageEmbed ( )
110+ . setTitle ( 'Prune Bot | Total of ' + memberscount + ' User(s)' )
111+ . setDescription ( `Users that has no role.` )
112+ . setAuthor ( 'Join our Discord Server' , 'https://i.imgur.com/hKeHeEy.gif' , 'https://discord.io/LIMYAW' )
113+ . setThumbnail ( 'https://i.imgur.com/ypxq7B9.png' )
114+ . setColor ( '#b491c8' )
115+ . addFields (
116+ { name : 'Reaction Timeout' , value : "I'm done looking for reactions on the message!" }
117+ )
118+ . setFooter ( 'PruneBot is created by Mashwishi' , 'https://i.imgur.com/DxWDaGv.png' ) ;
119+ //return
120+ listMsg . reactions . removeAll ( ) ;
121+ listMsg . edit ( done ) ;
122+ } ) ;
123+ function getUsers ( n ) {
124+ const list = message . guild . members . cache . filter ( member => member . roles . cache . array ( ) . length < 2 ) . map ( member => member . user . tag ) ;
125+ var pageNum = ( n * 10 ) - 10 ;
126+ if ( ! pageNum ) {
127+ pageNum = 0 ;
128+ } ;
129+ return list . slice ( pageNum , pageNum + 9 ) . join ( "\n" ) ;
130+ } ;
131+
132+
22133
23- //const ListEmbed = new Discord.MessageEmbed()
24- // .setTitle(`Prune Bot | Users`)
25- //.setDescription(`The bot will kick (`+ memberscount +`) users without a role.`)
26- // .setColor('#b491c8')
27- // .addFields(
28- // { name: 'Users:', value: message.guild.members.cache.filter(member => member.roles.cache.array().length < 2).map(member => member.user.tag).join('\n') },)
29- // .setFooter('PruneBot is created by Mashwishi', 'https://i.imgur.com/DxWDaGv.png');
30- // message.channel.send(ListEmbed);
31- message . reply ( 'The bot will kick (' + memberscount + ') users without a role.\n' + 'Confirm with a thumb up or deny with a thumb down.' )
32- message . react ( '👍' ) . then ( r => {
33- message . react ( '👎' ) ;
34- } ) ;
35- // confirmation of the task
36- message . awaitReactions ( ( reaction , user ) => user . id == message . author . id && ( reaction . emoji . name == '👍' || reaction . emoji . name == '👎' ) ,
37- { max : 1 , time : 30000 } ) . then ( collected => {
38- if ( collected . first ( ) . emoji . name == '👍' ) {
39- let members = message . guild . members . cache . filter ( member => member . roles . cache . array ( ) . length < 2 )
40- members . forEach ( m => {
41- m . kick ( )
42- . catch ( console . error ) ;
43- } ) ;
44- message . reply ( 'Done! (' + memberscount + ') users without roles has been kicked.' ) ;
45- message . reactions . removeAll ( ) . catch ( error => console . error ( 'Failed to clear reactions: ' , error ) ) ;
46- }
47- else
48- message . reply ( 'Operation canceled.' ) ;
49- message . reactions . removeAll ( ) . catch ( error => console . error ( 'Failed to clear reactions: ' , error ) ) ;
50- } ) . catch ( ( ) => {
51- message . reply ( 'No reaction after 30 seconds, operation canceled' ) ;
52- message . reactions . removeAll ( ) . catch ( error => console . error ( 'Failed to clear reactions: ' , error ) ) ;
53- } ) ;
54134 }
55135 }
56136 usedCommand . add ( message . author . id ) ;
57137 setTimeout ( ( ) => {
58138 usedCommand . delete ( message . author . id ) ;
59- } , 5000 ) ; //You can set the ammount of the cooldown here! Its Formated to Miliseconds 5000 = 5secs.
139+ } , 5000 ) ;
60140 }
61141}
62142
0 commit comments