Make use of the defined volume variable

One of @moosecrab 's previous commits defined this variable at the global scope, but then did nothing with it
This commit is contained in:
Robert 2022-06-11 02:03:11 -07:00
parent 4209113dc0
commit ed28d27738

6
bot.js
View File

@ -8,7 +8,7 @@ const ytdl = require('ytdl-core-discord');
// Include our local auth key, so that we don't leak keys
const auth = require('./auth.json');
// Volume for playback (fraction)
var volume = 0.6;
const volume = 0.60;
// **** PROGRAM START ****
// This program is 2 lines of code, the rest is callback function definition, wherein the bot magic happens
@ -115,7 +115,7 @@ client.on('message', async message => {
const connection = await message.member.voice.channel.join();
// TODO: Switch to fs-based file read?
// Play the sound file as requested
const dispatcher = connection.play(soundPath, { volume: 0.60 });
const dispatcher = connection.play(soundPath, { volume: volume });
dispatcher.on('start', () => { console.log(`Playing ${soundPath}`); });
dispatcher.on('finish', () => { console.log(`Finished ${soundPath}`); });
dispatcher.on('error', console.error);
@ -165,7 +165,7 @@ client.on('message', async message => {
// Play the video as requested
try {
//TODO: process the timestamp with ffmpeg or whatever
const dispatcher = connection.play(await ytdl(yturl), { type: 'opus', volume: 0.60, begin: timestamp});
const dispatcher = connection.play(await ytdl(yturl), { type: 'opus', volume: volume, begin: timestamp});
dispatcher.on('start', () => { console.log(`Playing ${yturl}`); });
dispatcher.on('finish', () => { console.log(`Finished ${yturl}`); });
dispatcher.on('error', console.error);