From 6a97e8fd586d0a6a0147da4113a10c2fc7b17a9d Mon Sep 17 00:00:00 2001 From: "Tomachi [ICHIGO]" Date: Fri, 1 Apr 2022 18:56:51 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20jdev=E3=81=B8=E3=81=AE=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C=E3=83=AD=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=82=B7=E3=83=A7=E3=83=B3=E5=BD=A2=E5=BC=8F?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20&=20Embed=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javajaotan2/event/Event_BugReaction.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/jaoafa/javajaotan2/event/Event_BugReaction.java b/src/main/java/com/jaoafa/javajaotan2/event/Event_BugReaction.java index b6f41d42..21251979 100644 --- a/src/main/java/com/jaoafa/javajaotan2/event/Event_BugReaction.java +++ b/src/main/java/com/jaoafa/javajaotan2/event/Event_BugReaction.java @@ -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; @@ -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(); }