Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = (...args) => ({
  2.   run(...args) {
  3.     if (suffix === 'stop') {
  4.       bot.removeListener('voiceStateUpdate', this.test);
  5.     } else {
  6.       this.test(bot, config, msg, args, suffix);
  7.     }
  8.   },
  9.   test(...args) {
  10.     bot.on('voiceStateUpdate', (oldMember, newMember) => {
  11.       console.log('Event is happening');
  12.       if (newMember.user.username !== suffix || suffix === 'none') {
  13.         console.log(`Following ${suffix}`);
  14.         console.log(`Will not follow ${newMember.user.username}`);
  15.         return;
  16.       }
  17.       const newUserChannel = newMember.voiceChannel;
  18.       const oldUserChannel = oldMember.voiceChannel;
  19.       if (oldUserChannel === undefined && newUserChannel !== undefined) {
  20.         const ytdl = require('ytdl-core');
  21.         // const streamOptions = { seek: 0, volume: 1 };
  22.         const broadcast = bot.createVoiceBroadcast();
  23.         newUserChannel.join().then().then((connection) => {
  24.           const stream = ytdl('https://www.youtube.com/watch?v=4RPEsuXMMTA', { filter: 'audioonly' });
  25.           broadcast.playStream(stream);
  26.           connection.playBroadcast(broadcast);
  27.         }).catch(console.error);
  28.       } else if (newUserChannel === undefined) {
  29.       // User leaves a voice channel
  30.       } else if (oldUserChannel !== undefined && newUserChannel !== undefined) {
  31.         // User switches channel
  32.         // Play streams using ytdl-core
  33.         const ytdl = require('ytdl-core');
  34.         // const streamOptions = { seek: 0, volume: 1 };
  35.         const broadcast = bot.createVoiceBroadcast();
  36.         newUserChannel.join().then().then((connection) => {
  37.           const stream = ytdl('https://www.youtube.com/watch?v=4RPEsuXMMTA', { filter: 'audioonly' });
  38.           broadcast.playStream(stream);
  39.           connection.playBroadcast(broadcast);
  40.         }).catch(console.error);
  41.       }
  42.     });
  43.   },
  44.   help: {
  45.     name: 'follow',
  46.     desc: 'Follows a user',
  47.     usage: 'follow'
  48.   },
  49.   config: {
  50.  
  51.   }
  52. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement