Skip to content

Commit

Permalink
refactor throwable name and logging error
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitsmt211 committed Nov 18, 2023
1 parent 11cebb3 commit cecc066
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.dv8tion.jda.api.requests.RestAction;
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.features.BotCommandAdapter;
Expand All @@ -47,6 +49,7 @@
*/
public final class TransferQuestionCommand extends BotCommandAdapter
implements MessageContextCommand {
private static final Logger logger = LoggerFactory.getLogger(TransferQuestionCommand.class);
private static final String COMMAND_NAME = "transfer-question";
private static final String MODAL_TITLE_ID = "transferID";
private static final String MODAL_INPUT_ID = "transferQuestion";
Expand Down Expand Up @@ -136,11 +139,14 @@ public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {
Consumer<Message> notHandledAction =
any -> transferFlow(event, channelId, authorId, messageId);

Consumer<Throwable> handledAction = any -> {
if (any instanceof ErrorResponseException errorResponseException
Consumer<Throwable> handledAction = failure -> {
if (failure instanceof ErrorResponseException errorResponseException
&& errorResponseException.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) {
alreadyHandled(sourceChannel, helperForum);
return;
}
logger.warn("Unknown error occurred on modal submission during question transfer.",
failure);
};

event.getChannel().retrieveMessageById(messageId).queue(notHandledAction, handledAction);
Expand Down

0 comments on commit cecc066

Please sign in to comment.