serenity icon indicating copy to clipboard operation
serenity copied to clipboard

Getting a user's voice channel from an interaction

Open bollian opened this issue 4 years ago • 6 comments

I'm receiving an application command for joining a voice channel, but can't figure out how to get the sender's current voice channel. As far as I can tell, the correct path is to get a VoiceState from the User contained within the ApplicationCommandInteraction I'm handed as part of the interaction handler. All examples I can find use the Guild object to achieve this, but I can't figure out how to construct one / fill the cache with one.

bollian avatar Nov 26 '21 23:11 bollian

https://gitlab.com/vicky5124/lavalink-rs/-/blob/master/examples/poise_basic_queue/src/main.rs#L151-188 This is how I do it with poise, if it helps.

vicky5124 avatar Nov 26 '21 23:11 vicky5124

As far as I can tell, poise just gets the information from the cache using Cache::guild. I have code that tries to do this, but my cache isn't containing the necessary Guild.

bollian avatar Nov 27 '21 00:11 bollian

Guild is obtained on startup, make sure you have the basic GUILDS intent enabled, and that the cache_ready event fired up. Also, there were issues building cache on past versions, make sure you are using the latest version of serenity!

vicky5124 avatar Nov 27 '21 19:11 vicky5124

Adding the intent did the trick, thanks! Would you mind if I added that advice to the Cache documentation?

bollian avatar Nov 30 '21 03:11 bollian

The intents or cache documentation should be updated noting which cache elements will become available with each intent, and not only for this use case.

vicky5124 avatar Nov 30 '21 12:11 vicky5124

Unfortunately, I don't think I know the API well enough to do that.

bollian avatar Dec 06 '21 23:12 bollian

Done in #2249

kangalio avatar Nov 05 '22 20:11 kangalio