title: TypeError: Cannot read property 'split' of undefined in discord and nodejs
body: <p>this is the error</p>
  <pre><code>let token = msg.content.split(' ');
                            ^
  
  TypeError: Cannot read property 'split' of undefined
      at Client.msg (/app/bot.js:15:27)
      at Client.emit (events.js:196:13)
      at MessageCreateAction.handle (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
      at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
      at WebSocketManager.handlePacket (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
      at WebSocketShard.onPacket (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
      at WebSocketShard.onMessage (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
      at WebSocket.onMessage (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/ws/7.4.2/node_modules/ws/lib/event-target.js:132:16)
      at WebSocket.emit (events.js:196:13)
      at Receiver.receiverOnMessage (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/ws/7.4.2/node_modules/ws/lib/websocket.js:825:20)
  </code></pre>
  <p>this is the code</p>
  <pre><code>console.log(&quot;loding&quot;);
  const Discord = require(&quot;discord.js&quot;);
  const client = new Discord.Client();
  
  client.login(process.env.SECRET);
  
  client.on(&quot;ready&quot;, () =&gt; {
    console.log(`Logged in as ${client.user.tag}!`);
  });
  
  client.on(&quot;message&quot;, msg);
  
      function msg() {
  </code></pre>
  <p>this line gives error</p>
  <p>let token = msg.content.split(' ');</p>
  <pre><code>  if ((msg.channel.id = &quot;791583092275937303&quot;)) {
      if (token[0] === &quot;ping&quot;) {
        msg.reply(&quot;Pong!&quot;);
      } else if (token[0] === &quot;!gif&quot;) {
        msg.reply(&quot;ok wait&quot;);
       
        
        
        
        
        
  </code></pre>
  <p>i have blanked it out</p>
  <pre><code>      let APIKEY = &quot;**************&quot;;
        let limit = &quot;100&quot;;
        let search= 'ok';
        let rating = 'g'
        if (token.length &gt; 1){
          search.slice(1,search.length).join(&quot; &quot;);
        }
        
        const gifForm = document.querySelector(&quot;#gif-form&quot;);
        gifForm.addEventListener(&quot;submit&quot;, fetchGiphs);
  
        function fetchGiphs(e) {
          e.preventDefault();
  </code></pre>
  <p>this fetches giphy gif</p>
  <pre><code>        fetch(
            `https://api.giphy.com/v1/gifs/search?&amp;q=${search}&amp;limit=${limit}&amp;api_key=${APIKEY}&amp;rating=${rating}`
          )
            .then(response =&gt; {
              return response.json();
            })
            .then(resp =&gt; {
  </code></pre>
  <p>// Here we get the data array from the response object</p>
  <pre><code>let dataArray = resp.data;
              console.log(dataArray);
              msg.channel.send()
  })        
  </code></pre>
  <p>// We pass the array to showGiphs function</p>
  <p>// We use catch method for Error handling</p>
  <pre><code> .catch(err =&gt; console.log(err)); 
        }
      }
    }
  }
  </code></pre>