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 <prefix> with actual prefix
This commit is contained in:
SileNce5k 2021-06-25 02:33:50 +02:00
parent f840bfd9db
commit 977d03e2e2
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
2 changed files with 20 additions and 4 deletions

View file

@ -25,7 +25,7 @@ module.exports = {
.setTimestamp() .setTimestamp()
.setAuthor("soilens bot", "https://cdn.discordapp.com/avatars/481128222147477506/1a30f57f8e403f54aaca502012aeff14.png?size=2048") .setAuthor("soilens bot", "https://cdn.discordapp.com/avatars/481128222147477506/1a30f57f8e403f54aaca502012aeff14.png?size=2048")
let noHelp = 0;
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`./${file}`); const command = require(`./${file}`);
@ -33,15 +33,30 @@ module.exports = {
if (args[0] == "admin") { if (args[0] == "admin") {
if (command.admin && !command.disabled) if (command.admin && !command.disabled)
commands = commands + `${prefix}${command.name} | ${command.description}\n` commands = commands + `${prefix}${command.name} | ${command.description}\n`
} else }else if(!args[0]){
if (!command.admin && !command.disabled) if (!command.admin && !command.disabled)
commands = commands + `${prefix}${command.name} | ${command.description}\n` 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 = /<prefix>/g
commands = commands.replace(regex, prefix)
embed.addFields( embed.addFields(
{ name: "General", value: commands }, { name: "General", value: commands },
) )
if(noHelp == 0)
message.channel.send(embed); message.channel.send(embed);
else
message.channel.send("Either there is no command with that name, or there is no specific help for it.")
}, },
}; };

View file

@ -5,6 +5,7 @@ const creationJoinDates = require("../util/creationJoinDates")
module.exports = { module.exports = {
name: 'userinfo', name: 'userinfo',
description: 'Displays information about the user', description: 'Displays information about the user',
moreHelp: ["Example: <prefix>userinfo <some_username>","It works with username, nickname, userid, and mention"],
execute({message, args}) { execute({message, args}) {
let info; let info;
let nickname = ""; let nickname = "";