use of net.dv8tion.jda.internal.requests.RestActionImpl in project JDA by DV8FromTheWorld.
the class StageChannelImpl method requestToSpeak.
@Nonnull
@Override
public RestAction<Void> requestToSpeak() {
Guild guild = getGuild();
Route.CompiledRoute route = Route.Guilds.UPDATE_VOICE_STATE.compile(guild.getId(), "@me");
DataObject body = DataObject.empty().put("channel_id", getId());
// Stage moderators can bypass the request queue by just unsuppressing
if (guild.getSelfMember().hasPermission(this, Permission.VOICE_MUTE_OTHERS))
body.putNull("request_to_speak_timestamp").put("suppress", false);
else
body.put("request_to_speak_timestamp", OffsetDateTime.now().toString());
if (!this.equals(guild.getSelfMember().getVoiceState().getChannel()))
throw new IllegalStateException("Cannot request to speak without being connected to the stage channel!");
return new RestActionImpl<>(getJDA(), route, body);
}
use of net.dv8tion.jda.internal.requests.RestActionImpl in project JDA by DV8FromTheWorld.
the class StageChannelImpl method cancelRequestToSpeak.
@Nonnull
@Override
public RestAction<Void> cancelRequestToSpeak() {
Guild guild = getGuild();
Route.CompiledRoute route = Route.Guilds.UPDATE_VOICE_STATE.compile(guild.getId(), "@me");
DataObject body = DataObject.empty().putNull("request_to_speak_timestamp").put("suppress", true).put("channel_id", getId());
if (!this.equals(guild.getSelfMember().getVoiceState().getChannel()))
throw new IllegalStateException("Cannot cancel request to speak without being connected to the stage channel!");
return new RestActionImpl<>(getJDA(), route, body);
}
use of net.dv8tion.jda.internal.requests.RestActionImpl in project JDA by DV8FromTheWorld.
the class GuildVoiceStateImpl method update.
private RestAction<Void> update(boolean suppress) {
if (requestToSpeak == 0L || !(connectedChannel instanceof StageChannel))
return new CompletedRestAction<>(api, null);
Member selfMember = getGuild().getSelfMember();
boolean isSelf = selfMember.equals(member);
if (!isSelf && !selfMember.hasPermission(connectedChannel, Permission.VOICE_MUTE_OTHERS))
throw new InsufficientPermissionException(connectedChannel, Permission.VOICE_MUTE_OTHERS);
Route.CompiledRoute route = Route.Guilds.UPDATE_VOICE_STATE.compile(guild.getId(), isSelf ? "@me" : getId());
DataObject body = DataObject.empty().put("channel_id", connectedChannel.getId()).put("suppress", suppress);
return new RestActionImpl<>(getJDA(), route, body);
}
use of net.dv8tion.jda.internal.requests.RestActionImpl in project JDA by DV8FromTheWorld.
the class GuildVoiceStateImpl method inviteSpeaker.
@Nonnull
@Override
public RestAction<Void> inviteSpeaker() {
if (!(connectedChannel instanceof StageChannel))
return new CompletedRestAction<>(api, null);
if (!getGuild().getSelfMember().hasPermission(connectedChannel, Permission.VOICE_MUTE_OTHERS))
throw new InsufficientPermissionException(connectedChannel, Permission.VOICE_MUTE_OTHERS);
Route.CompiledRoute route = Route.Guilds.UPDATE_VOICE_STATE.compile(guild.getId(), getId());
DataObject body = DataObject.empty().put("channel_id", connectedChannel.getId()).put("suppress", false).put("request_to_speak_timestamp", OffsetDateTime.now().toString());
return new RestActionImpl<>(getJDA(), route, body);
}
use of net.dv8tion.jda.internal.requests.RestActionImpl in project JDA by DV8FromTheWorld.
the class UserImpl method retrieveProfile.
@Nonnull
@Override
public RestAction<Profile> retrieveProfile() {
return new DeferredRestAction<>(getJDA(), Profile.class, this::getProfile, () -> {
Route.CompiledRoute route = Route.Users.GET_USER.compile(getId());
return new RestActionImpl<>(getJDA(), route, (response, request) -> {
DataObject json = response.getObject();
String bannerId = json.getString("banner", null);
int accentColor = json.getInt("accent_color", User.DEFAULT_ACCENT_COLOR_RAW);
return new Profile(getIdLong(), bannerId, accentColor);
});
});
}
Aggregations