Gods this thing is so rickety
parent
b964f4acfd
commit
a0c4630bed
|
@ -6,6 +6,7 @@ module.exports = class AudioQueue {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.queue = [];
|
this.queue = [];
|
||||||
this.current = undefined;
|
this.current = undefined;
|
||||||
|
this.api.player.on(Voice.AudioPlayerStatus.Idle, this.handleStop.bind(this));
|
||||||
}
|
}
|
||||||
playNext() {
|
playNext() {
|
||||||
if (this.queue.length == 0) {
|
if (this.queue.length == 0) {
|
||||||
|
@ -13,10 +14,8 @@ module.exports = class AudioQueue {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.current = this.api.play(this.queue[0]);
|
this.current = this.api.play(this.queue[0]);
|
||||||
this.api.player.on(Voice.AudioPlayerStatus.Idle, this.handleStop.bind(this));
|
|
||||||
}
|
}
|
||||||
handleStop(current) {
|
handleStop(current) {
|
||||||
console.log(`Handling stop`);
|
|
||||||
this.queue.shift();
|
this.queue.shift();
|
||||||
this.playNext();
|
this.playNext();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = function (bot, api) {
|
||||||
if (!oldState.channel) {
|
if (!oldState.channel) {
|
||||||
joined = true;
|
joined = true;
|
||||||
let conn=api.getConnectionForVoiceChannel(channel);
|
let conn=api.getConnectionForVoiceChannel(channel);
|
||||||
api.queue=new AudioQueue(conn, api);
|
if (!api.queue) api.queue=new AudioQueue(conn, api);
|
||||||
}
|
}
|
||||||
|
|
||||||
let username = newState.member.displayName;
|
let username = newState.member.displayName;
|
||||||
|
|
|
@ -7,7 +7,7 @@ module.exports = function (bot, api) {
|
||||||
const channel = await bot.channels.fetch(process.env.CHANNEL);
|
const channel = await bot.channels.fetch(process.env.CHANNEL);
|
||||||
await api.joinChannel(channel);
|
await api.joinChannel(channel);
|
||||||
let conn=api.getConnectionForVoiceChannel(channel);
|
let conn=api.getConnectionForVoiceChannel(channel);
|
||||||
api.queue=new AudioQueue(conn, api);
|
if (!api.queue) api.queue=new AudioQueue(conn, api);
|
||||||
api.queue.add(__dirname + "/../../sysstart.wav");
|
api.queue.add(__dirname + "/../../sysstart.wav");
|
||||||
api.speak(channel, api.strings.WELCOME);
|
api.speak(channel, api.strings.WELCOME);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue