Search in sources :

Example 1 with ChannelCategoryImpl

use of org.javacord.core.entity.channel.ChannelCategoryImpl in project Javacord by BtoBastian.

the class ServerImpl method getOrCreateChannelCategory.

/**
 * Gets or creates a channel category.
 *
 * @param data The json data of the channel.
 * @return The server text channel.
 */
public ChannelCategory getOrCreateChannelCategory(JsonNode data) {
    long id = Long.parseLong(data.get("id").asText());
    ChannelType type = ChannelType.fromId(data.get("type").asInt());
    synchronized (this) {
        if (type == ChannelType.CHANNEL_CATEGORY) {
            return getChannelCategoryById(id).orElseGet(() -> new ChannelCategoryImpl(api, this, data));
        }
    }
    // Invalid channel type
    return null;
}
Also used : ChannelCategoryImpl(org.javacord.core.entity.channel.ChannelCategoryImpl) ChannelType(org.javacord.api.entity.channel.ChannelType)

Aggregations

ChannelType (org.javacord.api.entity.channel.ChannelType)1 ChannelCategoryImpl (org.javacord.core.entity.channel.ChannelCategoryImpl)1