use of org.javacord.api.entity.channel.ChannelType in project Javacord by BtoBastian.
the class ServerImpl method getOrCreateServerTextChannel.
/**
* Gets or creates a server text channel.
*
* @param data The json data of the channel.
* @return The server text channel.
*/
public ServerTextChannel getOrCreateServerTextChannel(JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
ChannelType type = ChannelType.fromId(data.get("type").asInt());
synchronized (this) {
switch(type) {
case SERVER_TEXT_CHANNEL:
case // TODO Treat news channels differently
SERVER_NEWS_CHANNEL:
return getTextChannelById(id).orElseGet(() -> new ServerTextChannelImpl(api, this, data));
default:
// Invalid channel type
return null;
}
}
}
use of org.javacord.api.entity.channel.ChannelType in project Javacord by BtoBastian.
the class ServerImpl method getOrCreateServerVoiceChannel.
/**
* Gets or creates a server voice channel.
*
* @param data The json data of the channel.
* @return The server voice channel.
*/
public ServerVoiceChannel getOrCreateServerVoiceChannel(JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
ChannelType type = ChannelType.fromId(data.get("type").asInt());
synchronized (this) {
if (type == ChannelType.SERVER_VOICE_CHANNEL) {
return getVoiceChannelById(id).orElseGet(() -> new ServerVoiceChannelImpl(api, this, data));
}
}
// Invalid channel type
return null;
}
use of org.javacord.api.entity.channel.ChannelType in project Javacord by BtoBastian.
the class ServerImpl method getOrCreateServerThreadChannel.
/**
* Gets or creates a server text channel.
*
* @param data The json data of the channel.
* @return The server text channel.
*/
public ServerThreadChannel getOrCreateServerThreadChannel(final JsonNode data) {
final long id = Long.parseLong(data.get("id").asText());
final ChannelType type = ChannelType.fromId(data.get("type").asInt());
synchronized (this) {
switch(type) {
case SERVER_PUBLIC_THREAD:
case SERVER_PRIVATE_THREAD:
case SERVER_NEWS_THREAD:
return getThreadChannelById(id).orElseGet(() -> new ServerThreadChannelImpl(api, this, data));
default:
// Invalid channel type
return null;
}
}
}
Aggregations