use of net.essentialsx.api.v2.services.discord.MessageType in project Essentials by EssentialsX.
the class JDADiscordService method updateTypesRelay.
public void updateTypesRelay() {
if (!getSettings().isShowAvatar() && !getSettings().isShowName() && !getSettings().isShowDisplayName()) {
for (WebhookClient webhook : channelIdToWebhook.values()) {
webhook.close();
}
typeToChannelId.clear();
channelIdToWebhook.clear();
return;
}
for (MessageType type : MessageType.DefaultTypes.values()) {
if (!type.isPlayer()) {
continue;
}
final TextChannel channel = getChannel(type.getKey(), true);
if (channel.getId().equals(typeToChannelId.get(type))) {
continue;
}
final Webhook webhook = DiscordUtil.getOrCreateWebhook(channel, DiscordUtil.ADVANCED_RELAY_NAME).join();
if (webhook == null) {
final WebhookClient current = channelIdToWebhook.get(channel.getId());
if (current != null) {
current.close();
}
channelIdToWebhook.remove(channel.getId());
continue;
}
typeToChannelId.put(type, channel.getId());
channelIdToWebhook.put(channel.getId(), DiscordUtil.getWebhookClient(webhook.getIdLong(), webhook.getToken(), jda.getHttpClient()));
}
}
use of net.essentialsx.api.v2.services.discord.MessageType in project Essentials by drtshock.
the class JDADiscordService method updateTypesRelay.
public void updateTypesRelay() {
if (!getSettings().isShowAvatar() && !getSettings().isShowName() && !getSettings().isShowDisplayName()) {
for (WebhookClient webhook : channelIdToWebhook.values()) {
webhook.close();
}
typeToChannelId.clear();
channelIdToWebhook.clear();
return;
}
for (MessageType type : MessageType.DefaultTypes.values()) {
if (!type.isPlayer()) {
continue;
}
final TextChannel channel = getChannel(type.getKey(), true);
if (channel.getId().equals(typeToChannelId.get(type))) {
continue;
}
final Webhook webhook = DiscordUtil.getOrCreateWebhook(channel, DiscordUtil.ADVANCED_RELAY_NAME).join();
if (webhook == null) {
final WebhookClient current = channelIdToWebhook.get(channel.getId());
if (current != null) {
current.close();
}
channelIdToWebhook.remove(channel.getId());
continue;
}
typeToChannelId.put(type, channel.getId());
channelIdToWebhook.put(channel.getId(), DiscordUtil.getWebhookClient(webhook.getIdLong(), webhook.getToken(), jda.getHttpClient()));
}
}
Aggregations