Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to change default volume #264

Merged
merged 3 commits into from
Feb 9, 2024
Merged

Conversation

TannerGabriel
Copy link
Owner

Add the option to adjust the default volume of the player inside config.json.

Resolves: #263

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>
@elboletaire
Copy link

Haven't tried it yet, but I don't see the /volume command storing the value. Don't you think it makes total sense to store it when using the volume command?

@TannerGabriel
Copy link
Owner Author

The current /volume command is intended to change the volume of the current queue if some songs or a playlist is quieter/louder than usual. If we want to change the volume variable for the play command, we would need to store the value somehow, and I would add another command for this instead of changing the current one.

Now the question remains how to store the value (write it into JSON file, environment variable, public variable, etc.). If you have any ideas on how you would like to implement it, let me know.

@elboletaire
Copy link

I don't share that idea about the volume for the queue... I do understand it, but I don't share it, since usually the problem is not from an entire queue, but from a single song... so if the volume does reset on every song, that would make sense to not store it to the settings, but considering we're talking about a volume setting being reused only during the first play in the queue... I personally would share that and use /volume to set the volume both in settings.json and in memory for the current plays.

There's also the issue about the bot not disconnecting anymore, so the volume stored is in fact reused for consequent queues.

@elboletaire
Copy link

@TannerGabriel what do you think about adding a package like conf for managing (reading and writing) the configuration? https://www.npmjs.com/package/conf

I may be able to make a PR during the next two weeks (not too much free time these days...). If you agree using the package I would using just for the volume for now, following the behavior I described above (reusing the /volume command to store it directly into the settings file, and read from that file every time player.play command is executed).

@TannerGabriel
Copy link
Owner Author

Apologies for the delayed reply, @elboletaire. I've been tied up and couldn't get around to this until now.

Your suggestion on maintaining the volume makes sense, and I'm on board with modifying the existing command, provided we update the README accordingly.

The conf package seems suitable, so let's proceed with that. Would you like to make a PR, or should I go ahead and update this PR?

@elboletaire
Copy link

The conf package seems suitable, so let's proceed with that. Would you like to make a PR, or should I go ahead and update this PR?

Please, go ahead!

Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>
Signed-off-by: TannerGabriel <gabrieltanner.code@gmail.com>
@TannerGabriel
Copy link
Owner Author

Implementation should be ready for review.

Copy link

@elboletaire elboletaire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It calls my attention the async import of conf in the volume command. I would import it normally, but maybe you have your reasons (?) I understand you want to avoid loading the conf package unless the volume command is really used, but I'm not sure of the actual purpose of doing this.

@TannerGabriel
Copy link
Owner Author

Currently, the files are CommonJS modules, which is why I use the require syntax to import packages. The conf package does not seem to support this syntax (only supports ESM) and therefore needs to be imported dynamically.

I will probably refactor the whole bot to ES modules in the future. After that, we should be able to import conf using import {Conf} from 'conf'.

@TannerGabriel TannerGabriel merged commit 62f58e9 into master Feb 9, 2024
2 checks passed
@elboletaire
Copy link

Ah, that makes total sense. BTW looks like the docker image failed with a random connection error to npmjs (?)

@TannerGabriel TannerGabriel deleted the feat/default-volume branch February 9, 2024 10:00
@TannerGabriel
Copy link
Owner Author

Thanks for the notice. Yes, it seemed to be a connection error, but re-running didn't seem to fix the problem. Since I used deprecated versions of all the actions I used the opportunity to update the actions and it seems to work again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Volume gets down every time the bot disconnects
2 participants