Class GuildVoiceRequestToSpeakEvent
- 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.GuildVoiceRequestToSpeakEvent
-
- All Implemented Interfaces:
GenericEvent
public class GuildVoiceRequestToSpeakEvent extends GenericGuildVoiceEvent
Indicates that a guild member has updated theirRequest-to-Speak
.If
getNewTime()
is non-null, this means the member has raised their hand and wants to speak. You can useapproveSpeaker()
ordeclineSpeaker()
to handle this request if you havePermission.VOICE_MUTE_OTHERS
.Requirements
These events require the
VOICE_STATE
CacheFlag to be enabled, which requires theGUILD_VOICE_STATES
intent.createLight(String)
disables that CacheFlag by default!Additionally, these events require 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 specific events like these we need to have the old member cached to compare against.
-
-
Constructor Summary
Constructors Constructor Description GuildVoiceRequestToSpeakEvent(JDA api, long responseNumber, Member member, java.time.OffsetDateTime oldTime, java.time.OffsetDateTime newTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RestAction<java.lang.Void>
approveSpeaker()
Promote the member to speaker.RestAction<java.lang.Void>
declineSpeaker()
Reject this membersrequest to speak
.java.time.OffsetDateTime
getNewTime()
java.time.OffsetDateTime
getOldTime()
-
Methods 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, getResponseNumber
-
-
-
-
Method Detail
-
getOldTime
@Nullable public java.time.OffsetDateTime getOldTime()
- Returns:
- The old timestamp, or null if this member did not request to speak before
-
getNewTime
@Nullable public java.time.OffsetDateTime getNewTime()
- Returns:
- The new timestamp, or null if the request to speak was declined or cancelled
-
approveSpeaker
@Nonnull @CheckReturnValue public RestAction<java.lang.Void> approveSpeaker()
Promote the member to speaker.This requires a non-null
getNewTime()
. You can useGuildVoiceState.inviteSpeaker()
to invite the member to become a speaker if they haven't requested to speak.This does nothing if the member is not connected to a
StageChannel
.- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.VOICE_MUTE_OTHERS
in the associatedStageChannel
-
declineSpeaker
@Nonnull @CheckReturnValue public RestAction<java.lang.Void> declineSpeaker()
Reject this membersrequest to speak
.This requires a non-null
getNewTime()
. The member will have to request to speak again.This does nothing if the member is not connected to a
StageChannel
.- Returns:
RestAction
- Throws:
InsufficientPermissionException
- If the currently logged in account does not havePermission.VOICE_MUTE_OTHERS
in the associatedStageChannel
-
-