Skip to content

Commit

Permalink
Help command update
Browse files Browse the repository at this point in the history
Changed help command to use message collector alongside emoji collector for ease of access (emojis were reacting too slowly and were susceptible to bugs).
  • Loading branch information
Ayaan-Govil authored Dec 31, 2020
1 parent 793ab54 commit 20d8d50
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions commands/help_embeds/generate_help.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
// const Discord = require('discord.js');
const generateHelp = (message, client, generateEmbed, commandAmount) => {
message.reactions.removeAll();
message.reactions.removeAll().catch(err => console.log(err));

var currentIndex = 0;
let currentIndex = 0;
message.edit(generateEmbed(currentIndex)).then(message => {
let emojiArray = ['⬅️', '➡️', '⏮'];
if (commandAmount > 1) {
for (i = 0; i < emojiArray.length; i++) {
message.react(emojiArray[i]);
message.react(emojiArray[i]).catch(err => console.log(err));
}
} else message.react('⏮');
} else message.react('⏮').catch(err => console.log(err));

const filter = (reaction, user) => {
return (emojiArray.includes(reaction.emoji.name)) && user.id != message.author.id;
};

const collector = message.createReactionCollector(filter, { time: 180000 });
const collector = message.createReactionCollector(filter, { time: 120000 });

collector.on('collect', (reaction, user) => {

if (reaction.emoji.name === '➡️') {
if (currentIndex < commandAmount - 1) {
currentIndex++;
message.edit(generateEmbed(currentIndex));
message.edit(generateEmbed(currentIndex)).catch(err => console.log(err));
}
} else if (reaction.emoji.name === '⬅️') {
if (currentIndex > 0) {
currentIndex--;
message.edit(generateEmbed(currentIndex));
message.edit(generateEmbed(currentIndex)).catch(err => console.log(err));
}
} else {
client.commands.get('help').execute(message, client);
message.delete();
message.delete().catch(err => console.log(err));
}
});
}).catch(err => console.log(err));
Expand Down

0 comments on commit 20d8d50

Please sign in to comment.