use of org.javacord.api.entity.channel.ChannelType in project Javacord by BtoBastian.
the class ServerImpl method getOrCreateServerStageVoiceChannel.
/**
* Gets or creates a server stage voice channel.
*
* @param data The json data of the channel.
* @return The server stage voice channel.
*/
public ServerStageVoiceChannel getOrCreateServerStageVoiceChannel(JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
ChannelType type = ChannelType.fromId(data.get("type").asInt());
synchronized (this) {
if (type == ChannelType.SERVER_STAGE_VOICE_CHANNEL) {
return getStageVoiceChannelById(id).orElseGet(() -> new ServerStageVoiceChannelImpl(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 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;
}
use of org.javacord.api.entity.channel.ChannelType in project Javacord by BtoBastian.
the class ChannelCreateHandler method handle.
@Override
public void handle(JsonNode packet) {
ChannelType type = ChannelType.fromId(packet.get("type").asInt());
switch(type) {
case SERVER_TEXT_CHANNEL:
handleServerTextChannel(packet);
break;
case PRIVATE_CHANNEL:
handlePrivateChannel(packet);
break;
case SERVER_VOICE_CHANNEL:
handleServerVoiceChannel(packet);
break;
case SERVER_STAGE_VOICE_CHANNEL:
handleServerStageVoiceChannel(packet);
break;
case GROUP_CHANNEL:
handleGroupChannel(packet);
break;
case CHANNEL_CATEGORY:
handleChannelCategory(packet);
break;
case SERVER_NEWS_CHANNEL:
logger.debug("Received CHANNEL_CREATE packet for a news channel. In this Javacord version it is " + "treated as a normal text channel!");
handleServerTextChannel(packet);
break;
case SERVER_STORE_CHANNEL:
// TODO Handle store channels
logger.debug("Received CHANNEL_CREATE packet for a store channel. These are not supported in this" + " Javacord version and get ignored!");
break;
default:
logger.warn("Unknown or unexpected channel type. Your Javacord version might be out of date!");
}
}
use of org.javacord.api.entity.channel.ChannelType in project Javacord by BtoBastian.
the class ChannelUpdateHandler method handle.
@Override
public void handle(JsonNode packet) {
ChannelType type = ChannelType.fromId(packet.get("type").asInt());
switch(type) {
case SERVER_TEXT_CHANNEL:
handleServerChannel(packet);
handleRegularServerChannel(packet);
handleServerTextChannel(packet);
break;
case PRIVATE_CHANNEL:
handlePrivateChannel(packet);
break;
case SERVER_VOICE_CHANNEL:
handleServerChannel(packet);
handleRegularServerChannel(packet);
handleServerVoiceChannel(packet);
break;
case SERVER_STAGE_VOICE_CHANNEL:
handleServerChannel(packet);
handleRegularServerChannel(packet);
handleServerVoiceChannel(packet);
handleServerStageVoiceChannel(packet);
break;
case GROUP_CHANNEL:
handleGroupChannel(packet);
break;
case CHANNEL_CATEGORY:
handleServerChannel(packet);
handleRegularServerChannel(packet);
handleChannelCategory(packet);
break;
case SERVER_NEWS_CHANNEL:
logger.debug("Received CHANNEL_UPDATE packet for a news channel. In this Javacord version it is " + "treated as a normal text channel!");
handleServerChannel(packet);
handleRegularServerChannel(packet);
handleServerTextChannel(packet);
break;
case SERVER_STORE_CHANNEL:
// TODO Handle store channels
logger.debug("Received CHANNEL_UPDATE packet for a store channel. These are not supported in this" + " Javacord version and get ignored!");
break;
default:
logger.warn("Unknown or unexpected channel type. Your Javacord version might be out of date!");
}
}
use of org.javacord.api.entity.channel.ChannelType in project Javacord by BtoBastian.
the class ChannelDeleteHandler method handle.
@Override
public void handle(JsonNode packet) {
ChannelType type = ChannelType.fromId(packet.get("type").asInt());
switch(type) {
case SERVER_TEXT_CHANNEL:
handleServerTextChannel(packet);
break;
case PRIVATE_CHANNEL:
handlePrivateChannel(packet);
break;
case SERVER_VOICE_CHANNEL:
handleServerVoiceChannel(packet);
break;
case SERVER_STAGE_VOICE_CHANNEL:
handleServerStageVoiceChannel(packet);
break;
case GROUP_CHANNEL:
handleGroupChannel(packet);
break;
case CHANNEL_CATEGORY:
handleCategory(packet);
break;
case SERVER_NEWS_CHANNEL:
// TODO Handle server news channel differently
handleServerTextChannel(packet);
break;
case SERVER_STORE_CHANNEL:
// TODO Handle store channels
logger.debug("Received CHANNEL_DELETE packet for a store channel. These are not supported in this" + " Javacord version and get ignored!");
break;
default:
logger.warn("Unknown or unexpected channel type. Your Javacord version might be out of date!");
}
api.removeChannelFromCache(packet.get("id").asLong());
}
Aggregations