Skip to content

Commit

Permalink
no warning in direct rolls (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
twonirwana authored Sep 7, 2024
1 parent dd356b0 commit eaf0372
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.base.Strings;
import de.janno.discord.bot.AnswerInteractionType;
import de.janno.discord.bot.BotMetrics;
import de.janno.discord.bot.I18n;
Expand Down Expand Up @@ -34,8 +33,6 @@
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static de.janno.discord.bot.command.channelConfig.ChannelConfigCommand.DIRECT_ROLL_CONFIG_TYPE_ID;

Expand Down Expand Up @@ -155,13 +152,9 @@ protected EmbedOrMessageDefinition getHelpMessage(Locale userLocale) {
@NonNull RollAnswer answer,
@NonNull Stopwatch stopwatch,
@NonNull Locale userLocale) {
String warningMessage = Stream.of(commandString, answer.getWarning())
.filter(s -> !Strings.isNullOrEmpty(s))
.collect(Collectors.joining(" "));

Mono<Void> answerMono = Strings.isNullOrEmpty(answer.getWarning()) ?
Mono.defer(() -> event.replyWithEmbedOrMessageDefinition(RollAnswerConverter.toEmbedOrMessageDefinition(answer), false)) :
Mono.defer(() -> event.reply(warningMessage, true));
//ignore warning, no good way to display it
Mono<Void> answerMono = Mono.defer(() -> event.replyWithEmbedOrMessageDefinition(RollAnswerConverter.toEmbedOrMessageDefinition(answer), false));
return answerMono
.doOnSuccess(v ->
log.info("{}: '{}'={} -> {} in {}ms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ de.janno.discord.bot.command.directRoll.DirectRollCommandMockTest.roll_multiLine

de.janno.discord.bot.command.directRoll.DirectRollCommandMockTest.roll_warn=[
[
"reply: commandString did not contain any random element, try for Example `d20` to roll a 20 sided die"
"replyWithEmbedOrMessageDefinition: EmbedOrMessageDefinition(title=20 ⇒ 20, descriptionOrContent=, fields=[], componentRowDefinitions=[], hasImage=false, type=EMBED, userReference=true, sendToOtherChannelId=null)"
]
]

Expand Down

0 comments on commit eaf0372

Please sign in to comment.