Search in sources :

Example 16 with Route

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);
}
Also used : RestActionImpl(net.dv8tion.jda.internal.requests.RestActionImpl) DataObject(net.dv8tion.jda.api.utils.data.DataObject) InsufficientPermissionException(net.dv8tion.jda.api.exceptions.InsufficientPermissionException) Route(net.dv8tion.jda.internal.requests.Route)

Example 17 with Route

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);
}
Also used : RestActionImpl(net.dv8tion.jda.internal.requests.RestActionImpl) DataObject(net.dv8tion.jda.api.utils.data.DataObject) InsufficientPermissionException(net.dv8tion.jda.api.exceptions.InsufficientPermissionException) Route(net.dv8tion.jda.internal.requests.Route) Nonnull(javax.annotation.Nonnull)

Example 18 with Route

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)));
}
Also used : Message(net.dv8tion.jda.api.entities.Message) Checks(net.dv8tion.jda.internal.utils.Checks) JDA(net.dv8tion.jda.api.JDA) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TimeoutException(java.util.concurrent.TimeoutException) MiscUtil(net.dv8tion.jda.api.utils.MiscUtil) Route(net.dv8tion.jda.internal.requests.Route) Function(java.util.function.Function) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Future(java.util.concurrent.Future) WebhookMessageUpdateActionImpl(net.dv8tion.jda.internal.requests.restaction.WebhookMessageUpdateActionImpl) AbstractWebhookClient(net.dv8tion.jda.internal.entities.AbstractWebhookClient) JDAImpl(net.dv8tion.jda.internal.JDAImpl) InteractionHook(net.dv8tion.jda.api.interactions.InteractionHook) DataObject(net.dv8tion.jda.api.utils.data.DataObject) JDALogger(net.dv8tion.jda.internal.utils.JDALogger) LinkedList(java.util.LinkedList) Nonnull(javax.annotation.Nonnull) RestAction(net.dv8tion.jda.api.requests.RestAction) TriggerRestAction(net.dv8tion.jda.internal.requests.restaction.TriggerRestAction) WebhookMessageActionImpl(net.dv8tion.jda.internal.requests.restaction.WebhookMessageActionImpl) JDAImpl(net.dv8tion.jda.internal.JDAImpl) Route(net.dv8tion.jda.internal.requests.Route) Nonnull(javax.annotation.Nonnull)

Example 19 with Route

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);
        });
    });
}
Also used : RestActionImpl(net.dv8tion.jda.internal.requests.RestActionImpl) DataObject(net.dv8tion.jda.api.utils.data.DataObject) DeferredRestAction(net.dv8tion.jda.internal.requests.DeferredRestAction) Route(net.dv8tion.jda.internal.requests.Route) Nonnull(javax.annotation.Nonnull)

Example 20 with Route

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;
        });
    });
}
Also used : PrivateChannel(net.dv8tion.jda.api.entities.PrivateChannel) RestActionImpl(net.dv8tion.jda.internal.requests.RestActionImpl) DataObject(net.dv8tion.jda.api.utils.data.DataObject) DeferredRestAction(net.dv8tion.jda.internal.requests.DeferredRestAction) Route(net.dv8tion.jda.internal.requests.Route) Nonnull(javax.annotation.Nonnull)

Aggregations

Route (net.dv8tion.jda.internal.requests.Route)31 Nonnull (javax.annotation.Nonnull)24 RestActionImpl (net.dv8tion.jda.internal.requests.RestActionImpl)24 DataObject (net.dv8tion.jda.api.utils.data.DataObject)12 JDAImpl (net.dv8tion.jda.internal.JDAImpl)12 InsufficientPermissionException (net.dv8tion.jda.api.exceptions.InsufficientPermissionException)10 AuditableRestActionImpl (net.dv8tion.jda.internal.requests.restaction.AuditableRestActionImpl)10 CheckReturnValue (javax.annotation.CheckReturnValue)9 DataArray (net.dv8tion.jda.api.utils.data.DataArray)8 EntityBuilder (net.dv8tion.jda.internal.entities.EntityBuilder)5 JDA (net.dv8tion.jda.api.JDA)3 HierarchyException (net.dv8tion.jda.api.exceptions.HierarchyException)3 MissingAccessException (net.dv8tion.jda.api.exceptions.MissingAccessException)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 DeferredRestAction (net.dv8tion.jda.internal.requests.DeferredRestAction)2 WebhookEmbed (club.minnced.discord.webhook.send.WebhookEmbed)1 WebhookEmbedBuilder (club.minnced.discord.webhook.send.WebhookEmbedBuilder)1 WebhookMessage (club.minnced.discord.webhook.send.WebhookMessage)1