Class GuildVoiceUpdateEvent
java.lang.Object
net.dv8tion.jda.api.events.Event
net.dv8tion.jda.api.events.guild.GenericGuildEvent
net.dv8tion.jda.api.events.guild.voice.GenericGuildVoiceEvent
net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent
- All Implemented Interfaces:
GenericEvent
,UpdateEvent<Member,
AudioChannel>
public class GuildVoiceUpdateEvent
extends GenericGuildVoiceEvent
implements UpdateEvent<Member,AudioChannel>
Indicates that a
Member
joined or left an AudioChannel
.
Can be used to detect when a Member leaves/joins an AudioChannel.
Example
AudioChannelUnion joinedChannel = event.getChannelJoined();
AudioChannelUnion leftChannel = event.getChannelLeft();
if (joinedChannel != null) {
// the member joined an audio channel
}
if (leftChannel != null) {
// the member left an audio channel
}
if (joinedChannel != null && leftChannel != null) {
// the member moved between two audio channels in the same guild
}
Requirements
This event requires the VOICE_STATE
CacheFlag to be enabled, which requires
the GUILD_VOICE_STATES
intent.
createLight(String)
disables that CacheFlag by default!
Additionally, this event requires the MemberCachePolicy
to cache the updated members. Discord does not specifically tell us about the updates, but merely tells us the
member was updated and gives us the updated member object. In order to fire a specific event like this we
need to have the old member cached to compare against.
Identifier: audio-channel
-
Field Summary
-
Constructor Summary
ConstructorDescriptionGuildVoiceUpdateEvent
(JDA api, long responseNumber, Member member, AudioChannel previous) -
Method Summary
Modifier and TypeMethodDescriptionTheAudioChannelUnion
that was joinedTheAudioChannelUnion
that theMember
is moved fromThe affected entityThe new valueThe old valueThe field name for the updated propertyMethods inherited from class net.dv8tion.jda.api.events.guild.voice.GenericGuildVoiceEvent
getMember, getVoiceState
Methods inherited from class net.dv8tion.jda.api.events.guild.GenericGuildEvent
getGuild
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getRawData, getResponseNumber, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.events.GenericEvent
getJDA, getRawData, getResponseNumber
Methods inherited from interface net.dv8tion.jda.api.events.UpdateEvent
getEntityType
-
Field Details
-
IDENTIFIER
- See Also:
-
-
Constructor Details
-
GuildVoiceUpdateEvent
-
-
Method Details
-
getChannelLeft
TheAudioChannelUnion
that theMember
is moved from- Returns:
- The
AudioChannelUnion
, ornull
if the member was not connected to a channel before
-
getChannelJoined
TheAudioChannelUnion
that was joined- Returns:
- The
AudioChannelUnion
, ornull
if the member has disconnected
-
getPropertyIdentifier
Description copied from interface:UpdateEvent
The field name for the updated propertyExample
@Override public void onGenericRoleUpdate(GenericRoleUpdateEvent event) { switch (event.getPropertyIdentifier()) { case RoleUpdateColorEvent.IDENTIFIER: System.out.printf("Updated color for role: %s%n", event); break; case RoleUpdatePositionEvent.IDENTIFIER: RoleUpdatePositionEvent update = (RoleUpdatePositionEvent) event; System.out.printf("Updated position for role: %s raw(%s->%s)%n", event, update.getOldPositionRaw(), update.getNewPositionRaw()); break; default: return; } }
- Specified by:
getPropertyIdentifier
in interfaceUpdateEvent<Member,
AudioChannel> - Returns:
- The name of the updated property
-
getEntity
Description copied from interface:UpdateEvent
The affected entity- Specified by:
getEntity
in interfaceUpdateEvent<Member,
AudioChannel> - Returns:
- The affected entity
-
getOldValue
Description copied from interface:UpdateEvent
The old value- Specified by:
getOldValue
in interfaceUpdateEvent<Member,
AudioChannel> - Returns:
- The old value
-
getNewValue
Description copied from interface:UpdateEvent
The new value- Specified by:
getNewValue
in interfaceUpdateEvent<Member,
AudioChannel> - Returns:
- The new value
-