Skip to content

Commit

Permalink
forbid question transfer command on bot users (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitsmt211 authored Oct 23, 2023
1 parent 1b38951 commit 82df6ee
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public TransferQuestionCommand(Config config) {

@Override
public void onMessageContext(MessageContextInteractionEvent event) {

if (isBotMessageTransfer(event)) {
return;
}

String originalMessage = event.getTarget().getContentRaw();
String originalMessageId = event.getTarget().getId();
String originalChannelId = event.getChannel().getId();
Expand Down Expand Up @@ -217,4 +222,12 @@ private MessageEmbed makeEmbedForPost(User originalUser, String originalMessage)

private record ForumPost(User author, Message message) {
}

private boolean isBotMessageTransfer(MessageContextInteractionEvent event) {
if (event.getTarget().getAuthor().isBot()) {
event.reply("Cannot transfer messages from a bot.").setEphemeral(true).queue();
return true;
}
return false;
}
}

0 comments on commit 82df6ee

Please sign in to comment.