Skip to content

Commit f55bc82

Browse files
added support for thread channels
1 parent 57cb269 commit f55bc82

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/net/javadiscord/javabot/systems/moderation/PurgeCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class PurgeCommand extends ModerateCommand {
3030

3131
@Override
3232
protected ReplyCallbackAction handleModerationCommand(SlashCommandInteractionEvent event, Member commandUser) {
33+
this.setAllowThreads(true);
3334
OptionMapping amountOption = event.getOption("amount");
3435
OptionMapping userOption = event.getOption("user");
3536
boolean archive = event.getOption("archive", true, OptionMapping::getAsBoolean);
@@ -62,7 +63,7 @@ protected ReplyCallbackAction handleModerationCommand(SlashCommandInteractionEve
6263
* @param channel The channel to remove messages from.
6364
* @param logChannel The channel to write log messages to during the purge.
6465
*/
65-
private void purge(@Nullable Long amount, @Nullable User user, boolean archive, TextChannel channel, TextChannel logChannel) {
66+
private void purge(@Nullable Long amount, @Nullable User user, boolean archive, MessageChannel channel, TextChannel logChannel) {
6667
MessageHistory history = channel.getHistory();
6768
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"));
6869
String file = String.format("purge_%s_%s.txt", channel.getName(), timestamp);
@@ -130,7 +131,7 @@ private int removeMessages(List<Message> messages, @Nullable User user, @Nullabl
130131
* @param file The archive's filename.
131132
* @return The print writer to use.
132133
*/
133-
private PrintWriter createArchiveWriter(TextChannel channel, TextChannel logChannel, String file) {
134+
private PrintWriter createArchiveWriter(MessageChannel channel, TextChannel logChannel, String file) {
134135
try {
135136
if (Files.notExists(ARCHIVE_DIR)) Files.createDirectory(ARCHIVE_DIR);
136137
Path archiveFile = ARCHIVE_DIR.resolve(file);

0 commit comments

Comments
 (0)