1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 09:09:00 +03:00

Log originals of messages deleted through !clear

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-02-02 23:01:19 +05:00
parent a97341f9a9
commit 620c706c97
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
2 changed files with 12 additions and 6 deletions

View file

@ -86,7 +86,8 @@ public sealed class CommandProcessor {
} }
private void SendFeedbacks(bool reply = true) { private void SendFeedbacks(bool reply = true) {
if (reply && _stackedReplyMessage.Length > 0) var hasReply = _stackedReplyMessage.Length > 0;
if (reply && hasReply)
_ = Context.Message.ReplyAsync(_stackedReplyMessage.ToString(), false, null, AllowedMentions.None); _ = Context.Message.ReplyAsync(_stackedReplyMessage.ToString(), false, null, AllowedMentions.None);
var data = GuildData.Get(Context.Guild); var data = GuildData.Get(Context.Guild);
@ -94,7 +95,7 @@ public sealed class CommandProcessor {
var systemChannel = data.PublicFeedbackChannel; var systemChannel = data.PublicFeedbackChannel;
if (_stackedPrivateFeedback.Length > 0 if (_stackedPrivateFeedback.Length > 0
&& adminChannel is not null && adminChannel is not null
&& adminChannel.Id != Context.Message.Channel.Id) { && (adminChannel.Id != Context.Message.Channel.Id || !hasReply)) {
_ = Utils.SilentSendAsync(adminChannel, _stackedPrivateFeedback.ToString()); _ = Utils.SilentSendAsync(adminChannel, _stackedPrivateFeedback.ToString());
_stackedPrivateFeedback.Clear(); _stackedPrivateFeedback.Clear();
} }
@ -102,7 +103,7 @@ public sealed class CommandProcessor {
if (_stackedPublicFeedback.Length > 0 if (_stackedPublicFeedback.Length > 0
&& systemChannel is not null && systemChannel is not null
&& systemChannel.Id != adminChannel?.Id && systemChannel.Id != adminChannel?.Id
&& systemChannel.Id != Context.Message.Channel.Id) { && (systemChannel.Id != Context.Message.Channel.Id || !hasReply)) {
_ = Utils.SilentSendAsync(systemChannel, _stackedPublicFeedback.ToString()); _ = Utils.SilentSendAsync(systemChannel, _stackedPublicFeedback.ToString());
_stackedPublicFeedback.Clear(); _stackedPublicFeedback.Clear();
} }

View file

@ -17,9 +17,14 @@ public sealed class ClearCommand : ICommand {
var messages = await channel.GetMessagesAsync((int)(toDelete + 1)).FlattenAsync(); var messages = await channel.GetMessagesAsync((int)(toDelete + 1)).FlattenAsync();
var user = (SocketGuildUser)cmd.Context.User; var user = (SocketGuildUser)cmd.Context.User;
await channel.DeleteMessagesAsync(messages, Utils.GetRequestOptions(user.ToString()!)); var msgArray = messages.ToArray();
await channel.DeleteMessagesAsync(msgArray, Utils.GetRequestOptions(user.ToString()!));
cmd.Audit(string.Format(Messages.FeedbackMessagesCleared, (toDelete + 1).ToString(), foreach (var msg in msgArray.Where(m => !m.Author.IsBot))
Utils.MentionChannel(channel.Id))); cmd.Audit(
string.Format(
Messages.CachedMessageDeleted, msg.Author.Mention,
Utils.MentionChannel(channel.Id),
Utils.Wrap(msg.CleanContent)));
} }
} }