Class 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!

Identifier: audio-channel

  • Field Details

  • Constructor Details

    • GuildVoiceUpdateEvent

      public GuildVoiceUpdateEvent(@Nonnull JDA api, long responseNumber, @Nonnull Member member, @Nullable AudioChannel previous)
  • Method Details

    • getChannelLeft

      @Nullable public AudioChannelUnion getChannelLeft()
      The AudioChannelUnion that the Member is moved from
      Returns:
      The AudioChannelUnion, or null if the member was not connected to a channel before
    • getChannelJoined

      @Nullable public AudioChannelUnion getChannelJoined()
      The AudioChannelUnion that was joined
      Returns:
      The AudioChannelUnion, or null if the member has disconnected
    • getPropertyIdentifier

      @Nonnull public String getPropertyIdentifier()
      Description copied from interface: UpdateEvent
      The field name for the updated property

      Example

      @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 interface UpdateEvent<Member, AudioChannel>
      Returns:
      The name of the updated property
    • getEntity

      @Nonnull public Member getEntity()
      Description copied from interface: UpdateEvent
      The affected entity
      Specified by:
      getEntity in interface UpdateEvent<Member, AudioChannel>
      Returns:
      The affected entity
    • getOldValue

      @Nullable public AudioChannel getOldValue()
      Description copied from interface: UpdateEvent
      The old value
      Specified by:
      getOldValue in interface UpdateEvent<Member, AudioChannel>
      Returns:
      The old value
    • getNewValue

      @Nullable public AudioChannel getNewValue()
      Description copied from interface: UpdateEvent
      The new value
      Specified by:
      getNewValue in interface UpdateEvent<Member, AudioChannel>
      Returns:
      The new value