BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / discord.io / examples / audio.js

audio.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
audio.js 871 B Download Raw
1var Discord = require('discord.io');
2var fs = require('fs');
3
4var client = new Discord.Client({
5 autorun: true,
6 token: ""
7});
8
9var VCID = "";
10var song = "file.mp3";
11
12client.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