-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMenuReac.js
More file actions
53 lines (49 loc) · 2.28 KB
/
MenuReac.js
File metadata and controls
53 lines (49 loc) · 2.28 KB
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
// ______ __ __
// / \ | \ | \
//| $$$$$$\| $$ _______ ______ _| $$_ ______ ______ ________
//| $$__| $$| $$ / \| \| $$ \ / \ | \ | \
//| $$ $$| $$| $$$$$$$ \$$$$$$\\$$$$$$ | $$$$$$\ \$$$$$$\ \$$$$$$$$
//| $$$$$$$$| $$| $$ / $$ | $$ __ | $$ \$$/ $$ / $$
//| $$ | $$| $$| $$_____| $$$$$$$ | $$| \| $$ | $$$$$$$ / $$$$_
//| $$ | $$| $$ \$$ \\$$ $$ \$$ $$| $$ \$$ $$| $$ \
// \$$ \$$ \$$ \$$$$$$$ \$$$$$$$ \$$$$ \$$ \$$$$$$$ \$$$$$$$$
//=======================================================================
//● Crée par GalackQSM#0895 le 09 novembre 2020
//● Serveur Discord: https://discord.gg/HPtTfqDdMr
//● Github: https://github.com/GalackQSM/Alcatraz
//=======================================================================
module.exports = class MenuReac {
constructor(channel, member, embed, reactions, timeout = 120000) {
this.channel = channel;
this.memberId = member.id;
this.embed = embed;
this.reactions = reactions;
this.emojis = Object.keys(this.reactions);
this.timeout = timeout;
this.channel.send(this.embed).then(message => {
this.message = message;
this.addReactions();
this.createCollector();
});
}
async addReactions() {
for (const emoji of this.emojis) {
await this.message.react(emoji);
}
}
createCollector() {
const collector = this.message.createReactionCollector((reaction, user) => {
return (this.emojis.includes(reaction.emoji.name) || this.emojis.includes(reaction.emoji.id)) &&
user.id == this.memberId;
}, { time: this.timeout });
collector.on('collect', async reaction => {
let newPage = this.reactions[reaction.emoji.name] || this.reactions[reaction.emoji.id];
if (typeof newPage === 'function') newPage = newPage();
await this.message.edit(newPage);
await reaction.users.remove(this.memberId);
});
collector.on('end', () => {
this.message.reactions.removeAll();
});
}
};