Skip to content

Commit

Permalink
Fix a message
Browse files Browse the repository at this point in the history
And removed the event/tc from sendXWithMessage
  • Loading branch information
duncte123 committed Feb 24, 2018
1 parent 094f455 commit a045f82
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void executeCommand(String invoke, String[] args, GuildMessageReceivedEve
MessageUtils.sendSuccess(event.getMessage());

} catch (ArrayIndexOutOfBoundsException ex) {
MessageUtils.sendErrorWithMessage(event.getMessage(), event, "Please! You either forgot the text or to mention the channel!");
MessageUtils.sendErrorWithMessage(event.getMessage(), "Please! You either forgot the text or to mention the channel!");
ComparatingUtils.execCheck(ex);
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public void executeCommand(String invoke, String[] args, GuildMessageReceivedEve
case "toggleautodehoist":
boolean shouldAutoDeHoist = !settings.isAutoDeHoist();
GuildSettingsUtils.updateGuildSettings(event.getGuild(), settings.setAutoDeHoist(shouldAutoDeHoist) );
sendMsg(event, "Filtering discord invites has been **"
sendMsg(event, "Auto de-hoisting has been **"
+ ( shouldAutoDeHoist ? "enabled" : "disabled" ) + "**" );
break;
}
Expand Down
42 changes: 6 additions & 36 deletions src/main/java/ml/duncte123/skybot/utils/MessageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,14 @@ public static void sendError(Message message) {
}
}
message.addReaction("❌").queue(null, CUSTOM_QUEUE_ERROR);
}

/**
* This method uses the sendError and sendMsg methods
*
* @param message the {@link Message} for the sendError method
* @param textChannel the {@link TextChannel} for the sendMsg method
* @param text the {@link String} for the sendMsg method
*/
public static void sendErrorWithMessage(Message message, TextChannel textChannel, String text) {
sendError(message);
sendMsg(textChannel, text);
}


/**
} /**
* This method uses the sendError and sendMsg methods
*
* @param message the {@link Message} for the sendError method
* @param event the {@link GuildMessageReceivedEvent} for the sendMsg method
* @param message the {@link Message} for the sendError method
* @param text the {@link String} for the sendMsg method
*/
public static void sendErrorWithMessage(Message message, GuildMessageReceivedEvent event, String text) {
public static void sendErrorWithMessage(Message message, String text) {
sendError(message);
sendMsg(event, text);
sendMsg(message.getTextChannel(), text);
}

/**
Expand Down Expand Up @@ -133,24 +116,11 @@ public static void sendSuccess(Message message) {
* This method uses the sendSuccess and sendMsg methods
*
* @param message the {@link Message} for the sendSuccess method
* @param channel the {@link TextChannel} for the sendMsg method
* @param text the {@link String} for the sendMsg method
*/
public static void sendSuccessWithMessage(Message message, TextChannel channel, String text) {
sendSuccess(message);
sendMsg(channel, text);
}

/**
* This method uses the sendSuccess and sendMsg methods
*
* @param message the {@link Message} for the sendSuccess method
* @param event the {@link GuildMessageReceivedEvent} for the sendMsg method
* @param text the {@link String} for the sendMsg method
*/
public static void sendSuccessWithMessage(Message message, GuildMessageReceivedEvent event, String text) {
public static void sendSuccessWithMessage(Message message, String text) {
sendSuccess(message);
sendMsg(event, text);
sendMsg(message.getTextChannel(), text);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,18 @@ class EvalCommand : Command() {
}
is ExecutionException, is ScriptException -> {
out as Exception
MessageUtils.sendErrorWithMessage(event.message, event, "ERROR: " + out.cause.toString())
MessageUtils.sendErrorWithMessage(event.message, "ERROR: " + out.cause.toString())
}
is TimeoutException, is InterruptedException, is IllegalStateException -> {
out as Exception
coroutine.coroutineContext.cancel()
if (coroutine.isActive)
coroutine.coroutineContext.cancel()
MessageUtils.sendErrorWithMessage(event.message, event, "ERROR: " + out.toString())
MessageUtils.sendErrorWithMessage(event.message, "ERROR: " + out.toString())
}
is IllegalArgumentException, is VRCubeException -> {
out as RuntimeException
MessageUtils.sendErrorWithMessage(event.message, event, "ERROR: " + out.toString())
MessageUtils.sendErrorWithMessage(event.message, "ERROR: " + out.toString())
}
is Throwable -> {
if (Settings.useJSON)
Expand All @@ -246,7 +246,7 @@ class EvalCommand : Command() {
.forEach { it -> MessageUtils.sendMsg(event, it) }
} else {
if (filter.containsMentions(out.toString())) {
MessageUtils.sendErrorWithMessage(event.message, event, "**ERROR:** Mentioning people!")
MessageUtils.sendErrorWithMessage(event.message, "**ERROR:** Mentioning people!")
} else {
MessageUtils.sendMsg(event, "**" + event.author.name
+ ":** " + out.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class WarnCommand: Command() {
}
val target = event.message.mentionedMembers[0]
if (target.user == event.jda.selfUser) {
MessageUtils.sendErrorWithMessage(event.message, event, "You can not warn me")
MessageUtils.sendErrorWithMessage(event.message, "You can not warn me")
return
}
if(!event.member.canInteract(target)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class RadioCommand : MusicCommand() {
else -> {
val radio = radioStreams.firstOrNull { it.name == args[0].replace(oldValue = "", newValue = "love") }
if (radio == null) {
sendErrorWithMessage(event.message, event, "The stream is invalid!")
sendErrorWithMessage(event.message, "The stream is invalid!")
return@executeCommand
}
audioUtils.loadAndPlay(mng, event.channel, radio.url, false)
Expand All @@ -125,7 +125,7 @@ class RadioCommand : MusicCommand() {
}
}
else -> {
sendErrorWithMessage(event.message, event, "The stream name is too long! Type `$PREFIX$name (full)list` for a list of available streams!")
sendErrorWithMessage(event.message, "The stream name is too long! Type `$PREFIX$name (full)list` for a list of available streams!")
}
}
}
Expand Down

0 comments on commit a045f82

Please sign in to comment.