use of net.dv8tion.jda.internal.requests.Route 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.Route 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.Route in project JDA by DV8FromTheWorld.
the class InteractionHookImpl method retrieveOriginal.
@Nonnull
@Override
public RestAction<Message> retrieveOriginal() {
JDAImpl jda = (JDAImpl) getJDA();
Route.CompiledRoute route = Route.Interactions.GET_ORIGINAL.compile(jda.getSelfUser().getApplicationId(), interaction.getToken());
return onReady(new TriggerRestAction<>(jda, route, (response, request) -> jda.getEntityBuilder().createMessageWithChannel(response.getObject(), getInteraction().getMessageChannel(), false)));
}
use of net.dv8tion.jda.internal.requests.Route 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);
});
});
}
use of net.dv8tion.jda.internal.requests.Route in project JDA by DV8FromTheWorld.
the class UserImpl method openPrivateChannel.
@Nonnull
@Override
public RestAction<PrivateChannel> openPrivateChannel() {
return new DeferredRestAction<>(getJDA(), PrivateChannel.class, this::getPrivateChannel, () -> {
Route.CompiledRoute route = Route.Self.CREATE_PRIVATE_CHANNEL.compile();
DataObject body = DataObject.empty().put("recipient_id", getId());
return new RestActionImpl<>(getJDA(), route, body, (response, request) -> {
PrivateChannel priv = api.getEntityBuilder().createPrivateChannel(response.getObject(), this);
UserImpl.this.privateChannelId = priv.getIdLong();
return priv;
});
});
}
Aggregations