Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Allow 'show-warning-in-command-channel' to run even when 'remove-unne…
Browse files Browse the repository at this point in the history
…cessary-messages-from-whitelist-channel' is set to false
  • Loading branch information
Shimell committed Feb 3, 2021
1 parent 40250fc commit e7f86b8
Showing 1 changed file with 16 additions and 37 deletions.
53 changes: 16 additions & 37 deletions src/main/java/uk/co/angrybee/joe/DiscordClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1054,25 +1054,26 @@ else if (whitelistRoles.isEmpty())
if(DiscordWhitelister.removeUnnecessaryMessages)
{
RemoveMessageAfterSeconds(messageReceivedEvent, DiscordWhitelister.removeMessageWaitTime);
}

if(MainConfig.getMainConfig().getBoolean("show-warning-in-command-channel"))
// Warn if enabled
if(MainConfig.getMainConfig().getBoolean("show-warning-in-command-channel"))
{
if(!DiscordWhitelister.useCustomMessages)
{
if(!DiscordWhitelister.useCustomMessages)
{
MessageEmbed messageEmbed = CreateEmbeddedMessage("This Channel is for Commands Only", (author.getAsMention() + ", this channel is for commands only, please use another channel."),
EmbedMessageType.FAILURE).build();
QueueAndRemoveAfterSeconds(channel, messageEmbed);
}
else
{
String customTitle = DiscordWhitelister.getCustomMessagesConfig().getString("command-channel-title");
MessageEmbed messageEmbed = CreateEmbeddedMessage("This Channel is for Commands Only", (author.getAsMention() + ", this channel is for commands only, please use another channel."),
EmbedMessageType.FAILURE).build();
QueueAndRemoveAfterSeconds(channel, messageEmbed);
}
else
{
String customTitle = DiscordWhitelister.getCustomMessagesConfig().getString("command-channel-title");

String customMessage = DiscordWhitelister.getCustomMessagesConfig().getString("command-channel-message");
customMessage = customMessage.replaceAll("\\{Sender}", author.getAsMention());
String customMessage = DiscordWhitelister.getCustomMessagesConfig().getString("command-channel-message");
customMessage = customMessage.replaceAll("\\{Sender}", author.getAsMention());

MessageEmbed messageEmbed = DiscordClient.CreateEmbeddedMessage(customTitle, customMessage, DiscordClient.EmbedMessageType.FAILURE).build();
QueueAndRemoveAfterSeconds(channel, messageEmbed);
}
MessageEmbed messageEmbed = DiscordClient.CreateEmbeddedMessage(customTitle, customMessage, DiscordClient.EmbedMessageType.FAILURE).build();
QueueAndRemoveAfterSeconds(channel, messageEmbed);
}
}
}
Expand Down Expand Up @@ -1438,28 +1439,6 @@ public static void RemoveMessageAfterSeconds(MessageReceivedEvent messageReceive
removeTimerThread.start();
}

// public static void SendAndRemoveMessagesAfterSeconds(MessageReceivedEvent messageReceivedEvent, List<Object> messages, Integer timeToWait)
// {
// TextChannel textChannel = messageReceivedEvent.getTextChannel();
//
// for (Object o : messages)
// {
// // Only Remove supplied Messages
// if(o instanceof Message)
// {
// if(DiscordWhitelister.removeUnnecessaryMessages)
// RemoveMessageAfterSeconds(messageReceivedEvent, DiscordWhitelister.removeMessageWaitTime);
// }
// else if(o instanceof MessageEmbed)
// {
// if(DiscordWhitelister.removeUnnecessaryMessages)
// textChannel.sendMessage((MessageEmbed) o).queue(message -> message.delete().queueAfter(timeToWait, TimeUnit.SECONDS));
// else
// textChannel.sendMessage((MessageEmbed) o).queue();
// }
// }
// }

public static void QueueAndRemoveAfterSeconds(TextChannel textChannel, MessageEmbed messageEmbed)
{
if(DiscordWhitelister.removeUnnecessaryMessages)
Expand Down

0 comments on commit e7f86b8

Please sign in to comment.