Skip to content

Commit

Permalink
Cleanup some code
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaFox161 committed Mar 12, 2017
1 parent 8991f27 commit 06e0866
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/cloudcraftgaming/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void main(String[] args) {
if (client == null)
throw new NullPointerException("Failed to log in! Client cannot be null!");

if (args.length == 4)
if (args.length > 3)
UpdateListData.init(args[3]);

//Connect to MySQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,35 @@ public void onMessageEvent(MessageReceivedEvent event) {
try {
if (event.getMessage() != null && event.getMessage().getGuild() != null && event.getMessage().getChannel() != null) {
//Message is a valid guild message (not DM). Check if in correct channel.
if (PermissionChecker.inCorrectChannel(event)) {
//In correct channel for this guild, let's see if valid command.
if (event.getMessage().getContent().startsWith("!")) {
//Prefixed with ! which should mean it is a command, convert and confirm.
String[] argsOr = event.getMessage().getContent().split(" ");
if (argsOr.length > 1) {
ArrayList<String> argsOr2 = new ArrayList<>();
argsOr2.addAll(Arrays.asList(argsOr).subList(1, argsOr.length));
String[] args = argsOr2.toArray(new String[argsOr2.size()]);
if (PermissionChecker.inCorrectChannel(event) && event.getMessage().getContent().startsWith("!")) {
//Prefixed with ! which should mean it is a command, convert and confirm.
String[] argsOr = event.getMessage().getContent().split(" ");
if (argsOr.length > 1) {
ArrayList<String> argsOr2 = new ArrayList<>();
argsOr2.addAll(Arrays.asList(argsOr).subList(1, argsOr.length));
String[] args = argsOr2.toArray(new String[argsOr2.size()]);

String command = argsOr[0].replaceAll("!", "");
cmd.issueCommand(command, args, event);
} else if (argsOr.length == 1) {
//Only command... no args.
cmd.issueCommand(argsOr[0].replaceAll("!", ""), new String[0], event);
}
} else if (!event.getMessage().mentionsEveryone() && !event.getMessage().mentionsHere() && discalMentioned(event)) {
//DisCal is mentioned, everyone and here were not, check if valid command.
if (event.getMessage().toString().startsWith("<@" + Main.getSelfUser().getID() + ">") || event.getMessage().toString().startsWith("<@!" + Main.getSelfUser().getID() + ">")) {

String[] argsOr = event.getMessage().getContent().split(" ");
if (argsOr.length > 2) {
ArrayList<String> argsOr2 = new ArrayList<>();
argsOr2.addAll(Arrays.asList(argsOr).subList(2, argsOr.length));
String [] args = argsOr2.toArray(new String[argsOr2.size()]);
String command = argsOr[0].replaceAll("!", "");
cmd.issueCommand(command, args, event);
} else if (argsOr.length == 1) {
//Only command... no args.
cmd.issueCommand(argsOr[0].replaceAll("!", ""), new String[0], event);
}
} else if (!event.getMessage().mentionsEveryone() && !event.getMessage().mentionsHere() && discalMentioned(event) && event.getMessage().toString().startsWith("<@" + Main.getSelfUser().getID() + ">") || event.getMessage().toString().startsWith("<@!" + Main.getSelfUser().getID() + ">")) {
String[] argsOr = event.getMessage().getContent().split(" ");
if (argsOr.length > 2) {
ArrayList<String> argsOr2 = new ArrayList<>();
argsOr2.addAll(Arrays.asList(argsOr).subList(2, argsOr.length));
String [] args = argsOr2.toArray(new String[argsOr2.size()]);

String command = argsOr[1];
cmd.issueCommand(command, args, event);
} else if (argsOr.length == 2) {
//No args...
cmd.issueCommand(argsOr[1], new String[0], event);
} else if (argsOr.length == 1) {
//Only disCal mentioned...
cmd.issueCommand("DisCal", new String[0], event);
}
}
String command = argsOr[1];
cmd.issueCommand(command, args, event);
} else if (argsOr.length == 2) {
//No args...
cmd.issueCommand(argsOr[1], new String[0], event);
} else if (argsOr.length == 1) {
//Only disCal mentioned...
cmd.issueCommand("DisCal", new String[0], event);
}
}
}
Expand Down

0 comments on commit 06e0866

Please sign in to comment.