title: Discord.js Cannot read property 'send' of undefined and some other small problems
body: <p>I use <a href="https://github.com/UnrealSecurity/jdclient" rel="nofollow noreferrer">https://github.com/UnrealSecurity/jdclient</a> as the command handler now.
  I have tried for hours to make this working but it just doesn't work. The only error im getting now is
  "Cannot read property 'send' of undefined" but i feel like it will have other errors after its fixed
  The code should send a copy of message, deleted message, edited message to a channel. It worked some while ago but now its broken -.- 
  I'm having problems with this code: </p>
  
  <pre><code>// import library
  const { JDClient, Discord } = require('./src/');
  const { prefix, token, logsChannel } = require('./config.json');
  client = new Discord.Client();
  // define minimum bot options
  const options = {
    token: 'TOKEN',
    trigger: '?'
  };
  
  
  // build bot commands
  const commands = {
    help: {
      run: (message, pars, arr)=&gt;{
        message.reply('**Available commands:** \n' + Object.keys(bot.commands).join(', '))
      }
    }
  };
  
  
  // create bot instance
  var bot = new JDClient(options, commands);
  
  // Messages log
  bot.discord.on('message', message =&gt; {
    // Function
    function isEmpty(collection) {
        for(var arg in collection) {
            if(collection.hasOwnProperty(arg))
                return false;
        }
        return true;
    }
    // Logs
    if(message.author.bot) return;
    let username = message.author.tag;
    let channel = message.channel.name;
    let server = message.channel.guild;
  var serverAvatarURL = message.guild.iconURL;
    var attachment = (message.attachments).array();
    if(isEmpty(attachment)) {
        var img = "";
    } else {
        var img = attachment[0].url;
    }
  
    let embed_send = new Discord.MessageEmbed()
        .setAuthor(username, message.author.avatarURL)
        .setColor('23c115')
        .setTitle("Message sent!")
        .setDescription(message.content + " " + img)
        .setImage(img)
        .setFooter("#" + channel)
        .setTimestamp();
        client.channels.cache.get(logsChannel).send(embed_send);
  });
  
  // Message edit log
  bot.discord.on("messageUpdate", async(oldMessage, newMessage) =&gt; {
    // Function
    function isEmpty(collection) {
        for(var arg in collection) {
            if(collection.hasOwnProperty(arg))
                return false;
        }
        return true;
    }
    // Logs
    if (oldMessage.content === newMessage.content) {
        return;
    }
  
    var attachment = (oldMessage.attachments).array();
    if(isEmpty(attachment)) {
        var img = "";
    } else {
        var img = attachment[0].url;
    }
  
    let embed_edit = new Discord.MessageEmbed()
        .setAuthor(oldMessage.author.tag, oldMessage.author.avatarURL)
        .setColor('2615c1')
    .setTitle("Message edited!")
        .addField("Old", oldMessage.content + " " + img, true)
    .addField("New", newMessage.content + " " + img, true)
        .setFooter("#" + oldMessage.channel.name)
        .setTimestamp();
    client.channels.cache.get(logsChannel).send(embed_edit);
  });
  
  // Message delete log
  bot.discord.on("messageDelete", async message =&gt; {
    // Function
    function isEmpty(collection) {
        for(var arg in collection) {
            if(collection.hasOwnProperty(arg))
                return false;
        }
        return true;
    }
    // Logs
    var attachment = (message.attachments).array();
    if(isEmpty(attachment)) {
        var img = "";
    } else {
        var img = attachment[0].url;
    }
  
    let embed_delete = new Discord.MessageEmbed()
    .setAuthor(message.author.tag, message.author.avatarURL)
    .setColor('c11515')
    .setTitle("Message deleted!")
    .setDescription(message.content + " " + img)
    .setImage(img)
    .setFooter("#" + message.channel.name)
    .setTimestamp();    
    client.channels.cache.get(logsChannel).send(embed_delete);
  }),
  
        bot.discord.on("guildMemberAdd", (member) =&gt; {
        const embed = new Discord.MessageEmbed()
        .setColor(0x00d0ff)
        .setTitle("New user joined!")
        .setDescription("Welcome, " + member + "!")
        .setFooter("https://discord.gg/xHusQ4d", "https://cdn.drawception.com/images/panels/2017/10-13/P7sMKBC2pR-4.png")
        .setTimestamp()
        client.channels.cache.get(member.guild.systemChannelID).send({embed});
            },
        )
        bot.discord.on("guildMemberRemove", (member) =&gt; {
        const embed = new Discord.MessageEmbed()
        .setColor(0x00d0ff)
        .setTitle("Bye!")
        .setDescription("Good bye, " + member + "!")
        .setFooter("https://discord.gg/xHusQ4d", "https://cdn.drawception.com/images/panels/2017/10-13/P7sMKBC2pR-4.png")
        .setTimestamp()
        bot.discord.channels.get(member.guild.systemChannelID).send({embed});
        }),
  
        bot.discord.onConnect = ()=&gt;{
            console.log('We are logged into Dickcord!');
         }
  
  
  bot.commands = {
  
    botstatus: {
      text: 'Changes bot status',
      run: (args, pars, arr) =&gt; {
          bot.discord.user.setActivity(arr.join(' '), { type: "WATCHING" });
          args.delete(1)
          console.log(args.author.tag, 'used the botstatus command!');
          },  
      },
  
       joke: {
          text: "fun",
          run: (args, pars, arr) =&gt; {
              var facts = ["Yo mama's so fat, when she skips a meal, the stock market drops ", "Yo mama's so fat, when she fell I didn't laugh, but the sidewalk cracked up.", "Yo mama's so fat, it took me two buses and a train to get to her good side.", "Why do cows never have any money? Because the farmers milk them dry!", "My wife told me I had to stop acting like a flamingo. So I had to put my foot down.", "As I suspected, someone has been adding soil to my garden. The plot thickens.", "When a deaf person sees someone yawn do they think it’s a scream?", "What did the traffic light say to the car? Don’t look! I’m about to change.", "Somebody stole my microsoft office and they're going to pay - you have my Word.", "What did the left eye say to the right eye? Between you and me, something smells."];
              var fact = Math.floor(Math.random() * facts.length);
              args.channel.send("Finding fun jokes... "),
              args.channel.send(facts[fact]);
              args.delete(1)
              console.log(args.author.tag, 'used the joke command!');
  
          },
       },
  
      facts: {
          text: "facts",
          run: (args, pars, arr) =&gt; {
              var facts = ["Hawaiian pizza was invented by a Greek man in Canada. ", "The world’s first cosmonaut was a dog.", "Ketchup was invented in China.", "All blue-eyed people have a common ancestor.", "Workers are most productive on Mondays.", "The human eye can detect the light of a candle from over a mile away.", "You can tell if someone really likes you by looking at their feet while you talk.", "The oldest “your mom” joke dates from ancient Babylonia", "Penguin urine makes up about 3% of Antarctica’s glaciers.", "The name for the fear of long words is 36 letters long. ", "Nutella was originally invented as a way to stretch chocolate rations.", "A cat named Sweet Tart is the Mayor of Omena, Michigan.", "There is a medical procedure to remove the sense of fear.", "Genghis Khan has about 16 million living descendants.", "Grapes are toxic to dogs.", "Barbie’s full name is Barbara Millicent Roberts.", "Some snakes can sense when an earthquake is coming.", "Killer whales aren’t really whales.", "90% of the world’s fresh water is in Antarctica.",];
              var fact = Math.floor(Math.random() * facts.length);
              args.channel.send("searching for facts... "),
              args.channel.send(facts[fact]);
              args.delete(1)
              console.log(args.author.tag, 'used the facts command!');
          },
          command: {
              text: "command name",
              run: (args, pars, arr) =&gt; {
                  args.channel.send("command")
              }
          }
      },
      roulette: {
      text: "russian roulette",
      run: (args, pars, arr) =&gt; {
          var facts = ["YOU LOSE!", "YOU WIN!", "YOU LOSE!", "YOU WIN!", "YOU LOSE!", "YOU WIN!",];
          var fact = Math.floor(Math.random() * facts.length);
  
          args.react('').then(() =&gt; args.react('❤'));
          const filter = (reaction, user) =&gt; {
          return ['', '❤'].includes(reaction.emoji.name) &amp;&amp; user.id === args.author.id;
          };
          args.channel.send("Pick a color! Black or red!")
          args.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
          .then(collected =&gt; {
          const reaction = collected.first();
  
          if (reaction.emoji.name === '') {
          args.channel.send(facts[fact]);
          } else {
          args.channel.send(facts[fact]);
          }
          })
          .catch(collected =&gt; {
          args.channel.send('you reacted with neither a black, nor a red.');
          });
          }
      },
  }
  // bind bot events, all of these are optional
  bot.on('ready', () =&gt; {
    console.log('We are logged into Discord!');
  });
  
  bot.on('message', (event) =&gt; {
    let { client, text, data } = event;
    console.log(text);
  });
  
  bot.on('error', (event) =&gt; {
    const { client, text, data } = event;
    console.log(text);
  });
  
  bot.on('debug', (event) =&gt; {
    const { client, text, data } = event;
    console.log(text);
  });
  </code></pre>
  
  <p>full error:</p>
  
  <pre><code>TypeError: Cannot read property 'send' of undefined
      at Client.&lt;anonymous&gt; (C:\Users\CryT0r\Desktop\botty\app.js:56:45)
      at Client.emit (events.js:215:7)
      at MessageCreateAction.handle (C:\Users\CryT0r\Desktop\botty\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
      at Object.module.exports [as MESSAGE_CREATE] (C:\Users\CryT0r\Desktop\botty\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
      at WebSocketManager.handlePacket (C:\Users\CryT0r\Desktop\botty\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)  
      at WebSocketShard.onPacket (C:\Users\CryT0r\Desktop\botty\node_modules\discord.js\src\client\websocket\WebSocketShard.js:435:22)
      at WebSocketShard.onMessage (C:\Users\CryT0r\Desktop\botty\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
      at WebSocket.onMessage (C:\Users\CryT0r\Desktop\botty\node_modules\ws\lib\event-target.js:120:16)
      at WebSocket.emit (events.js:210:5)
      at Receiver.receiverOnMessage (C:\Users\CryT0r\Desktop\botty\node_modules\ws\lib\websocket.js:801:20)
  </code></pre>