Skip to content

Commit

Permalink
Avoid unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Aug 18, 2024
1 parent bcf49ec commit 47a4bc9
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions Events/MessageEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,6 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
if (!wasAutoModBlock)
_ = message.DeleteAsync();

var button = new DiscordButtonComponent(DiscordButtonStyle.Secondary, "line-limit-deleted-message-callback", "View message content", false, null);

if (!Program.db.HashExists("linePardoned", message.Author.Id.ToString()))
{
await Program.db.HashSetAsync("linePardoned", member.Id.ToString(), false);
Expand All @@ -673,10 +671,17 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
$"Please consider using a Pastebin-style website or <#{Program.cfgjson.UnrestrictedEmojiChannels[0]}> to avoid further punishment.";
DiscordMessageBuilder messageBuilder = new();
messageBuilder.WithContent(output);
DiscordMessage msg;
if (!wasAutoModBlock)
messageBuilder.AddComponents(button);
DiscordMessage msg = await message.Channel.SendMessageAsync(messageBuilder);
await Program.db.HashSetAsync("deletedMessageReferences", msg.Id, message.Content);
{
messageBuilder.AddComponents(new DiscordButtonComponent(DiscordButtonStyle.Secondary, "line-limit-deleted-message-callback", "View message content", false, null));
msg = await message.Channel.SendMessageAsync(messageBuilder);
await Program.db.HashSetAsync("deletedMessageReferences", msg.Id, message.Content);
}
else
{
msg = await message.Channel.SendMessageAsync(messageBuilder);
}
await InvestigationsHelpers.SendInfringingMessaageAsync("investigations", message, reason, DiscordHelpers.MessageLink(msg), wasAutoModBlock: wasAutoModBlock);
return;
}
Expand All @@ -686,12 +691,19 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
$"Please consider using a Pastebin-style website or <#{Program.cfgjson.UnrestrictedEmojiChannels[0]}> to avoid punishment.";
DiscordMessageBuilder messageBuilder = new();
messageBuilder.WithContent(output);
DiscordMessage msg;
if (!wasAutoModBlock)
messageBuilder.AddComponents(button);
{
messageBuilder.AddComponents(new DiscordButtonComponent(DiscordButtonStyle.Secondary, "line-limit-deleted-message-callback", "View message content", false, null));
msg = await message.Channel.SendMessageAsync(messageBuilder);
await Program.db.HashSetAsync("deletedMessageReferences", msg.Id, message.Content);
}
else
{
msg = await message.Channel.SendMessageAsync(messageBuilder);
}

DiscordMessage msg = await message.Channel.SendMessageAsync(messageBuilder);
var warning = await WarningHelpers.GiveWarningAsync(message.Author, client.CurrentUser, reason, contextMessage: msg, message.Channel, " automatically ");
await Program.db.HashSetAsync("deletedMessageReferences", msg.Id, message.Content);
await InvestigationsHelpers.SendInfringingMessaageAsync("investigations", message, reason, warning.ContextLink, wasAutoModBlock: wasAutoModBlock);

return;
Expand Down

0 comments on commit 47a4bc9

Please sign in to comment.