From 977d03e2e260d4713638577d639cb93a58aa1831 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Fri, 25 Jun 2021 02:33:50 +0200 Subject: [PATCH] Expand help command with morehelp feature Now you can specify what command you want help on. Respond if no specific command or help Add moreHelp for the userinfo command Use regex to replace with actual prefix --- commands/help.js | 23 +++++++++++++++++++---- commands/userinfo.js | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/commands/help.js b/commands/help.js index 75d36c7..3d35711 100644 --- a/commands/help.js +++ b/commands/help.js @@ -25,7 +25,7 @@ module.exports = { .setTimestamp() .setAuthor("soilens bot", "https://cdn.discordapp.com/avatars/481128222147477506/1a30f57f8e403f54aaca502012aeff14.png?size=2048") - + let noHelp = 0; for (const file of commandFiles) { const command = require(`./${file}`); @@ -33,15 +33,30 @@ module.exports = { if (args[0] == "admin") { if (command.admin && !command.disabled) commands = commands + `${prefix}${command.name} | ${command.description}\n` - } else + }else if(!args[0]){ if (!command.admin && !command.disabled) commands = commands + `${prefix}${command.name} | ${command.description}\n` + }else if(args[0] === command.name){ + commands = commands + `${prefix}${command.name}\n` + if(command.moreHelp){ + command.moreHelp.forEach(element => { + commands = commands + `${element}\n` + }); + } else { + noHelp = 1; + } + break; + } } + let regex = //g + commands = commands.replace(regex, prefix) embed.addFields( { name: "General", value: commands }, ) - - message.channel.send(embed); + if(noHelp == 0) + message.channel.send(embed); + else + message.channel.send("Either there is no command with that name, or there is no specific help for it.") }, }; diff --git a/commands/userinfo.js b/commands/userinfo.js index 7a9b46d..66949dd 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -5,6 +5,7 @@ const creationJoinDates = require("../util/creationJoinDates") module.exports = { name: 'userinfo', description: 'Displays information about the user', + moreHelp: ["Example: userinfo ","It works with username, nickname, userid, and mention"], execute({message, args}) { let info; let nickname = "";