use of net.dv8tion.jda.internal.requests.DeferredRestAction in project JDA by DV8FromTheWorld.
the class Guild method retrieveEmote.
/**
* Retrieves a listed emote together with its respective creator.
*
* <p>Note that {@link ListedEmote#getUser()} is only available if the currently
* logged in account has {@link net.dv8tion.jda.api.Permission#MANAGE_EMOTES_AND_STICKERS Permission.MANAGE_EMOTES_AND_STICKERS}.
*
* <p>Possible {@link net.dv8tion.jda.api.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.api.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.api.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI}
* <br>If the provided emote does not correspond to an emote in this guild anymore</li>
* </ul>
*
* @param emote
* The emote
*
* @return {@link net.dv8tion.jda.api.requests.RestAction RestAction} - Type: {@link net.dv8tion.jda.api.entities.ListedEmote ListedEmote}
*
* @since 3.8.0
*/
@Nonnull
@CheckReturnValue
default RestAction<ListedEmote> retrieveEmote(@Nonnull Emote emote) {
Checks.notNull(emote, "Emote");
if (emote.getGuild() != null)
Checks.check(emote.getGuild().equals(this), "Emote must be from the same Guild!");
JDA jda = getJDA();
return new DeferredRestAction<>(jda, ListedEmote.class, () -> {
if (emote instanceof ListedEmote) {
ListedEmote listedEmote = (ListedEmote) emote;
if (listedEmote.hasUser() || !getSelfMember().hasPermission(Permission.MANAGE_EMOTES_AND_STICKERS))
return listedEmote;
}
return null;
}, () -> retrieveEmoteById(emote.getId()));
}
use of net.dv8tion.jda.internal.requests.DeferredRestAction 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.DeferredRestAction 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