mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
fix some voice stuff
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -132,7 +132,7 @@ class StreamDispatcher extends EventEmitter {
|
|||||||
data.length = 20;
|
data.length = 20;
|
||||||
data.missed = 0;
|
data.missed = 0;
|
||||||
data.startTime = Date.now();
|
data.startTime = Date.now();
|
||||||
this._send();
|
this.stream.once('readable', () => this._send());
|
||||||
}
|
}
|
||||||
|
|
||||||
_pause(value) {
|
_pause(value) {
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ class DefaultPlayer extends BasePlayer {
|
|||||||
|
|
||||||
playFile(file) {
|
playFile(file) {
|
||||||
this._shutdown();
|
this._shutdown();
|
||||||
const fileStream = fs.createReadStream(file);
|
return this.playStream(fs.createReadStream(file));
|
||||||
const pcmStream = this.convertStream(fileStream);
|
}
|
||||||
|
|
||||||
|
playStream(stream) {
|
||||||
|
this._shutdown();
|
||||||
|
const pcmStream = this.convertStream(stream);
|
||||||
const dispatcher = this.playPCMStream(pcmStream);
|
const dispatcher = this.playPCMStream(pcmStream);
|
||||||
return dispatcher;
|
return dispatcher;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ client.on('message', msg => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let disp;
|
const ytdl = require('ytdl-core');
|
||||||
|
|
||||||
client.on('message', msg => {
|
client.on('message', msg => {
|
||||||
if (msg.content.startsWith('/join')) {
|
if (msg.content.startsWith('/join')) {
|
||||||
@@ -205,7 +205,10 @@ client.on('message', msg => {
|
|||||||
msg.channel.guild.channels.get(chan).join()
|
msg.channel.guild.channels.get(chan).join()
|
||||||
.then(conn => {
|
.then(conn => {
|
||||||
msg.reply('done');
|
msg.reply('done');
|
||||||
|
const disp = conn.player.playStream(ytdl('https://www.youtube.com/watch?v=nbXgHAzUWB0', {filter : 'audioonly'}));
|
||||||
conn.player.on('debug', console.log);
|
conn.player.on('debug', console.log);
|
||||||
|
conn.player.on('error', err => console.log(123, err));
|
||||||
|
disp.on('error', err => console.log(123, err));
|
||||||
})
|
})
|
||||||
.catch(console.log);
|
.catch(console.log);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user