From 3f68677d996db78d88b23e2d67511bbf85f25144 Mon Sep 17 00:00:00 2001 From: Nathan Curran <30569566+Focusvity@users.noreply.github.com> Date: Tue, 18 Aug 2020 15:52:19 +1000 Subject: [PATCH] Don't send empty messages --- .../totalfreedommod/discord/Discord.java | 25 +++++++++---------- .../discord/DiscordToMinecraftListener.java | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java index 06e82590..daa67143 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java @@ -20,7 +20,6 @@ import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.staff.StaffMember; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; -import net.dv8tion.jda.api.AccountType; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; @@ -78,20 +77,20 @@ public class Discord extends FreedomService } try { - bot = new JDABuilder(AccountType.BOT) - .setToken(ConfigEntry.DISCORD_TOKEN.getString()) - .addEventListeners(new PrivateMessageListener()) - .addEventListeners(new DiscordToMinecraftListener()) + bot = JDABuilder.createDefault(ConfigEntry.DISCORD_TOKEN.getString()) + .addEventListeners(new PrivateMessageListener(), + new DiscordToMinecraftListener(), + new ListenerAdapter() + { + @Override + public void onReady(ReadyEvent event) + { + new StartEvent(event.getJDA()).start(); + } + }) .setAutoReconnect(true) .setRateLimitPool(RATELIMIT_EXECUTOR) - .addEventListeners(new ListenerAdapter() - { - @Override - public void onReady(ReadyEvent event) - { - new StartEvent(event.getJDA()).start(); - } - }).build(); + .build(); FLog.info("Discord verification bot has successfully enabled!"); } catch (LoginException e) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java index c7cd7b39..f7a6e923 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java @@ -20,7 +20,7 @@ public class DiscordToMinecraftListener extends ListenerAdapter String chat_channel_id = ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString(); if (event.getMember() != null && !chat_channel_id.isEmpty() && event.getChannel().getId().equals(chat_channel_id)) { - if (!event.getAuthor().getId().equals(Discord.bot.getSelfUser().getId())) + if (!event.getAuthor().getId().equals(Discord.bot.getSelfUser().getId()) && !event.getMessage().getContentDisplay().isEmpty()) { Member member = event.getMember(); String tag = getDisplay(member);