Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onst Discord = require('discord.js');
- const client = new Discord.Client();
- var opus = require('node-opus')
- const ytdl = require("ytdl-core");
- /*
- npm install discord.js
- npm install node-opus
- npm install ytdl-core
- */
- const token = "YOUR BOT TOKEN";
- const voiceChannel = "CHANNEL ID";
- const video_url = "YOUTUBE URL";
- client.on('ready', () => {
- console.log(`User : ${client.user.tag}!`)
- const streamOptions = { seek : 0, volume: 1 }
- let vv = client.channels.get(voiceChannel);
- vv.join().then(connection => {
- function loopbaby (connection) {
- const stream = ytdl(video_url, { filter: 'audioonly' });
- const dispatcher = connection.playStream(stream, streamOptions)
- dispatcher.on('end', () => {
- loopbaby(connection);
- });
- }
- loopbaby(connection)
- })
- });
- client.login(token);
- //By Toxic Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement