|
8 | 8 | import net.dv8tion.jda.api.entities.MessageEmbed; |
9 | 9 | import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; |
10 | 10 | import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; |
| 11 | +import net.dv8tion.jda.api.interactions.components.buttons.Button; |
11 | 12 | import net.dv8tion.jda.api.requests.RestAction; |
12 | 13 | import net.dv8tion.jda.api.utils.TimeUtil; |
13 | 14 | import org.slf4j.Logger; |
@@ -128,41 +129,48 @@ private void handleArchiveFlow(ThreadChannel threadChannel, MessageEmbed embed) |
128 | 129 | () -> triggerAuthorIdNotFoundArchiveFlow(threadChannel, embed)); |
129 | 130 | } |
130 | 131 |
|
131 | | - private void triggerArchiveFlow(ThreadChannel threadChannel, long authorId, |
132 | | - MessageEmbed embed) { |
| 132 | + private void triggerArchiveFlow(ThreadChannel threadChannel, long authorId, MessageEmbed embed) { |
133 | 133 |
|
| 134 | + // --- UPDATED: Added ActionRow with custom namespace ID --- |
134 | 135 | Function<Member, RestAction<Message>> sendEmbedWithMention = |
135 | | - member -> threadChannel.sendMessage(member.getAsMention()).addEmbeds(embed); |
| 136 | + member -> threadChannel.sendMessage(member.getAsMention()) |
| 137 | + .addEmbeds(embed) |
| 138 | + .addActionRow(Button.primary("OTHER:thread-inactivity:mark-active", "Mark Active")); |
136 | 139 |
|
137 | 140 | Supplier<RestAction<Message>> sendEmbedWithoutMention = |
138 | | - () -> threadChannel.sendMessageEmbeds(embed); |
| 141 | + () -> threadChannel.sendMessageEmbeds(embed) |
| 142 | + .addActionRow(Button.primary("OTHER:thread-inactivity:mark-active", "Mark Active")); |
| 143 | + // --------------------------------------------------------- |
139 | 144 |
|
140 | 145 | threadChannel.getGuild() |
141 | | - .retrieveMemberById(authorId) |
142 | | - .mapToResult() |
143 | | - .flatMap(authorResults -> { |
144 | | - if (authorResults.isFailure()) { |
145 | | - logger.info( |
146 | | - "Trying to archive a thread ({}), but OP ({}) left the server, sending embed without mention", |
147 | | - threadChannel.getId(), authorId, authorResults.getFailure()); |
148 | | - |
149 | | - return sendEmbedWithoutMention.get(); |
150 | | - } |
151 | | - |
152 | | - return sendEmbedWithMention.apply(authorResults.get()); |
153 | | - }) |
154 | | - .flatMap(_ -> threadChannel.getManager().setArchived(true)) |
155 | | - .queue(); |
| 146 | + .retrieveMemberById(authorId) |
| 147 | + .mapToResult() |
| 148 | + .flatMap(authorResults -> { |
| 149 | + if (authorResults.isFailure()) { |
| 150 | + logger.info( |
| 151 | + "Trying to archive a thread ({}), but OP ({}) left the server, sending embed without mention", |
| 152 | + threadChannel.getId(), authorId, authorResults.getFailure()); |
| 153 | + |
| 154 | + return sendEmbedWithoutMention.get(); |
| 155 | + } |
| 156 | + |
| 157 | + return sendEmbedWithMention.apply(authorResults.get()); |
| 158 | + }) |
| 159 | + .flatMap(_ -> threadChannel.getManager().setArchived(true)) |
| 160 | + .queue(); |
156 | 161 | } |
157 | 162 |
|
158 | | - private void triggerAuthorIdNotFoundArchiveFlow(ThreadChannel threadChannel, |
159 | | - MessageEmbed embed) { |
| 163 | + private void triggerAuthorIdNotFoundArchiveFlow(ThreadChannel threadChannel, MessageEmbed embed) { |
160 | 164 |
|
161 | 165 | logger.info( |
162 | 166 | "Was unable to find a matching thread for id: {} in DB, archiving thread without mentioning OP", |
163 | 167 | threadChannel.getId()); |
| 168 | + |
| 169 | + // --- UPDATED: Added ActionRow with custom namespace ID --- |
164 | 170 | threadChannel.sendMessageEmbeds(embed) |
165 | | - .flatMap(sentEmbed -> threadChannel.getManager().setArchived(true)) |
166 | | - .queue(); |
| 171 | + .addActionRow(Button.primary("OTHER:thread-inactivity:mark-active", "Mark Active")) |
| 172 | + .flatMap(sentEmbed -> threadChannel.getManager().setArchived(true)) |
| 173 | + .queue(); |
| 174 | + // --------------------------------------------- |
167 | 175 | } |
168 | 176 | } |
0 commit comments