summaryrefslogtreecommitdiff
path: root/commands/help.js
blob: bf2971c10b6a6218efb3770e55b9a077486390f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const fs = require("fs");

module.exports = (parameter, wrapper) => {
    /*wrapper.send("👋 Hey! Here are all the commands you can use:\n" + fs.readdirSync("./commands").map((i) => {
        let txt = "<ul><li><code>." + i.substring(0, i.length - 3);

        if (fs.existsSync("./help/" + i.substring(0, i.length - 3) + ".json")) {
            let help = JSON.parse(fs.readFileSync("./help/" + i.substring(0, i.length - 3) + ".json").toString());

            txt += help['parameters'].replaceAll("<", "&lt;").replaceAll(">", "&gt;") + "</code><ul>";

            if (help['aliases'] && help['aliases'].length > 0) {
                txt += "<li><b>Alias" + (help['aliases'].length > 1 ? "es" : "") + ":</b> " + help['aliases'].map(i => `<code>.${i}</code>`).join(", ") + "</li>";
            }

            txt += "<li>" + help['description'].replaceAll("<", "&lt;").replaceAll(">", "&gt;") + "</li></ul></li></ul>";
        } else {
            txt += "</code><ul><li><i>No documentation yet</i></li></ul></li></ul>";
        }

        return txt;
    }).join(""));*/

    if (parameter.trim() !== "") {
        if (fs.existsSync("./help/" + parameter.replaceAll("/", "-") + ".json")) {
            let help = JSON.parse(fs.readFileSync("./help/" + parameter + ".json").toString());
            let txt = "ℹ️ `." + parameter + help['parameters'] + "`\n";

            if (help['aliases'] && help['aliases'].length > 0) {
                txt += "* **Alias" + (help['aliases'].length > 1 ? "es" : "") + ":** " + help['aliases'].map(i => `\`.${i}\``).join(", ") + "\n";
            }

            if (help['description'] && help['description'].trim() !== "") {
                txt += "* **Description:** " + help['description'] + "\n";
            }

            if (parameter === "ask" || parameter === "math") {
                txt += "* Limited to 400 commands a month\n";
            }

            wrapper.send(txt);
        } else {
            wrapper.send("😢 Sorry, no help is available for this command, try again later.");
        }
    } else {
        wrapper.send("👋 Hey! Here are all the commands you can use: " + fs.readdirSync("./commands").map((i) => "`." + i.substring(0, i.length - 3) + "`").join(", ") + "\n\nUse `.help [command]` to get help for a specific command.");
    }
}