Skip to content

Commit 03aef12

Browse files
committed
notify OP for thread inactivity
1 parent 613d54e commit 03aef12

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.dv8tion.jda.api.EmbedBuilder;
44
import net.dv8tion.jda.api.JDA;
55
import net.dv8tion.jda.api.entities.Guild;
6+
import net.dv8tion.jda.api.entities.Member;
67
import net.dv8tion.jda.api.entities.MessageEmbed;
78
import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
89
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
@@ -65,15 +66,16 @@ private void autoArchiveForGuild(Guild guild) {
6566
logger.debug("Found {} active questions", activeThreads.size());
6667

6768
Instant archiveAfterMoment = computeArchiveAfterMoment();
68-
activeThreads
69-
.forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment));
69+
activeThreads.forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment,
70+
activeThread.getOwner()));
7071
}
7172

7273
private Instant computeArchiveAfterMoment() {
7374
return Instant.now().minus(ARCHIVE_AFTER_INACTIVITY_OF);
7475
}
7576

76-
private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment) {
77+
private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment,
78+
Member author) {
7779
if (shouldBeArchived(threadChannel, archiveAfterMoment)) {
7880
logger.debug("Auto archiving help thread {}", threadChannel.getId());
7981

@@ -108,7 +110,8 @@ private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAf
108110
.setColor(HelpSystemHelper.AMBIENT_COLOR)
109111
.build();
110112

111-
threadChannel.sendMessageEmbeds(embed)
113+
threadChannel.sendMessage(author.getAsMention())
114+
.addEmbeds(embed)
112115
.flatMap(any -> threadChannel.getManager().setArchived(true))
113116
.queue();
114117
}

0 commit comments

Comments
 (0)