Rather than make a new resource for each player, the bot uses one resource / connection to ClassicFM for each channel.
This commit is contained in:
parent
bf977c24dc
commit
80d1baad4e
|
@ -20,6 +20,8 @@ client.once('ready', () => {
|
||||||
console.log('Bot is ready!');
|
console.log('Bot is ready!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const resource = dVC.createAudioResource('https://icecast.thisisdax.com/ClassicFM', {inlineVolume: true, silencePaddingFrames: 5});
|
||||||
|
|
||||||
client.on('messageCreate', async message => {
|
client.on('messageCreate', async message => {
|
||||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||||
|
|
||||||
|
@ -48,14 +50,14 @@ client.on('messageCreate', async message => {
|
||||||
const streamURL = lines[0];
|
const streamURL = lines[0];
|
||||||
|
|
||||||
console.log(`Playing stream: ${streamURL}`);
|
console.log(`Playing stream: ${streamURL}`);
|
||||||
JoinChannel(voiceChannel, 'https://icecast.thisisdax.com/ClassicFM', 2);
|
JoinChannel(voiceChannel, resource, 2);
|
||||||
}
|
}
|
||||||
) }
|
) }
|
||||||
});
|
});
|
||||||
|
|
||||||
let streamJob = null;
|
let streamJob = null;
|
||||||
|
|
||||||
function JoinChannel(channel, track, volume) {
|
function JoinChannel(channel, resource, volume) {
|
||||||
const connection = dVC.joinVoiceChannel({
|
const connection = dVC.joinVoiceChannel({
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
guildId: channel.guild.id,
|
guildId: channel.guild.id,
|
||||||
|
@ -80,7 +82,6 @@ function JoinChannel(channel, track, volume) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const resource = dVC.createAudioResource(track, {inlineVolume: true, silencePaddingFrames: 5});
|
|
||||||
const player = dVC.createAudioPlayer();
|
const player = dVC.createAudioPlayer();
|
||||||
resource.volume.setVolume(2);
|
resource.volume.setVolume(2);
|
||||||
connection.subscribe(player)
|
connection.subscribe(player)
|
||||||
|
|
Loading…
Reference in a new issue