Nothing happens when using command












0















I am having some problems to run this commands: the export does work fine (no issues at console log) but when I execute some of those commands nothing happens...



let _exports = require("../exports.js");

module.exports.main = function(guild,command,type,member,message) {

const Discord = require('discord.js');
const prefix = "!"

Client.on("ready", () => {
console.log("online");
Client.user.setPresence({ game: { name: `Hello world`, type: 0} });
});

// welcome message

Client.on("guildMemberAdd", member => {
member.guild.defaultChannel.send("Welcome to: " + member.guild.name + "")
});

Client.on("guildMemberRemove", member => {
member.guild.defaultChannel.send("Goodbye: " + member.user.username + " from " + member.guild.name)
});

Client.on("guildCreate", guild => {
console.log("server owner: " + guild.owner.user.username)
});

Client.on("message", async (message) => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;

let command = message.content.split(" ")[0];
command = command.slice(prefix.length);

let args = message.content.split(" ").slice(1);

if (command === "ping") {
message.channel.send(`Pong! Time took: ${Date.now() - message.createdTimestamp} ms`);
} else

if (command === "say") {
message.delete()
const embed = new Discord.RichEmbed()
.setColor(0x954D23)
.setDescription(message.author.username + " says: " + args.join(" "));
message.channel.send({embed})
} else

if (command == "helpz") {
const embed = new Discord.RichEmbed()
.setColor(0x954D23)
.setTitle("Command List:")
.addField("!help", "Will give the current command list")
.addField("!ping", "WIll show the ping time for the bot")
.addField("!say [text]", "Will make the bot say something")
message.channel.send({embed})
}

if(command === `slive`){

let botembed = new Discord.RichEmbed()
.setColor("#C02909")
.addField("**LIVE, ALL!**", ("good luck!"));

return message.channel.send('@here', botembed);

}

if(command === `sremake`){

let botembed = new Discord.RichEmbed()
.setColor("#C02909")
.addField("**RMK / ALL!**", ("rmk"));

return message.channel.send('@here', botembed);

}

if(command === `cd15s`){

let botembed = new Discord.RichEmbed()
.setColor("#C02909")
.addField("Next lobby starts in **15** Seconds", ("00:15"));


return message.channel.send('@here', botembed);

}

if(command === `cd30s`){

let botembed = new Discord.RichEmbed()
.setColor("#C02909")
.addField("Next lobby starts in **30** Seconds", ("00:30"));

return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

}

if(command === `cd1m`){

let botembed = new Discord.RichEmbed()
.setColor("#C02909")
.addField("Next lobby starts in **1** Minute", ("01:00"));

return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

}

if(command === `cd2m`){

let botembed = new Discord.RichEmbed()
.setColor("#C02909")
.addField("Next lobby starts in **2** Minutes", ("02:00"));

return message.channel.send('@here', botembed);
}

});
};


If you know where the issue is just modify the source! thank you beforehand










share|improve this question





























    0















    I am having some problems to run this commands: the export does work fine (no issues at console log) but when I execute some of those commands nothing happens...



    let _exports = require("../exports.js");

    module.exports.main = function(guild,command,type,member,message) {

    const Discord = require('discord.js');
    const prefix = "!"

    Client.on("ready", () => {
    console.log("online");
    Client.user.setPresence({ game: { name: `Hello world`, type: 0} });
    });

    // welcome message

    Client.on("guildMemberAdd", member => {
    member.guild.defaultChannel.send("Welcome to: " + member.guild.name + "")
    });

    Client.on("guildMemberRemove", member => {
    member.guild.defaultChannel.send("Goodbye: " + member.user.username + " from " + member.guild.name)
    });

    Client.on("guildCreate", guild => {
    console.log("server owner: " + guild.owner.user.username)
    });

    Client.on("message", async (message) => {
    if (message.author.bot) return;
    if (!message.content.startsWith(prefix)) return;

    let command = message.content.split(" ")[0];
    command = command.slice(prefix.length);

    let args = message.content.split(" ").slice(1);

    if (command === "ping") {
    message.channel.send(`Pong! Time took: ${Date.now() - message.createdTimestamp} ms`);
    } else

    if (command === "say") {
    message.delete()
    const embed = new Discord.RichEmbed()
    .setColor(0x954D23)
    .setDescription(message.author.username + " says: " + args.join(" "));
    message.channel.send({embed})
    } else

    if (command == "helpz") {
    const embed = new Discord.RichEmbed()
    .setColor(0x954D23)
    .setTitle("Command List:")
    .addField("!help", "Will give the current command list")
    .addField("!ping", "WIll show the ping time for the bot")
    .addField("!say [text]", "Will make the bot say something")
    message.channel.send({embed})
    }

    if(command === `slive`){

    let botembed = new Discord.RichEmbed()
    .setColor("#C02909")
    .addField("**LIVE, ALL!**", ("good luck!"));

    return message.channel.send('@here', botembed);

    }

    if(command === `sremake`){

    let botembed = new Discord.RichEmbed()
    .setColor("#C02909")
    .addField("**RMK / ALL!**", ("rmk"));

    return message.channel.send('@here', botembed);

    }

    if(command === `cd15s`){

    let botembed = new Discord.RichEmbed()
    .setColor("#C02909")
    .addField("Next lobby starts in **15** Seconds", ("00:15"));


    return message.channel.send('@here', botembed);

    }

    if(command === `cd30s`){

    let botembed = new Discord.RichEmbed()
    .setColor("#C02909")
    .addField("Next lobby starts in **30** Seconds", ("00:30"));

    return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

    }

    if(command === `cd1m`){

    let botembed = new Discord.RichEmbed()
    .setColor("#C02909")
    .addField("Next lobby starts in **1** Minute", ("01:00"));

    return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

    }

    if(command === `cd2m`){

    let botembed = new Discord.RichEmbed()
    .setColor("#C02909")
    .addField("Next lobby starts in **2** Minutes", ("02:00"));

    return message.channel.send('@here', botembed);
    }

    });
    };


    If you know where the issue is just modify the source! thank you beforehand










    share|improve this question



























      0












      0








      0








      I am having some problems to run this commands: the export does work fine (no issues at console log) but when I execute some of those commands nothing happens...



      let _exports = require("../exports.js");

      module.exports.main = function(guild,command,type,member,message) {

      const Discord = require('discord.js');
      const prefix = "!"

      Client.on("ready", () => {
      console.log("online");
      Client.user.setPresence({ game: { name: `Hello world`, type: 0} });
      });

      // welcome message

      Client.on("guildMemberAdd", member => {
      member.guild.defaultChannel.send("Welcome to: " + member.guild.name + "")
      });

      Client.on("guildMemberRemove", member => {
      member.guild.defaultChannel.send("Goodbye: " + member.user.username + " from " + member.guild.name)
      });

      Client.on("guildCreate", guild => {
      console.log("server owner: " + guild.owner.user.username)
      });

      Client.on("message", async (message) => {
      if (message.author.bot) return;
      if (!message.content.startsWith(prefix)) return;

      let command = message.content.split(" ")[0];
      command = command.slice(prefix.length);

      let args = message.content.split(" ").slice(1);

      if (command === "ping") {
      message.channel.send(`Pong! Time took: ${Date.now() - message.createdTimestamp} ms`);
      } else

      if (command === "say") {
      message.delete()
      const embed = new Discord.RichEmbed()
      .setColor(0x954D23)
      .setDescription(message.author.username + " says: " + args.join(" "));
      message.channel.send({embed})
      } else

      if (command == "helpz") {
      const embed = new Discord.RichEmbed()
      .setColor(0x954D23)
      .setTitle("Command List:")
      .addField("!help", "Will give the current command list")
      .addField("!ping", "WIll show the ping time for the bot")
      .addField("!say [text]", "Will make the bot say something")
      message.channel.send({embed})
      }

      if(command === `slive`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("**LIVE, ALL!**", ("good luck!"));

      return message.channel.send('@here', botembed);

      }

      if(command === `sremake`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("**RMK / ALL!**", ("rmk"));

      return message.channel.send('@here', botembed);

      }

      if(command === `cd15s`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **15** Seconds", ("00:15"));


      return message.channel.send('@here', botembed);

      }

      if(command === `cd30s`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **30** Seconds", ("00:30"));

      return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

      }

      if(command === `cd1m`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **1** Minute", ("01:00"));

      return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

      }

      if(command === `cd2m`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **2** Minutes", ("02:00"));

      return message.channel.send('@here', botembed);
      }

      });
      };


      If you know where the issue is just modify the source! thank you beforehand










      share|improve this question
















      I am having some problems to run this commands: the export does work fine (no issues at console log) but when I execute some of those commands nothing happens...



      let _exports = require("../exports.js");

      module.exports.main = function(guild,command,type,member,message) {

      const Discord = require('discord.js');
      const prefix = "!"

      Client.on("ready", () => {
      console.log("online");
      Client.user.setPresence({ game: { name: `Hello world`, type: 0} });
      });

      // welcome message

      Client.on("guildMemberAdd", member => {
      member.guild.defaultChannel.send("Welcome to: " + member.guild.name + "")
      });

      Client.on("guildMemberRemove", member => {
      member.guild.defaultChannel.send("Goodbye: " + member.user.username + " from " + member.guild.name)
      });

      Client.on("guildCreate", guild => {
      console.log("server owner: " + guild.owner.user.username)
      });

      Client.on("message", async (message) => {
      if (message.author.bot) return;
      if (!message.content.startsWith(prefix)) return;

      let command = message.content.split(" ")[0];
      command = command.slice(prefix.length);

      let args = message.content.split(" ").slice(1);

      if (command === "ping") {
      message.channel.send(`Pong! Time took: ${Date.now() - message.createdTimestamp} ms`);
      } else

      if (command === "say") {
      message.delete()
      const embed = new Discord.RichEmbed()
      .setColor(0x954D23)
      .setDescription(message.author.username + " says: " + args.join(" "));
      message.channel.send({embed})
      } else

      if (command == "helpz") {
      const embed = new Discord.RichEmbed()
      .setColor(0x954D23)
      .setTitle("Command List:")
      .addField("!help", "Will give the current command list")
      .addField("!ping", "WIll show the ping time for the bot")
      .addField("!say [text]", "Will make the bot say something")
      message.channel.send({embed})
      }

      if(command === `slive`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("**LIVE, ALL!**", ("good luck!"));

      return message.channel.send('@here', botembed);

      }

      if(command === `sremake`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("**RMK / ALL!**", ("rmk"));

      return message.channel.send('@here', botembed);

      }

      if(command === `cd15s`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **15** Seconds", ("00:15"));


      return message.channel.send('@here', botembed);

      }

      if(command === `cd30s`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **30** Seconds", ("00:30"));

      return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

      }

      if(command === `cd1m`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **1** Minute", ("01:00"));

      return message.channel.send('@here', botembed);return message.channel.send('@here', botembed);

      }

      if(command === `cd2m`){

      let botembed = new Discord.RichEmbed()
      .setColor("#C02909")
      .addField("Next lobby starts in **2** Minutes", ("02:00"));

      return message.channel.send('@here', botembed);
      }

      });
      };


      If you know where the issue is just modify the source! thank you beforehand







      discord.js






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '18 at 11:48









      Federico Grandi

      2,93321227




      2,93321227










      asked Nov 25 '18 at 5:05









      AuguxAugux

      215




      215
























          1 Answer
          1






          active

          oldest

          votes


















          0














          If that's your entire file, that can't work because Client is not defined: you could either pass the client as an argument to the module.exports.main function, or declare it at the top.

          With that said, I won't export all that stuff: since you're declaring only event listeners, you can directly add them in the same function where you declared the client. Exporting can be useful only if you want to keep every command in a different file (you could also use discord.js-commando). In that case, you should declare the listeners in the main file, then require the command files.

          Scheme:





          // main file
          const Discord = require('discord');
          const client = new Discord.Client();

          client.on('ready') {...}
          // other "client.on"s
          client.on('message') {
          // command parsing & co
          if (command == 'say') require('./commands/say.js').main()
          }




          // command file: '/commands/say.js'
          module.exports.main = (message, ...args) => {
          ...
          };





          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',
            autoActivateHeartbeat: false,
            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
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464810%2fnothing-happens-when-using-command%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            If that's your entire file, that can't work because Client is not defined: you could either pass the client as an argument to the module.exports.main function, or declare it at the top.

            With that said, I won't export all that stuff: since you're declaring only event listeners, you can directly add them in the same function where you declared the client. Exporting can be useful only if you want to keep every command in a different file (you could also use discord.js-commando). In that case, you should declare the listeners in the main file, then require the command files.

            Scheme:





            // main file
            const Discord = require('discord');
            const client = new Discord.Client();

            client.on('ready') {...}
            // other "client.on"s
            client.on('message') {
            // command parsing & co
            if (command == 'say') require('./commands/say.js').main()
            }




            // command file: '/commands/say.js'
            module.exports.main = (message, ...args) => {
            ...
            };





            share|improve this answer




























              0














              If that's your entire file, that can't work because Client is not defined: you could either pass the client as an argument to the module.exports.main function, or declare it at the top.

              With that said, I won't export all that stuff: since you're declaring only event listeners, you can directly add them in the same function where you declared the client. Exporting can be useful only if you want to keep every command in a different file (you could also use discord.js-commando). In that case, you should declare the listeners in the main file, then require the command files.

              Scheme:





              // main file
              const Discord = require('discord');
              const client = new Discord.Client();

              client.on('ready') {...}
              // other "client.on"s
              client.on('message') {
              // command parsing & co
              if (command == 'say') require('./commands/say.js').main()
              }




              // command file: '/commands/say.js'
              module.exports.main = (message, ...args) => {
              ...
              };





              share|improve this answer


























                0












                0








                0







                If that's your entire file, that can't work because Client is not defined: you could either pass the client as an argument to the module.exports.main function, or declare it at the top.

                With that said, I won't export all that stuff: since you're declaring only event listeners, you can directly add them in the same function where you declared the client. Exporting can be useful only if you want to keep every command in a different file (you could also use discord.js-commando). In that case, you should declare the listeners in the main file, then require the command files.

                Scheme:





                // main file
                const Discord = require('discord');
                const client = new Discord.Client();

                client.on('ready') {...}
                // other "client.on"s
                client.on('message') {
                // command parsing & co
                if (command == 'say') require('./commands/say.js').main()
                }




                // command file: '/commands/say.js'
                module.exports.main = (message, ...args) => {
                ...
                };





                share|improve this answer













                If that's your entire file, that can't work because Client is not defined: you could either pass the client as an argument to the module.exports.main function, or declare it at the top.

                With that said, I won't export all that stuff: since you're declaring only event listeners, you can directly add them in the same function where you declared the client. Exporting can be useful only if you want to keep every command in a different file (you could also use discord.js-commando). In that case, you should declare the listeners in the main file, then require the command files.

                Scheme:





                // main file
                const Discord = require('discord');
                const client = new Discord.Client();

                client.on('ready') {...}
                // other "client.on"s
                client.on('message') {
                // command parsing & co
                if (command == 'say') require('./commands/say.js').main()
                }




                // command file: '/commands/say.js'
                module.exports.main = (message, ...args) => {
                ...
                };






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 25 '18 at 11:59









                Federico GrandiFederico Grandi

                2,93321227




                2,93321227






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464810%2fnothing-happens-when-using-command%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Contact image not getting when fetch all contact list from iPhone by CNContact

                    count number of partitions of a set with n elements into k subsets

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks