From 30d2b767fac8f011cf4d571757adb1c8971c6037 Mon Sep 17 00:00:00 2001
From: Stalitsa <kolokotronakos@gmail.com>
Date: Sat, 10 Jul 2021 12:06:30 +0100
Subject: [PATCH] Update discord bot methods due to JDA deprecation.

---
 .../datapack/custom/service/discord/AbstractCommand.java  | 2 +-
 .../datapack/custom/service/discord/DiscordBot.java       | 2 +-
 .../custom/service/discord/commands/OnlineCommand.java    | 4 ++--
 .../service/discord/commands/moderation/AbortCommand.java | 4 ++--
 .../discord/commands/moderation/AnnounceCommand.java      | 4 ++--
 .../discord/commands/moderation/RestartCommand.java       | 6 +++---
 .../discord/commands/moderation/ShutdownCommand.java      | 8 ++++----
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/l2jserver/datapack/custom/service/discord/AbstractCommand.java b/src/main/java/com/l2jserver/datapack/custom/service/discord/AbstractCommand.java
index d53eeb3793..1e7ba5dba0 100644
--- a/src/main/java/com/l2jserver/datapack/custom/service/discord/AbstractCommand.java
+++ b/src/main/java/com/l2jserver/datapack/custom/service/discord/AbstractCommand.java
@@ -71,7 +71,7 @@ public abstract class AbstractCommand extends ListenerAdapter {
 		// Only Server owner and members with the specified role assigned can execute the command.
 		if ((guildMember == null) || (gameMaster == null) || !guildMember.isOwner() || !guildMember.getRoles().contains(gameMaster)) {
 			eb.setDescription("Only Staff members can use this command!");
-			event.getTextChannel().sendMessage(eb.build()).queue();
+			event.getTextChannel().sendMessageEmbeds(eb.build()).queue();
 			event.getMessage().addReaction("\u274C").queue();
 			return false;
 		}
diff --git a/src/main/java/com/l2jserver/datapack/custom/service/discord/DiscordBot.java b/src/main/java/com/l2jserver/datapack/custom/service/discord/DiscordBot.java
index f2936e508e..479bc2f13f 100644
--- a/src/main/java/com/l2jserver/datapack/custom/service/discord/DiscordBot.java
+++ b/src/main/java/com/l2jserver/datapack/custom/service/discord/DiscordBot.java
@@ -103,7 +103,7 @@ public class DiscordBot {
 	public static void sendMessageTo(EmbedBuilder ed, String channelId) {
 		MessageChannel channel = jda.getTextChannelById(channelId);
 		if (channel != null) {
-			channel.sendMessage(ed.build()).queue(); // this actually sends the information to discord.
+			channel.sendMessageEmbeds(ed.build()).queue(); // this actually sends the information to discord.
 		}
 	}
 }
diff --git a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/OnlineCommand.java b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/OnlineCommand.java
index a22f6d47f1..c7df7658f4 100644
--- a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/OnlineCommand.java
+++ b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/OnlineCommand.java
@@ -51,7 +51,7 @@ public class OnlineCommand extends AbstractCommand {
 		if (args.length != 1) {
 			eb.setColor(Color.RED);
 			eb.setDescription("Please use the command without any Arguments");
-			event.getTextChannel().sendMessage(eb.build()).queue();
+			event.getTextChannel().sendMessageEmbeds(eb.build()).queue();
 			event.getMessage().addReaction("\u274C").queue(); // Bot reacts with X mark.
 			return;
 		}
@@ -63,7 +63,7 @@ public class OnlineCommand extends AbstractCommand {
 		eb.addField("Online Players", String.valueOf(playersCount), false);
 		eb.addBlankField(false);
 		eb.addField("Online GM's", String.valueOf(gmCount), false);
-		event.getChannel().sendMessage(eb.build()).queue(); // this actually sends the information to discord.
+		event.getChannel().sendMessageEmbeds(eb.build()).queue(); // this actually sends the information to discord.
 		event.getMessage().addReaction("\u2705").queue(); // Bot reacts with check mark.
 	}
 }
diff --git a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AbortCommand.java b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AbortCommand.java
index d9afed82f2..cd95d067f4 100644
--- a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AbortCommand.java
+++ b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AbortCommand.java
@@ -54,7 +54,7 @@ public class AbortCommand extends AbstractCommand {
 
         if (args.length != 1) {
             eb.setDescription("Please use the command without any Arguments");
-            event.getTextChannel().sendMessage(eb.build()).queue();
+            event.getTextChannel().sendMessageEmbeds(eb.build()).queue();
             event.getMessage().addReaction("\u274C").queue();
             return;
         }
@@ -63,7 +63,7 @@ public class AbortCommand extends AbstractCommand {
         String commandName = args[0].substring(discord().getPrefix().length()).toUpperCase();
         Shutdown.getInstance().telnetAbort(event.getAuthor().getName()); //Using telnet method.
         eb.setDescription("GM: {" + gmName + "} issued command. **" + commandName + "** --- Shutdown/Restart Aborted.");
-        event.getChannel().sendMessage(eb.build()).queue();
+        event.getChannel().sendMessageEmbeds(eb.build()).queue();
         event.getMessage().addReaction("\u2705").queue();
     }
 }
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AnnounceCommand.java b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AnnounceCommand.java
index f32930813c..15178b029d 100644
--- a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AnnounceCommand.java
+++ b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/AnnounceCommand.java
@@ -54,7 +54,7 @@ public class AnnounceCommand extends AbstractCommand {
 
 		if (args.length <= 2) {
 			eb.setDescription("Wrong Arguments. Please type the message to be sent.");
-			event.getTextChannel().sendMessage(eb.build()).queue();
+			event.getTextChannel().sendMessageEmbeds(eb.build()).queue();
 			event.getMessage().addReaction("\u274C").queue();
 			return;
 		}
@@ -73,6 +73,6 @@ public class AnnounceCommand extends AbstractCommand {
 		}
 		eb.setDescription("**In game Announcement have been sent**.");
 		event.getMessage().addReaction("\u2705").queue();
-		event.getChannel().sendMessage(eb.build()).queue();
+		event.getChannel().sendMessageEmbeds(eb.build()).queue();
 	}
 }
diff --git a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/RestartCommand.java b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/RestartCommand.java
index c1bdc7e5bb..cf5de44693 100644
--- a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/RestartCommand.java
+++ b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/RestartCommand.java
@@ -54,7 +54,7 @@ public class RestartCommand extends AbstractCommand {
 
 		if (args.length != 2) {
 			eb.setDescription("Wrong Arguments. Please just provide a number in seconds.");
-			event.getTextChannel().sendMessage(eb.build()).queue();
+			event.getTextChannel().sendMessageEmbeds(eb.build()).queue();
 			event.getMessage().addReaction("\u274C").queue();
 			return;
 		}
@@ -64,7 +64,7 @@ public class RestartCommand extends AbstractCommand {
 			seconds = Integer.parseInt(args[1]);
 		} catch (NumberFormatException e) {
 			eb.setDescription("Wrong Arguments. Please just provide a number in seconds.");
-			event.getChannel().sendMessage(eb.build()).queue();
+			event.getChannel().sendMessageEmbeds(eb.build()).queue();
 			event.getMessage().addReaction("\u274C").queue();
 			return;
 		}
@@ -74,7 +74,7 @@ public class RestartCommand extends AbstractCommand {
 		Shutdown.getInstance().startTelnetShutdown(event.getAuthor().getName(), seconds, true); //Using telnet method.
 		eb.setColor(Color.GREEN);
 		eb.setDescription("GM: {" + gmName + "} issued command. **" + commandName + "** in " + seconds + " " + "seconds!");
-		event.getChannel().sendMessage(eb.build()).queue();
+		event.getChannel().sendMessageEmbeds(eb.build()).queue();
 		event.getMessage().addReaction("\u2705").queue();
 	}
 }
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/ShutdownCommand.java b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/ShutdownCommand.java
index d84c64cdb5..66820c87ae 100644
--- a/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/ShutdownCommand.java
+++ b/src/main/java/com/l2jserver/datapack/custom/service/discord/commands/moderation/ShutdownCommand.java
@@ -55,7 +55,7 @@ public class ShutdownCommand extends AbstractCommand {
 		if (args.length != 2) {
 			eb.setColor(Color.RED);
 			eb.setDescription("Wrong Arguments. Please just provide a number in seconds.");
-			event.getTextChannel().sendMessage(eb.build()).queue();
+			event.getTextChannel().sendMessageEmbeds(eb.build()).queue();
 			event.getMessage().addReaction("\u274C").queue();
 			return;
 		}
@@ -66,7 +66,7 @@ public class ShutdownCommand extends AbstractCommand {
 		} catch (NumberFormatException e) {
 			eb.setColor(Color.RED);
 			eb.setDescription("Wrong Arguments. Please just provide a number in seconds.");
-			event.getChannel().sendMessage(eb.build()).queue();
+			event.getChannel().sendMessageEmbeds(eb.build()).queue();
 			event.getMessage().addReaction("\u274C").queue();
 			return;
 		}
@@ -75,8 +75,8 @@ public class ShutdownCommand extends AbstractCommand {
 		String commandName = args[0].substring(discord().getPrefix().length()).toUpperCase();
 		Shutdown.getInstance().startTelnetShutdown(event.getAuthor().getName(), seconds, false); //Using telnet method.
 		eb.setColor(Color.GREEN);
-		eb.setDescription("GM: {" + gmName + "} issued command. **" + commandName + "** in " + args[1] + " " + "seconds!");
-		event.getChannel().sendMessage(eb.build()).queue();
+		eb.setDescription("GM: {" + gmName + "} issued command. **" + commandName + "** in " + seconds + " " + "seconds!");
+		event.getChannel().sendMessageEmbeds(eb.build()).queue();
 		event.getMessage().addReaction("\u2705").queue();
 	}
 }
\ No newline at end of file
-- 
GitLab