-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Add Guild#retrieveMemberVoiceState
#2729
base: master
Are you sure you want to change the base?
Conversation
src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Austin Keener <[email protected]>
Co-authored-by: Austin Keener <[email protected]>
Co-authored-by: Florian Spieß <[email protected]>
src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java
Outdated
Show resolved
Hide resolved
{ | ||
EntityBuilder entityBuilder = jda.getEntityBuilder(); | ||
DataObject voiceStateData = response.getObject(); | ||
MemberImpl member = entityBuilder.createMember(this, voiceStateData.getObject("member"), voiceStateData, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not pass the voice state to createMember
here since it will become stale and inconsistent.
|
||
final long channelId = voiceStateJson.getLong("channel_id"); | ||
final long channelId = newVoiceStateJson.getLong("channel_id"); | ||
AudioChannel audioChannel = (AudioChannel) guild.getGuildChannelById(channelId); | ||
if (audioChannel != null) | ||
((AudioChannelMixin<?>) audioChannel).getConnectedMembersMap().put(member.getIdLong(), member); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid updating the channel connected members cache unless we actually cache voice states, otherwise this cache is incredibly unreliable.
…java Co-authored-by: Florian Spieß <[email protected]>
Pull Request Etiquette
Changes
Closes Issue: NaN
Description
Discord recently added an API endpoint to get a user's voice state in a guild (https://discord.com/developers/docs/resources/voice).
Adds
Guild#retrieveMemberVoiceState
,Guild#retrieveMemberVoiceStateById(long)
andGuild#retrieveMemberVoiceStateById(String)
that send a request and create a newGuildVoiceState
if not already cached.Also makes changes to
EntityBuilder
to allow the creation of voice states from JSON andRoute
for the new endpoint.