@@ -42,7 +42,7 @@ protected ReplyCallbackAction handleModerationCommand(SlashCommandInteractionEve
4242 if (amount == null || amount < 1 || amount > maxAmount ) {
4343 return Responses .warning (event , "Invalid amount. Should be between 1 and " + maxAmount + ", inclusive." );
4444 }
45- Bot .asyncPool .submit (() -> this .purge (amount , user , archive , event .getTextChannel (), config .getLogChannel ()));
45+ Bot .asyncPool .submit (() -> this .purge (amount , user , event . getUser (), archive , event .getTextChannel (), config .getLogChannel ()));
4646 StringBuilder sb = new StringBuilder ();
4747 sb .append (amount > 1 ? "Up to " + amount + " messages " : "1 message " );
4848 if (user != null ) {
@@ -63,15 +63,16 @@ protected ReplyCallbackAction handleModerationCommand(SlashCommandInteractionEve
6363 * @param channel The channel to remove messages from.
6464 * @param logChannel The channel to write log messages to during the purge.
6565 */
66- private void purge (@ Nullable Long amount , @ Nullable User user , boolean archive , MessageChannel channel , TextChannel logChannel ) {
66+ private void purge (@ Nullable Long amount , @ Nullable User user , User initiatedBy , boolean archive , MessageChannel channel , TextChannel logChannel ) {
6767 MessageHistory history = channel .getHistory ();
6868 String timestamp = LocalDateTime .now ().format (DateTimeFormatter .ofPattern ("yyyy-MM-dd_HH-mm-ss" ));
6969 String file = String .format ("purge_%s_%s.txt" , channel .getName (), timestamp );
7070 PrintWriter archiveWriter = archive ? createArchiveWriter (channel , logChannel , file ) : null ;
7171 List <Message > messages ;
7272 OffsetDateTime startTime = OffsetDateTime .now ();
7373 long count = 0 ;
74- logChannel .sendMessage ("Starting purge of channel " + channel .getAsMention ()).queue ();
74+ logChannel .sendMessageFormat ("Starting purge of channel %s, initiated by %s" , channel .getAsMention (), initiatedBy .getAsMention ())
75+ .queue ();
7576 do {
7677 messages = history .retrievePast (amount == null ? 100 : (int ) Math .min (100 , amount )).complete ();
7778 if (!messages .isEmpty ()) {
@@ -136,7 +137,7 @@ private PrintWriter createArchiveWriter(MessageChannel channel, TextChannel logC
136137 if (Files .notExists (ARCHIVE_DIR )) Files .createDirectory (ARCHIVE_DIR );
137138 Path archiveFile = ARCHIVE_DIR .resolve (file );
138139 var archiveWriter = new PrintWriter (Files .newBufferedWriter (archiveFile ), true );
139- logChannel .sendMessage ("Created archive of purge of channel " + channel .getAsMention () + " at " + archiveFile ).queue ();
140+ logChannel .sendMessageFormat ("Created archive of purge of channel %s at `%s`" , channel .getAsMention (), archiveFile ).queue ();
140141 archiveWriter .println ("Purge of channel " + channel .getName ());
141142 return archiveWriter ;
142143 } catch (IOException e ) {
0 commit comments