My discord.js help command doesn't exactly work











up vote
1
down vote

favorite












First things first, my help command does work but not in the way I would like it to work.



My first issue is that the commands are being sent in separate messages which is kind of annoying when you have a lot of commands.



My second issue is that when the message is sent in an embed, it shows up like this:




  • Command

  • Description

  • Usage

  • Undefined


I tried multiple ways to get rid of 'Undefined'.



My code:



const fs = require("fs");
const Discord = require("discord.js");

module.exports.run = async(bot, message, args, con) => {
fs.readdir("./commands/", (err, files) => {
if(err) console.error(err);

let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <= 0) {
console.log("No commands to load!");
return;
}

var namelist = "";
var desclist = "";
var usage = "";

let result = jsfiles((f, i) => {
let props = require(`./${f}`);
namelist = props.help.name;
desclist = props.help.description;
usage = props.help.usage;

// send help text
let helpembed = new Discord.RichEmbed()
.setTitle("Commands")
.setFooter("Please report any bugs to Vati#1662")
.setColor("RANDOM")
.addField(`**${namelist}** n${desclist} n${usage}`)
message.author.sendEmbed(helpembed);
});

})
}
module.exports.help = {
name: "help",
description: "shows all commands",
usage: "help"
}









share|improve this question









New contributor




MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    1
    down vote

    favorite












    First things first, my help command does work but not in the way I would like it to work.



    My first issue is that the commands are being sent in separate messages which is kind of annoying when you have a lot of commands.



    My second issue is that when the message is sent in an embed, it shows up like this:




    • Command

    • Description

    • Usage

    • Undefined


    I tried multiple ways to get rid of 'Undefined'.



    My code:



    const fs = require("fs");
    const Discord = require("discord.js");

    module.exports.run = async(bot, message, args, con) => {
    fs.readdir("./commands/", (err, files) => {
    if(err) console.error(err);

    let jsfiles = files.filter(f => f.split(".").pop() === "js");
    if(jsfiles.length <= 0) {
    console.log("No commands to load!");
    return;
    }

    var namelist = "";
    var desclist = "";
    var usage = "";

    let result = jsfiles((f, i) => {
    let props = require(`./${f}`);
    namelist = props.help.name;
    desclist = props.help.description;
    usage = props.help.usage;

    // send help text
    let helpembed = new Discord.RichEmbed()
    .setTitle("Commands")
    .setFooter("Please report any bugs to Vati#1662")
    .setColor("RANDOM")
    .addField(`**${namelist}** n${desclist} n${usage}`)
    message.author.sendEmbed(helpembed);
    });

    })
    }
    module.exports.help = {
    name: "help",
    description: "shows all commands",
    usage: "help"
    }









    share|improve this question









    New contributor




    MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      First things first, my help command does work but not in the way I would like it to work.



      My first issue is that the commands are being sent in separate messages which is kind of annoying when you have a lot of commands.



      My second issue is that when the message is sent in an embed, it shows up like this:




      • Command

      • Description

      • Usage

      • Undefined


      I tried multiple ways to get rid of 'Undefined'.



      My code:



      const fs = require("fs");
      const Discord = require("discord.js");

      module.exports.run = async(bot, message, args, con) => {
      fs.readdir("./commands/", (err, files) => {
      if(err) console.error(err);

      let jsfiles = files.filter(f => f.split(".").pop() === "js");
      if(jsfiles.length <= 0) {
      console.log("No commands to load!");
      return;
      }

      var namelist = "";
      var desclist = "";
      var usage = "";

      let result = jsfiles((f, i) => {
      let props = require(`./${f}`);
      namelist = props.help.name;
      desclist = props.help.description;
      usage = props.help.usage;

      // send help text
      let helpembed = new Discord.RichEmbed()
      .setTitle("Commands")
      .setFooter("Please report any bugs to Vati#1662")
      .setColor("RANDOM")
      .addField(`**${namelist}** n${desclist} n${usage}`)
      message.author.sendEmbed(helpembed);
      });

      })
      }
      module.exports.help = {
      name: "help",
      description: "shows all commands",
      usage: "help"
      }









      share|improve this question









      New contributor




      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      First things first, my help command does work but not in the way I would like it to work.



      My first issue is that the commands are being sent in separate messages which is kind of annoying when you have a lot of commands.



      My second issue is that when the message is sent in an embed, it shows up like this:




      • Command

      • Description

      • Usage

      • Undefined


      I tried multiple ways to get rid of 'Undefined'.



      My code:



      const fs = require("fs");
      const Discord = require("discord.js");

      module.exports.run = async(bot, message, args, con) => {
      fs.readdir("./commands/", (err, files) => {
      if(err) console.error(err);

      let jsfiles = files.filter(f => f.split(".").pop() === "js");
      if(jsfiles.length <= 0) {
      console.log("No commands to load!");
      return;
      }

      var namelist = "";
      var desclist = "";
      var usage = "";

      let result = jsfiles((f, i) => {
      let props = require(`./${f}`);
      namelist = props.help.name;
      desclist = props.help.description;
      usage = props.help.usage;

      // send help text
      let helpembed = new Discord.RichEmbed()
      .setTitle("Commands")
      .setFooter("Please report any bugs to Vati#1662")
      .setColor("RANDOM")
      .addField(`**${namelist}** n${desclist} n${usage}`)
      message.author.sendEmbed(helpembed);
      });

      })
      }
      module.exports.help = {
      name: "help",
      description: "shows all commands",
      usage: "help"
      }






      node.js discord discord.js






      share|improve this question









      New contributor




      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday









      halfer

      14.1k757104




      14.1k757104






      New contributor




      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 9 at 22:06









      MyNameIsVati

      84




      84




      New contributor




      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          When you use RichEmbed.addField() it expects at least two arguments: the title of the field and its value.



          .addField(`**${namelist}** n${desclist} n${usage}`) // this has only the title argument


          Try putting the three "sections" in three different fields.



          .addField("Name:", namelist, true) // the 'true' means that they're inline fileds
          .addField("Usage:", usage, true) // they will try to fit on the same line
          .addField("Description:", desclist) // if there's no third argument, the default is 'false'


          The commands are sent in different messages because you're running the whole code for every command, and not only adding the fields for every command. If you don't want to spend time on all this stuff, you can use the discord.js-commando library: it's a framework that deals with the commands and also handles errors, incomplete commands, and a lot of other stuff. If you want to check it out, you can find the docs here.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            MyNameIsVati is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233852%2fmy-discord-js-help-command-doesnt-exactly-work%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            When you use RichEmbed.addField() it expects at least two arguments: the title of the field and its value.



            .addField(`**${namelist}** n${desclist} n${usage}`) // this has only the title argument


            Try putting the three "sections" in three different fields.



            .addField("Name:", namelist, true) // the 'true' means that they're inline fileds
            .addField("Usage:", usage, true) // they will try to fit on the same line
            .addField("Description:", desclist) // if there's no third argument, the default is 'false'


            The commands are sent in different messages because you're running the whole code for every command, and not only adding the fields for every command. If you don't want to spend time on all this stuff, you can use the discord.js-commando library: it's a framework that deals with the commands and also handles errors, incomplete commands, and a lot of other stuff. If you want to check it out, you can find the docs here.






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              When you use RichEmbed.addField() it expects at least two arguments: the title of the field and its value.



              .addField(`**${namelist}** n${desclist} n${usage}`) // this has only the title argument


              Try putting the three "sections" in three different fields.



              .addField("Name:", namelist, true) // the 'true' means that they're inline fileds
              .addField("Usage:", usage, true) // they will try to fit on the same line
              .addField("Description:", desclist) // if there's no third argument, the default is 'false'


              The commands are sent in different messages because you're running the whole code for every command, and not only adding the fields for every command. If you don't want to spend time on all this stuff, you can use the discord.js-commando library: it's a framework that deals with the commands and also handles errors, incomplete commands, and a lot of other stuff. If you want to check it out, you can find the docs here.






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                When you use RichEmbed.addField() it expects at least two arguments: the title of the field and its value.



                .addField(`**${namelist}** n${desclist} n${usage}`) // this has only the title argument


                Try putting the three "sections" in three different fields.



                .addField("Name:", namelist, true) // the 'true' means that they're inline fileds
                .addField("Usage:", usage, true) // they will try to fit on the same line
                .addField("Description:", desclist) // if there's no third argument, the default is 'false'


                The commands are sent in different messages because you're running the whole code for every command, and not only adding the fields for every command. If you don't want to spend time on all this stuff, you can use the discord.js-commando library: it's a framework that deals with the commands and also handles errors, incomplete commands, and a lot of other stuff. If you want to check it out, you can find the docs here.






                share|improve this answer












                When you use RichEmbed.addField() it expects at least two arguments: the title of the field and its value.



                .addField(`**${namelist}** n${desclist} n${usage}`) // this has only the title argument


                Try putting the three "sections" in three different fields.



                .addField("Name:", namelist, true) // the 'true' means that they're inline fileds
                .addField("Usage:", usage, true) // they will try to fit on the same line
                .addField("Description:", desclist) // if there's no third argument, the default is 'false'


                The commands are sent in different messages because you're running the whole code for every command, and not only adding the fields for every command. If you don't want to spend time on all this stuff, you can use the discord.js-commando library: it's a framework that deals with the commands and also handles errors, incomplete commands, and a lot of other stuff. If you want to check it out, you can find the docs here.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 14:42









                Federico Grandi

                2,0541921




                2,0541921






















                    MyNameIsVati is a new contributor. Be nice, and check out our Code of Conduct.










                     

                    draft saved


                    draft discarded


















                    MyNameIsVati is a new contributor. Be nice, and check out our Code of Conduct.













                    MyNameIsVati is a new contributor. Be nice, and check out our Code of Conduct.












                    MyNameIsVati is a new contributor. Be nice, and check out our Code of Conduct.















                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233852%2fmy-discord-js-help-command-doesnt-exactly-work%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    Bressuire

                    Vorschmack

                    Quarantine