use of org.javacord.core.entity.channel.GroupChannelImpl in project Javacord by BtoBastian.
the class ReadyHandler method handle.
@Override
public void handle(JsonNode packet) {
// Purge the cache first
api.purgeCache();
JsonNode guilds = packet.get("guilds");
for (JsonNode guildJson : guilds) {
if (guildJson.has("unavailable") && guildJson.get("unavailable").asBoolean()) {
api.addUnavailableServerToCache(guildJson.get("id").asLong());
continue;
}
new ServerImpl(api, guildJson);
}
// https://github.com/hammerandchisel/discord-api-docs/issues/184
if (packet.has("private_channels")) {
JsonNode privateChannels = packet.get("private_channels");
for (JsonNode channelJson : privateChannels) {
switch(ChannelType.fromId(channelJson.get("type").asInt())) {
case PRIVATE_CHANNEL:
new PrivateChannelImpl(api, channelJson);
break;
case GROUP_CHANNEL:
new GroupChannelImpl(api, channelJson);
break;
default:
logger.warn("Unknown or unexpected channel type. Your Javacord version might be out of date!");
}
}
}
api.setYourself(new UserImpl(api, packet.get("user"), (MemberImpl) null, null));
}
use of org.javacord.core.entity.channel.GroupChannelImpl in project Javacord by BtoBastian.
the class ChannelCreateHandler method handleGroupChannel.
/**
* Handles a group channel creation.
*
* @param channel The channel data.
*/
private void handleGroupChannel(JsonNode channel) {
long channelId = channel.get("id").asLong();
if (!api.getGroupChannelById(channelId).isPresent()) {
GroupChannel groupChannel = new GroupChannelImpl(api, channel);
GroupChannelCreateEvent event = new GroupChannelCreateEventImpl(groupChannel);
api.getEventDispatcher().dispatchGroupChannelCreateEvent(api, groupChannel.getMembers(), event);
}
}
Aggregations