Advertisement
Guest User

Music Loop

a guest
Feb 17th, 2020
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. onst Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. var opus = require('node-opus')
  4. const ytdl = require("ytdl-core");
  5. /*
  6. npm install discord.js
  7. npm install node-opus
  8. npm install ytdl-core
  9. */
  10.  
  11. const token = "YOUR BOT TOKEN";
  12. const voiceChannel = "CHANNEL ID";
  13. const video_url = "YOUTUBE URL";
  14.  
  15. client.on('ready', () => {
  16. console.log(`User : ${client.user.tag}!`)
  17. const streamOptions = { seek : 0, volume: 1 }
  18. let vv = client.channels.get(voiceChannel);
  19. vv.join().then(connection => {
  20. function loopbaby (connection) {
  21. const stream = ytdl(video_url, { filter: 'audioonly' });
  22. const dispatcher = connection.playStream(stream, streamOptions)
  23.  
  24. dispatcher.on('end', () => {
  25. loopbaby(connection);
  26. });
  27. }
  28. loopbaby(connection)
  29. })
  30. });
  31. client.login(token);
  32.  
  33. //By Toxic Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement