use of net.dv8tion.jda.internal.JDAImpl in project JDA by DV8FromTheWorld.
the class GuildImpl method retrieveMemberById.
@Nonnull
@Override
public RestAction<Member> retrieveMemberById(long id, boolean update) {
JDAImpl jda = getJDA();
if (id == jda.getSelfUser().getIdLong())
return new CompletedRestAction<>(jda, getSelfMember());
return new DeferredRestAction<>(jda, Member.class, () -> getMember(id, update, jda), () -> {
// otherwise we need to update the member with a REST request first to get the nickname/roles
Route.CompiledRoute route = Route.Guilds.GET_MEMBER.compile(getId(), Long.toUnsignedString(id));
return new RestActionImpl<>(jda, route, (resp, req) -> {
MemberImpl member = jda.getEntityBuilder().createMember(this, resp.getObject());
jda.getEntityBuilder().updateMemberCache(member);
return member;
});
});
}
use of net.dv8tion.jda.internal.JDAImpl in project JDA by DV8FromTheWorld.
the class MessageReactionBulkRemoveHandler method handleInternally.
@Override
protected Long handleInternally(DataObject content) {
final long messageId = content.getLong("message_id");
final long channelId = content.getLong("channel_id");
JDAImpl jda = getJDA();
if (!content.isNull("guild_id")) {
long guildId = content.getUnsignedLong("guild_id");
if (api.getGuildSetupController().isLocked(guildId))
return guildId;
}
// TODO-v5-unified-channel-cache
MessageChannel channel = jda.getTextChannelById(channelId);
if (channel == null)
channel = jda.getNewsChannelById(channelId);
if (channel == null)
channel = jda.getThreadChannelById(channelId);
if (channel == null) {
jda.getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
EventCache.LOG.debug("Received a reaction for a channel that JDA does not currently have cached channel_id: {} message_id: {}", channelId, messageId);
return null;
}
jda.handleEvent(new MessageReactionRemoveAllEvent(jda, responseNumber, messageId, channel));
return null;
}
use of net.dv8tion.jda.internal.JDAImpl in project JDA by DV8FromTheWorld.
the class GuildSetupNode method completeSetup.
private void completeSetup() {
updateStatus(GuildSetupController.Status.BUILDING);
JDAImpl api = getController().getJDA();
for (TLongIterator it = removedMembers.iterator(); it.hasNext(); ) members.remove(it.next());
removedMembers.clear();
GuildImpl guild = api.getEntityBuilder().createGuild(id, partialGuild, members, expectedMemberCount);
updateAudioManagerReference(guild);
switch(type) {
case AVAILABLE:
api.handleEvent(new GuildAvailableEvent(api, api.getResponseTotal(), guild));
getController().remove(id);
break;
case JOIN:
api.handleEvent(new GuildJoinEvent(api, api.getResponseTotal(), guild));
if (requestedChunk)
getController().ready(id);
else
getController().remove(id);
break;
default:
api.handleEvent(new GuildReadyEvent(api, api.getResponseTotal(), guild));
getController().ready(id);
break;
}
updateStatus(GuildSetupController.Status.READY);
GuildSetupController.log.debug("Finished setup for guild {} firing cached events {}", id, cachedEvents.size());
api.getClient().handle(cachedEvents);
api.getEventCache().playbackCache(EventCache.Type.GUILD, id);
}
use of net.dv8tion.jda.internal.JDAImpl 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.JDAImpl in project JDA by DV8FromTheWorld.
the class IInviteContainerMixin method retrieveInvites.
@Nonnull
@Override
default RestAction<List<Invite>> retrieveInvites() {
checkPermission(Permission.MANAGE_CHANNEL);
final Route.CompiledRoute route = Route.Invites.GET_CHANNEL_INVITES.compile(getId());
JDAImpl jda = (JDAImpl) getJDA();
return new RestActionImpl<>(jda, route, (response, request) -> {
EntityBuilder entityBuilder = jda.getEntityBuilder();
DataArray array = response.getArray();
List<Invite> invites = new ArrayList<>(array.length());
for (int i = 0; i < array.length(); i++) invites.add(entityBuilder.createInvite(array.getObject(i)));
return Collections.unmodifiableList(invites);
});
}
Aggregations