title: How to fix : "DiscordAPIError: Cannot send an empty message"
body: <p>before I start, I'd like to say that i've seen the page with the same problem as I have. But for some reason i can't figure out where my problem is. 
  I'm fairly new to programming so sorry if I made any major mistakes in the program. I'll explain my problem: everytime I run the code the game actually works but after a while a long text appears in my terminal which says: "DiscordAPIError: Cannot send an empty message". I know it probably has something to do with the message.delete code but I'm not able to fix it.</p>
  
  <pre><code>const botconfig = require("./botconfig.json");
  const Discord = require("discord.js");
  const bot = new Discord.Client({disableEveryone: true});
  
  
  let word;
  let letter;
  let lWord = [];
  let charLength;
  let txt = [];
  let outputTxt;
  let misscount;
  let misses = 0;
  let succes;
  
  
  bot.on("ready", async () =&gt; {
      console.log(`${bot.user.username} is online!`);
      bot.user.setActivity("Hangman with y'all");
  });
  
  
  bot.on("message", async message =&gt; { 
      if(message.author.bot) return;
      if(message.channel.type === "dm") return;
  
      let prefix = botconfig.prefix;
      let messageArray = message.content.split(" ");
      let cmd = messageArray[0];
  
  
      if(cmd === `${prefix}word`){                                        
          word = messageArray[1];
          message.delete(100);
          console.log("\x1b[33m", "Word has been set to: " + word);
          console.log("\x1b[0m");
          startGame();
      }
  
  
      else if(cmd === `${prefix}reset`){
          console.log("\x1b[34m", "Player has reset the game");
          console.log("\x1b[0m");
          reset();
      }
  
  
      else if(cmd === `${prefix}letter`){
          letter = messageArray[1];
          console.log("\x1b[36m", "Entered letter was: " + letter);
          console.log("\x1b[0m")
          tryletter();
      }
  
  
      function startGame(){
          lWord = word.split("");
          charLength = lWord.length;
  
          for(i = 0; i&lt;charLength; i++) { 
              txt[i] = "?"
            }
  
          outputTxt = txt.join(" ");
          txtOutput();
      }
  
  
      function txtOutput(){
          return message.channel.send(outputTxt);
      }
  
  
      function tryletter() {
          misscount = 0;
  
          for(i = 0; i&lt;charLength; i++) {    
              if(letter === lWord[i]) {
                txt[i] = letter;
                misscount = 0;
              }  
              else {
                misscount++;
              }
              if(misscount === charLength) {
                misscount = 0;
                misses++;
                lostCheck();
                if(misses &gt; 0 &amp;&amp; misses &lt; 8) { 
                return message.channel.send("You have made " + misses + "/8 mistakes!");
                }
              }
          }
  
          winCheck();
          outputTxt = txt.join(" ");
          if(misses &lt; 8){
          return message.channel.send(outputTxt);
          }
  }
  
  
      function winCheck() {
          succes = 0;
  
          for(i=0; i&lt;charLength; i++) {
              if(txt[i] === lWord[i]) {
                succes++
              }
              else {
                succes = 0;
              }
            }
  
            if(succes === charLength) {
              succes = 0;
              for(i=0; i&lt;charLength; i++) {
                  if(txt[i] === lWord[i]) {
                  succes++
                  }   
                  else {
                  succes = 0;
                  }
              } 
  
              if(succes === charLength &amp;&amp; charLength &gt; 0) {
                  succes = 0;
                  message.channel.send("You have won, the word was " + word + "!");
                  console.log("\x1b[32m", "Player has guessed the word");
                  console.log("\x1b[0m");
                  reset();
              }
           }
      }
  
  
      function lostCheck() {
          if(misses === 8){
              message.channel.send("You lost, the word was " + word + "!");
              console.log("\x1b[31m", "Player lost the game");
              console.log("\x1b[0m");
              reset();
          }
      }
  
  
      function reset() {
          word = "";
          letter = "";
          lWord = [];
          charLength = 0;
          txt = [];
          outputTxt = "";
          misscount = 0;
          misses = 0;
          succes = 0;
          console.log("\x1b[35m", "Game has been reset");
          console.log("\x1b[0m");
          return message.channel.send("Game has been reset!");
      }
  
  });
  
  
  bot.login(botconfig.token);
  </code></pre>