benevolent27

Discord Bot Snippet - Creating new voice channel

Mar 10th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('voiceStateUpdate', (oldMember, newMember) => {
  2.     var oldVoiceChannel=oldMember.voiceChannel;
  3.     var voiceChannel=newMember.voiceChannel;
  4.     if (voiceChannel){
  5.         if (oldVoiceChannel){
  6.             console.log(newMember.user.tag + " has left voice channel, '" + oldVoiceChannel.name + "' and joined '" + voiceChannel.name + "'!");
  7.             console.log(oldVoiceChannel.name + " now has a user total of: " + oldVoiceChannel.members.array().length);
  8.         }
  9.         else {
  10.             console.log(newMember.user.tag + " has joined voice channel: " + voiceChannel.name + "!");
  11.         }
  12.         if (voiceChannel.id == baseVoiceChannelID){
  13.             function success(result) {
  14.                 console.log("It was a success: " + result);
  15.             };
  16.             function fail(error) {
  17.                 console.log("It was a failure: " + error);
  18.                 };
  19.             console.log(newMember.user.tag + " has joined the special channel! YAY!");
  20.             voiceChannel.clone('TestVoice2', true)
  21.             .then(vc => vc.setParent(voiceChannel.parentID))
  22.             .catch(console.error);
  23.         }
  24.     }
  25.     else if (oldVoiceChannel){
  26.         console.log(newMember.user.tag + " has left voice channel, '" + oldVoiceChannel.name + "'!");
  27.     }
  28. });
Advertisement
Add Comment
Please, Sign In to add comment