Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = (...args) => ({
- run(...args) {
- if (suffix === 'stop') {
- bot.removeListener('voiceStateUpdate', this.test);
- } else {
- this.test(bot, config, msg, args, suffix);
- }
- },
- test(...args) {
- bot.on('voiceStateUpdate', (oldMember, newMember) => {
- console.log('Event is happening');
- if (newMember.user.username !== suffix || suffix === 'none') {
- console.log(`Following ${suffix}`);
- console.log(`Will not follow ${newMember.user.username}`);
- return;
- }
- const newUserChannel = newMember.voiceChannel;
- const oldUserChannel = oldMember.voiceChannel;
- if (oldUserChannel === undefined && newUserChannel !== undefined) {
- const ytdl = require('ytdl-core');
- // const streamOptions = { seek: 0, volume: 1 };
- const broadcast = bot.createVoiceBroadcast();
- newUserChannel.join().then().then((connection) => {
- const stream = ytdl('https://www.youtube.com/watch?v=4RPEsuXMMTA', { filter: 'audioonly' });
- broadcast.playStream(stream);
- connection.playBroadcast(broadcast);
- }).catch(console.error);
- } else if (newUserChannel === undefined) {
- // User leaves a voice channel
- } else if (oldUserChannel !== undefined && newUserChannel !== undefined) {
- // User switches channel
- // Play streams using ytdl-core
- const ytdl = require('ytdl-core');
- // const streamOptions = { seek: 0, volume: 1 };
- const broadcast = bot.createVoiceBroadcast();
- newUserChannel.join().then().then((connection) => {
- const stream = ytdl('https://www.youtube.com/watch?v=4RPEsuXMMTA', { filter: 'audioonly' });
- broadcast.playStream(stream);
- connection.playBroadcast(broadcast);
- }).catch(console.error);
- }
- });
- },
- help: {
- name: 'follow',
- desc: 'Follows a user',
- usage: 'follow'
- },
- config: {
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement