-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
52 lines (50 loc) · 2.61 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
const Discord = require('discord.js');
let pageEmbeds = [];
Discord.Message.prototype.replyPages = function(embeds){
let msg = this;
this.channel.send(embeds[0]).then(message => {
message.react('⏪').then(() => {
message.react('⬅').then(() => {
message.react('⏹').then(() => {
message.react('➡').then(() => {
message.react('⏩').then(() => {
pageEmbeds[message.id] = {embeds: embeds, user: msg.author, currentPage: 0};
});
});
});
});
});
});
}
module.exports.createListener = function(client){
client.on('messageReactionAdd', (reaction, user) => {
if(pageEmbeds[reaction.message.id]){
if(pageEmbeds[reaction.message.id].user.id==user.id){
if(reaction.message.reactions.get('⬅').users.find('id', user.id)!=undefined){
if(pageEmbeds[reaction.message.id].currentPage!=0){
pageEmbeds[reaction.message.id].currentPage--;
reaction.message.edit(pageEmbeds[reaction.message.id].embeds[pageEmbeds[reaction.message.id].currentPage]);
}
}
if(reaction.message.reactions.get('➡').users.find('id', user.id)!=undefined){
if(pageEmbeds[reaction.message.id].embeds.length!=pageEmbeds[reaction.message.id].currentPage + 1){
pageEmbeds[reaction.message.id].currentPage++;
reaction.message.edit(pageEmbeds[reaction.message.id].embeds[pageEmbeds[reaction.message.id].currentPage]);
}
}
if(reaction.message.reactions.get('⏹').users.find('id', user.id)!=undefined){
reaction.message.react('🛑')
pageEmbeds[reaction.message.id] = undefined;
}
if(reaction.message.reactions.get('⏪').users.find('id', user.id)!=undefined){
pageEmbeds[reaction.message.id].currentPage = 0;
reaction.message.edit(pageEmbeds[reaction.message.id].embeds[pageEmbeds[reaction.message.id].currentPage]);
}
if(reaction.message.reactions.get('⏩').users.find('id', user.id)!=undefined){
pageEmbeds[reaction.message.id].currentPage = pageEmbeds[reaction.message.id].embeds.length - 1;
reaction.message.edit(pageEmbeds[reaction.message.id].embeds[pageEmbeds[reaction.message.id].currentPage]);
}
}
}
});
}