Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #244 from book000/fix/bug-mention2
Browse files Browse the repository at this point in the history
fix: jdevへのメンションがロールメンション形式になっていなかった問題を修正 & Embed化
  • Loading branch information
book000 authored Apr 1, 2022
2 parents ecb2933 + 6a97e8f commit cd03885
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/main/java/com/jaoafa/javajaotan2/event/Event_BugReaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
import com.jaoafa.javajaotan2.Main;
import com.jaoafa.javajaotan2.lib.Channels;
import com.jaoafa.javajaotan2.lib.JavajaotanLibrary;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;

import java.awt.*;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -110,18 +114,26 @@ public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) {
messages.add("[LINKED-ISSUE:jaoafa/jao-Minecraft-Server#" + issueNumber + "]");
messages.add("");
}
messages.add(":bug: リアクションにより、不具合の報告がなされました。");
messages.add("投稿者、または報告者は不具合内容についての説明(何が不具合と思ったのか、期待される動作など)をお願いします。");
messages.add("");
messages.add(mainMessage);
messages.add("<@&959313488113717298> / " + user.getAsMention() + " / " + message.getAuthor().getAsMention());

EmbedBuilder embed = new EmbedBuilder()
.setTitle(":bug: リアクションによる不具合の報告")
.addField("不具合と思われるメッセージ (または報告)", "%s に送信された %s による %s でのメッセージ\n\n%s".formatted(createdAt.format(formatter), message.getAuthor().getAsMention(), message.getChannel().getAsMention(), message.getJumpUrl()), false)
.addField("不具合報告者", user.getAsMention(), false)
.setTimestamp(Instant.now())
.setFooter("投稿者、または報告者は不具合内容についての説明(何が不具合と思ったのか、期待される動作など)をお願いします。")
.setColor(Color.YELLOW);

if (responseType == JavajaotanLibrary.IssueResponseType.SUCCESS) {
messages.add("Issue: https://github.com/jaoafa/jao-Minecraft-Server/issues/" + issueNumber);
embed.addField("Issue Url", "https://github.com/jaoafa/jao-Minecraft-Server/issues/" + issueNumber, false);
}
messages.add("<@959313488113717298>");

String threadTitle = (responseType == JavajaotanLibrary.IssueResponseType.SUCCESS ? "*" + issueNumber + " " : "") + title;
ThreadChannel thread = developmentChannel.createThreadChannel(threadTitle).complete();
thread.sendMessage(String.join("\n", messages)).queue();
thread.sendMessage(new MessageBuilder()
.setContent(String.join("\n", messages))
.setEmbeds(embed.build())
.build()).queue();

message.addReaction(targetReaction).queue();
}
Expand Down

0 comments on commit cd03885

Please sign in to comment.