|
3 | 3 | import net.dv8tion.jda.api.EmbedBuilder;
|
4 | 4 | import net.dv8tion.jda.api.JDA;
|
5 | 5 | import net.dv8tion.jda.api.entities.Guild;
|
| 6 | +import net.dv8tion.jda.api.entities.Member; |
6 | 7 | import net.dv8tion.jda.api.entities.MessageEmbed;
|
7 | 8 | import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
|
8 | 9 | import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
|
@@ -65,28 +66,52 @@ private void autoArchiveForGuild(Guild guild) {
|
65 | 66 | logger.debug("Found {} active questions", activeThreads.size());
|
66 | 67 |
|
67 | 68 | Instant archiveAfterMoment = computeArchiveAfterMoment();
|
68 |
| - activeThreads |
69 |
| - .forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment)); |
| 69 | + activeThreads.forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment, |
| 70 | + activeThread.getOwner())); |
70 | 71 | }
|
71 | 72 |
|
72 | 73 | private Instant computeArchiveAfterMoment() {
|
73 | 74 | return Instant.now().minus(ARCHIVE_AFTER_INACTIVITY_OF);
|
74 | 75 | }
|
75 | 76 |
|
76 |
| - private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment) { |
| 77 | + private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment, |
| 78 | + Member author) { |
77 | 79 | if (shouldBeArchived(threadChannel, archiveAfterMoment)) {
|
78 | 80 | logger.debug("Auto archiving help thread {}", threadChannel.getId());
|
79 | 81 |
|
80 |
| - MessageEmbed embed = new EmbedBuilder().setDescription(""" |
81 |
| - Closed the thread due to inactivity. |
| 82 | + String linkHowToAsk = "https://stackoverflow.com/help/how-to-ask"; |
82 | 83 |
|
83 |
| - If your question was not resolved yet, feel free to just post a message \ |
84 |
| - to reopen it, or create a new thread. But try to improve the quality of \ |
85 |
| - your question to make it easier to help you 👍""") |
| 84 | + MessageEmbed embed = new EmbedBuilder() |
| 85 | + .setDescription( |
| 86 | + """ |
| 87 | + Your question has been closed due to inactivity. |
| 88 | +
|
| 89 | + If it was not resolved yet, feel free to just post a message below |
| 90 | + to reopen it, or create a new thread. |
| 91 | +
|
| 92 | + Note that usually the reason for nobody calling back is that your |
| 93 | + question may have been not well asked and hence no one felt confident |
| 94 | + enough answering. |
| 95 | +
|
| 96 | + When you reopen the thread, try to use your time to **improve the quality** |
| 97 | + of the question by elaborating, providing **details**, context, all relevant code |
| 98 | + snippets, any **errors** you are getting, concrete **examples** and perhaps also some |
| 99 | + screenshots. Share your **attempt**, explain the **expected results** and compare |
| 100 | + them to the current results. |
| 101 | +
|
| 102 | + Also try to make the information **easily accessible** by sharing code |
| 103 | + or assignment descriptions directly on Discord, not behind a link or |
| 104 | + PDF-file; provide some guidance for long code snippets and ensure |
| 105 | + the **code is well formatted** and has syntax highlighting. Kindly read through |
| 106 | + %s for more. |
| 107 | +
|
| 108 | + With enough info, someone knows the answer for sure 👍""" |
| 109 | + .formatted(linkHowToAsk)) |
86 | 110 | .setColor(HelpSystemHelper.AMBIENT_COLOR)
|
87 | 111 | .build();
|
88 | 112 |
|
89 |
| - threadChannel.sendMessageEmbeds(embed) |
| 113 | + threadChannel.sendMessage(author.getAsMention()) |
| 114 | + .addEmbeds(embed) |
90 | 115 | .flatMap(any -> threadChannel.getManager().setArchived(true))
|
91 | 116 | .queue();
|
92 | 117 | }
|
|
0 commit comments