react menu help command

master
Kit Kasune 3 years ago
parent f1c4f83a99
commit 2875e52a65
  1. 70
      commands/misc/help.js
  2. 4
      util/pagination.js
  3. 4
      util/ts/pagination.ts

@ -36,25 +36,71 @@ module.exports = {
helpSorted[category] = categorySorted;
}
let cat = await ask(message, "What would you like help with? (`Fun`|`Utility`|`Misc`|`Moderation`|`Social`|`Leveling`) or `all` if you'd like to browse all commands", 60000); if (!cat) {return;}
if (!['f', 'fun', 'u', 'util', 'utility', 'utilities', 'm', 'misc', 'miscellaneous', 'mod', 'moderation', 's', 'social', 'leveling', 'l', 'level', 'a', 'all'].includes(`${cat}`.trim().toLowerCase())) {return message.channel.send("That wasn't a valid response! Try again?");}
let cle = await message.channel.send({embeds: [
new Discord.MessageEmbed()
.setTitle("Natsuki Help")
.setDescription(`Here you can find a list of commands and how to use them.\n\nNatsuki's prefix, by default, is \`n?\`. Here, it's \`${prefix}\`.\n\nWhen viewing a command's syntax, a parameter/argument marked with <> means that it is required. [] shows that it is optional.\n\nGet more help on a command by sending it without any arguments (i.e. \`${prefix}anime\`), or run \`${prefix}help <command>\`.`)
.addField("Category", "What category would you like to view?\n:one: - Fun\n:two: - Utility\n:three: - Misc\n:four: - Developer\n:five: - Moderation\n:six: - Social\n:seven: - Leveling\n:eight: - Anime\n:nine: - **All**")
.setColor('c375f0')
.setFooter("Natsuki | Will time out in 60 seconds.")
.setThumbnail(client.user.avatarURL({size: 2048}))
.setTimestamp()
]});
let pages;
if (['f', 'fun'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Fun'];}
if (['u', 'util', 'utility', 'utilities'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Utility'];}
if (['m', 'misc', 'miscellaneous'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Misc'];}
if (['d', 'dev', 'developer'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Developer'];}
if (['mod', 'moderation'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Moderation'];}
if (['s', 'social'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Social'];}
if (['l', 'leveling', 'level'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Leveling'];}
if (['a', 'all'].includes(`${cat}`.trim().toLowerCase())) {pages = []; let c; for (c of Object.values(helpSorted)) {let h; for (h of c) {pages.push(h)}}}
let nums = {
'1': "Fun",
'2': "Utility",
'3': "Misc",
'4': "Developer",
'5': "Moderation",
'6': "Social",
'7': "Leveling",
'8': "Anime",
'9': "All"
};
Object.keys(nums).forEach(num => cle.react(num).catch(() => {}));
let donePre = false;
const getCat = () => {
return new Promise(r => {
message.channel.awaitMessages({filter: m => m.author.id === message.author.id, max: 1, errors: ['time'], time: 60000}).then(cat => {
if (donePre) {return;}
cat = cat.first().content;
if (['f', 'fun', 'u', 'util', 'utility', 'utilities', 'm', 'misc', 'miscellaneous', 'mod', 'moderation', 's', 'social', 'leveling', 'l', 'level', 'ani', 'anime', 'a', 'all'].includes(`${cat}`.trim().toLowerCase())) {
if (['f', 'fun'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Fun'];}
if (['u', 'util', 'utility', 'utilities'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Utility'];}
if (['m', 'misc', 'miscellaneous'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Misc'];}
if (['d', 'dev', 'developer'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Developer'];}
if (['mod', 'moderation'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Moderation'];}
if (['s', 'social'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Social'];}
if (['l', 'leveling', 'level'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Leveling'];}
if (['ani', 'anime'].includes(`${cat}`.trim().toLowerCase())) {pages = helpSorted['Anime'];}
if (['a', 'all'].includes(`${cat}`.trim().toLowerCase())) {pages = []; let c; for (c of Object.values(helpSorted)) {let h; for (h of c) {pages.push(h)}}}
donePre = true;
r(true);
} else {donePre = true; r(false);}
}).catch(() => {donePre = true; r(false);});
cle.awaitReactions({filter: (rt, u) => Object.keys(nums).includes(rt.emoji.name) && u.id === message.author.id, time: 60000, errors: ['time'], max: 1}).then(collected => {
if (donePre) {return;}
if (nums[collected.first().emoji.name] === 'All') {pages = []; let c; for (c of Object.values(helpSorted)) {let h; for (h of c) {pages.push(h)}}}
else {pages = helpSorted[nums[collected.first().emoji.name]];}
donePre = true;
r(true);
}).then(() => {donePre = true; r(false);});
});
}
if (!await getCat().catch(() => {})) {return;}
await require('../../util/wait')(500);
cle.delete().catch(() => {});
if (pages.length > 1) {
let help = new Pagination(message.channel, pages, message, client, true);
return await help.start({endTime: 120000, user: message.author.id});
} else {return message.channel.send({embeds: [pages[0].setFooter("Natsuki", client.user.avatarURL()).setTimestamp()]});}
return await help.start({endTime: 60000, user: message.author.id}).catch(() => {});
} else {return message.channel.send({embeds: [pages[0].setFooter("Natsuki", client.user.avatarURL()).setTimestamp()]}).catch(() => {});}
} else {
let command;
if (client.commands.has(args[0])) {command = client.commands.get(args[0]);}

@ -116,9 +116,9 @@ class Pagination {
await this.message.reactions.removeAll().catch(() => { });
}
this.controllers.collector.stop();
let fe = this.message.embeds[0];
let fe = this.getCurrentPage();
fe.setDescription(`${fe.description}\n\n*This menu has ended, start a new one to interact with it!*`);
fe.setFooter(`${fe.footer && fe.footer.text && fe.footer.text.length ? ` | ${fe.footer.text}` : ''}Menu ended`, this.client.user.avatarURL());
fe.setFooter(`Menu Ended${fe.footer && fe.footer.text && fe.footer.text.length ? ` | ${fe.footer.text}` : ''}`, this.client.user.avatarURL());
await this.message.edit({ embeds: [fe] });
clearInterval(this.timeoutInterval);
return this;

@ -124,9 +124,9 @@ export class Pagination {
if (this.message.guild) {await this.message.reactions.removeAll().catch(() => {});}
this.controllers.collector.stop();
let fe = this.message.embeds[0];
let fe = this.getCurrentPage();
fe.setDescription(`${fe.description}\n\n*This menu has ended, start a new one to interact with it!*`);
fe.setFooter(`${fe.footer && fe.footer.text && fe.footer.text.length ? ` | ${fe.footer.text}` : ''}Menu ended`, this.client.user.avatarURL());
fe.setFooter(`Menu Ended${fe.footer && fe.footer.text && fe.footer.text.length ? ` | ${fe.footer.text}` : ''}`, this.client.user.avatarURL());
await this.message.edit({embeds: [fe]});
clearInterval(this.timeoutInterval);

Loading…
Cancel
Save