Cloud Stack Ninja

Here is my whole code for the command, the problem is when I do -move everyone 123132123123(example channel id). The command works perfectly but gives me an error of (node:317) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'voice' of undefined. I have been trying to .catch() the error but it still gives me that error. Whenever I do return member.voice.setChannel(`${move}`);. The error stops but also only moves me for some reason...

 if (command === 'move') {
   if (!message.member.permissions.has("MOVE_MEMBERS")) return message.channel.send(':x: **You do not have the permission to use this command!**');
   const args = message.content.slice(prefix.length).trim().split(/ +/g);
   const command = args.shift().toLowerCase();
   const mem = message.mentions.members.first()
   let move = args[1]; // Remember arrays are 0-based!.
   let move2 = args[2];
   let idcheckchannel1 = client.channels.cache.get(move)
   let idcheckchannel2 = client.channels.cache.get(move2)
   if (!args[0]) return message.channel.send('Please mention user and voice channel ID/IDs')
   if (!args[1]) return message.channel.send('Please mention voice channel ID/IDs')

   if(args[0] === 'everyone' && !move2) {
     if (!idcheckchannel1) return message.channel.send('Please use a valid voice channel ID')
      let channel = message.guild.channels.cache.get(message.member.voice.channel.id);
     for (const [memberID, member] of channel.members)
     member.voice.setChannel(`${move}`);
       }

   if (!mem.voice.channel) return message.channel.send('User is not in voice channel')

   if (!move2) {
     if (!idcheckchannel1) return message.channel.send('Please use a valid voice channel ID')
     mem.voice.setChannel(`${move}`)
   } else {

     if (!idcheckchannel1) return message.channel.send('Please use a valid voice channel ID')
     if (!idcheckchannel2) return message.channel.send('Please use a valid voice channel ID')
     mem.voice.setChannel(`${move}`)
     mem.voice.setChannel(`${move2}`)
   }
 }


Read more here: https://stackoverflow.com/questions/64408175/node-js-discord-bot-typeerror-cannot-read-property-of-voice-of-undefined

Content Attribution

This content was originally published by Flappy at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: