| 1 | var Discord = require('discord.io'); |
| 2 | var fs = require('fs'); |
| 3 | |
| 4 | var client = new Discord.Client({ |
| 5 | autorun: true, |
| 6 | token: "" |
| 7 | }); |
| 8 | |
| 9 | var VCID = ""; |
| 10 | var song = "file.mp3"; |
| 11 | |
| 12 | client.on('ready', function() { |
| 13 | console.log("%s (%s)", client.username, client.id); |
| 14 | |
| 15 | client.joinVoiceChannel(VCID, function(err, events) { |
| 16 | if (err) return console.error(err); |
| 17 | events.on('speaking', function(userID, SSRC, speakingBool) { |
| 18 | console.log("%s is " + (speakingBool ? "now speaking" : "done speaking"), userID ); |
| 19 | }); |
| 20 | |
| 21 | client.getAudioContext(VCID, function(err, stream) { |
| 22 | if (err) return console.error(err); |
| 23 | fs.createReadStream(song).pipe(stream, {end: false}); |
| 24 | stream.on('done', function() { |
| 25 | fs.createReadStream(song).pipe(stream, {end: false}); |
| 26 | }); |
| 27 | }); |
| 28 | }); |
| 29 | }); |
| 30 | |