package kuroodo.discordbot.chatcommands.admin;

import kuroodo.discordbot.entities.ChatCommand;
import kuroodo.discordbot.helpers.JDAHelper;
import net.dv8tion.jda.events.message.guild.GuildMessageReceivedEvent;

public class CommandDeleteRole extends ChatCommand {

	public CommandDeleteRole() {
		isAdminCommand = true;
	}

	@Override
	public void executeCommand(String commandParams, GuildMessageReceivedEvent event) {
		super.executeCommand(commandParams, event);

		if (!isUserAuthorized) {
			return;
		}

		// Ensure that role exists or that it isn't admin/mod
		if (JDAHelper.getRoleByName(commandParameters) == null || commandParameters.equals("Admin")
				|| commandParameters.equals("Moderator")) {

			JDAHelper.getTextChannelByName("headquarters").sendMessageAsync(event.getAuthor().getAsMention()
					+ " A role with the name " + commandParameters + " doesn't exist or is locked", null);
		} else {
			JDAHelper.getRoleByName(commandParameters).getManager().delete();

			JDAHelper.getTextChannelByName("headquarters").sendMessageAsync(
					event.getAuthor().getAsMention() + " deleted role called " + commandParameters, null);
		}
	}

	@Override
	public String info() {
		return "Delete a role. Usage !deleterole rolename . Example: !deletrole Member";
	}

}

@@ -134,16 +134,107 @@
 Helper;%0A
+import kuroodo.discordbot.helpers.JSonReader;%0Aimport net.dv8tion.jda.entities.TextChannel;%0A
 import n
@@ -596,16 +596,126 @@
 n;%0A%09%09%7D%0A%0A
+%09%09TextChannel adminChannel = JDAHelper.getTextChannelByName(JSonReader.getPreferencesValue(%22adminchannel%22));%0A%0A
 %09%09// Ens
@@ -912,54 +912,52 @@
 %0A%09%09%09
-JDAHelper.getTextChannelByName(%22headquarters%22)
+if (adminChannel != null) %7B%0A%09%09%09%09adminChannel
 .sen
@@ -1002,22 +1002,17 @@
 ention()
-%0A%09%09%09%09%09
+ 
 + %22 A ro
@@ -1029,17 +1029,23 @@
 e name %22
- 
+%0A%09%09%09%09%09%09
 + comman
@@ -1096,16 +1096,21 @@
  null);%0A
+%09%09%09%7D%0A
 %09%09%7D else
@@ -1189,54 +1189,52 @@
 %0A%09%09%09
-JDAHelper.getTextChannelByName(%22headquarters%22)
+if (adminChannel != null) %7B%0A%09%09%09%09adminChannel
 .sen
@@ -1248,16 +1248,17 @@
 eAsync(%0A
+%09
 %09%09%09%09%09eve
@@ -1341,16 +1341,21 @@
  null);%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%7D%0A%0A

Implement preference.json preferences to CommandDeleteRole