diff --git a/commands/misc/help.js b/commands/misc/help.js index e1c2469..5dd935c 100644 --- a/commands/misc/help.js +++ b/commands/misc/help.js @@ -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 \`.`) + .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]);} diff --git a/util/pagination.js b/util/pagination.js index 44a72d7..6a872dd 100644 --- a/util/pagination.js +++ b/util/pagination.js @@ -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; diff --git a/util/ts/pagination.ts b/util/ts/pagination.ts index 5d571dc..4d82fb6 100644 --- a/util/ts/pagination.ts +++ b/util/ts/pagination.ts @@ -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);