From 5209d495d25a59fed0dfe49a6d547d26c2540820 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 21 Feb 2021 01:47:21 -0500 Subject: some refactorage --- windows/guildsettings/auditlogpane.cpp | 152 ++++++++++++++++----------------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'windows/guildsettings/auditlogpane.cpp') diff --git a/windows/guildsettings/auditlogpane.cpp b/windows/guildsettings/auditlogpane.cpp index 7f789e7..d6b6fee 100644 --- a/windows/guildsettings/auditlogpane.cpp +++ b/windows/guildsettings/auditlogpane.cpp @@ -36,8 +36,8 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { switch (entry.Type) { case AuditLogActionType::GUILD_UPDATE: { markup = - "" + user.GetEscapedString() + " " + - "made changes to " + + user.GetEscapedBoldString() + + " made changes to " + Glib::Markup::escape_text(guild.Name) + ""; @@ -58,8 +58,8 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } break; case AuditLogActionType::CHANNEL_CREATE: { const auto type = *entry.GetNewFromKey("type"); - markup = "" + user.GetEscapedString() + " " + - "created a " + (type == ChannelType::GUILD_VOICE ? "voice" : "text") + + markup = user.GetEscapedBoldString() + + " created a " + (type == ChannelType::GUILD_VOICE ? "voice" : "text") + " channel #" + Glib::Markup::escape_text(*entry.GetNewFromKey("name")) + ""; @@ -78,13 +78,13 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { case AuditLogActionType::CHANNEL_UPDATE: { const auto target_channel = discord.GetChannel(entry.TargetID); if (target_channel.has_value()) { - markup = "" + user.GetEscapedString() + " " + - "made changes to #" + + markup = user.GetEscapedBoldString() + + " made changes to #" + Glib::Markup::escape_text(*target_channel->Name) + ""; } else { - markup = "" + user.GetEscapedString() + " " + - "made changes to <#" + + markup = user.GetEscapedBoldString() + + " made changes to <#" + entry.TargetID + ">"; } @@ -121,57 +121,57 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } } break; case AuditLogActionType::CHANNEL_DELETE: { - markup = "" + user.GetEscapedString() + " " + - "removed #" + + markup = user.GetEscapedBoldString() + + " removed #" + Glib::Markup::escape_text(*entry.GetOldFromKey("name")) + ""; } break; case AuditLogActionType::CHANNEL_OVERWRITE_CREATE: { const auto channel = discord.GetChannel(entry.TargetID); if (channel.has_value()) { - markup = "" + user.GetEscapedString() + " " + - "created channel overrides for #" + + markup = user.GetEscapedBoldString() + + " created channel overrides for #" + Glib::Markup::escape_text(*channel->Name) + ""; } else { - markup = "" + user.GetEscapedString() + " " + - "created channel overrides for <#" + + markup = user.GetEscapedBoldString() + + " created channel overrides for <#" + entry.TargetID + ">"; } } break; case AuditLogActionType::CHANNEL_OVERWRITE_UPDATE: { const auto channel = discord.GetChannel(entry.TargetID); if (channel.has_value()) { - markup = "" + user.GetEscapedString() + " " + - "updated channel overrides for #" + + markup = user.GetEscapedBoldString() + + " updated channel overrides for #" + Glib::Markup::escape_text(*channel->Name) + ""; } else { - markup = "" + user.GetEscapedString() + " " + - "updated channel overrides for <#" + + markup = user.GetEscapedBoldString() + + " updated channel overrides for <#" + entry.TargetID + ">"; } } break; case AuditLogActionType::CHANNEL_OVERWRITE_DELETE: { const auto channel = discord.GetChannel(entry.TargetID); if (channel.has_value()) { - markup = "" + user.GetEscapedString() + " " + - "removed channel overrides for #" + + markup = user.GetEscapedBoldString() + + " removed channel overrides for #" + Glib::Markup::escape_text(*channel->Name) + ""; } else { - markup = "" + user.GetEscapedString() + " " + - "removed channel overrides for <#" + + markup = user.GetEscapedBoldString() + + " removed channel overrides for <#" + entry.TargetID + ">"; } } break; case AuditLogActionType::MEMBER_KICK: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "kicked " + + markup = user.GetEscapedBoldString() + + " kicked " + target_user->GetEscapedString() + ""; } break; case AuditLogActionType::MEMBER_PRUNE: { - markup = "" + user.GetEscapedString() + " " + - "pruned " + + markup = user.GetEscapedBoldString() + + " pruned " + *entry.Options->MembersRemoved + " members"; extra_markup.push_back("For " + @@ -180,22 +180,22 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } break; case AuditLogActionType::MEMBER_BAN_ADD: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "banned " + + markup = user.GetEscapedBoldString() + + " banned " + target_user->GetEscapedString() + ""; } break; case AuditLogActionType::MEMBER_BAN_REMOVE: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "removed the ban for " + + markup = user.GetEscapedBoldString() + + " removed the ban for " + target_user->GetEscapedString() + ""; } break; case AuditLogActionType::MEMBER_UPDATE: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "updated " + + markup = user.GetEscapedBoldString() + + " updated " + target_user->GetEscapedString() + ""; if (entry.Changes.has_value()) @@ -216,8 +216,8 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } break; case AuditLogActionType::MEMBER_ROLE_UPDATE: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "updated roles for " + + markup = user.GetEscapedBoldString() + + " updated roles for " + target_user->GetEscapedString() + ""; if (entry.Changes.has_value()) for (const auto &change : *entry.Changes) { @@ -234,8 +234,8 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } break; case AuditLogActionType::MEMBER_MOVE: { const auto channel = discord.GetChannel(*entry.Options->ChannelID); - markup = "" + user.GetEscapedString() + " " + - "moved " + + markup = user.GetEscapedBoldString() + + " moved " + *entry.Options->Count + " user" + (*entry.Options->Count == "1" ? ""s : "s"s) + @@ -244,28 +244,28 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { ""; } break; case AuditLogActionType::MEMBER_DISCONNECT: { - markup = "" + user.GetEscapedString() + " " + - "disconnected " + + markup = user.GetEscapedBoldString() + + " disconnected " + *entry.Options->Count + " users from voice"; } break; case AuditLogActionType::BOT_ADD: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "added " + + markup = user.GetEscapedBoldString() + + " added " + target_user->GetEscapedString() + " to the server"; } break; case AuditLogActionType::ROLE_CREATE: { - markup = "" + user.GetEscapedString() + " " + - "created the role " + + markup = user.GetEscapedBoldString() + + " created the role " + *entry.GetNewFromKey("name") + ""; } break; case AuditLogActionType::ROLE_UPDATE: { const auto role = discord.GetRole(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "updated the role " + + markup = user.GetEscapedBoldString() + + " updated the role " + (role.has_value() ? Glib::Markup::escape_text(role->Name) : Glib::ustring(entry.TargetID)) + ""; if (entry.Changes.has_value()) @@ -292,15 +292,15 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } } break; case AuditLogActionType::ROLE_DELETE: { - markup = "" + user.GetEscapedString() + " " + - "deleted the role " + + markup = user.GetEscapedBoldString() + + " deleted the role " + *entry.GetOldFromKey("name") + ""; } break; case AuditLogActionType::INVITE_CREATE: { const auto code = *entry.GetNewFromKey("code"); - markup = "" + user.GetEscapedString() + " " + - "created an invite " + code + ""; + markup = user.GetEscapedBoldString() + + " created an invite " + code + ""; if (entry.Changes.has_value()) for (const auto &change : *entry.Changes) { if (change.Key == "channel_id" && change.NewValue.has_value()) { @@ -323,14 +323,14 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } } break; case AuditLogActionType::INVITE_DELETE: { - markup = "" + user.GetEscapedString() + " " + - "deleted an invite " + + markup = user.GetEscapedBoldString() + + " deleted an invite " + *entry.GetOldFromKey("code") + ""; } break; case AuditLogActionType::WEBHOOK_CREATE: { - markup = "" + user.GetEscapedString() + " " + - "created the webhook " + + markup = user.GetEscapedBoldString() + + " created the webhook " + Glib::Markup::escape_text(*entry.GetNewFromKey("name")) + ""; for (const auto &change : *entry.Changes) { @@ -351,13 +351,13 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { webhookptr = &webhook; } if (webhookptr != nullptr) { - markup = "" + user.GetEscapedString() + " " + - "updated the webhook " + + markup = user.GetEscapedBoldString() + + " updated the webhook " + Glib::Markup::escape_text(webhookptr->Name) + ""; } else { - markup = "" + user.GetEscapedString() + " " + - "updated a webhook"; + markup = user.GetEscapedBoldString() + + " updated a webhook"; } if (entry.Changes.has_value()) for (const auto &change : *entry.Changes) { @@ -380,20 +380,20 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { } } break; case AuditLogActionType::WEBHOOK_DELETE: { - markup = "" + user.GetEscapedString() + " " + - "deleted the webhook " + + markup = user.GetEscapedBoldString() + + " deleted the webhook " + Glib::Markup::escape_text(*entry.GetOldFromKey("name")) + ""; } break; case AuditLogActionType::EMOJI_CREATE: { - markup = "" + user.GetEscapedString() + " " + - "created the emoji " + + markup = user.GetEscapedBoldString() + + " created the emoji " + Glib::Markup::escape_text(*entry.GetNewFromKey("name")) + ""; } break; case AuditLogActionType::EMOJI_UPDATE: { - markup = "" + user.GetEscapedString() + " " + - "updated the emoji " + + markup = user.GetEscapedBoldString() + + " updated the emoji " + Glib::Markup::escape_text(*entry.GetOldFromKey("name")) + ""; extra_markup.push_back("Changed the name from " + @@ -403,8 +403,8 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { ""); } break; case AuditLogActionType::EMOJI_DELETE: { - markup = "" + user.GetEscapedString() + " " + - "deleted the emoji " + + markup = user.GetEscapedBoldString() + + " deleted the emoji " + Glib::Markup::escape_text(*entry.GetOldFromKey("name")) + ""; } break; @@ -412,42 +412,42 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { const auto channel = discord.GetChannel(*entry.Options->ChannelID); const auto count = *entry.Options->Count; if (channel.has_value()) { - markup = "" + user.GetEscapedString() + " " + - "deleted " + count + " messages in #" + + markup = user.GetEscapedBoldString() + + " deleted " + count + " messages in #" + Glib::Markup::escape_text(*channel->Name) + ""; } else { - markup = "" + user.GetEscapedString() + " " + - "deleted " + count + " messages"; + markup = user.GetEscapedBoldString() + + " deleted " + count + " messages"; } } break; case AuditLogActionType::MESSAGE_BULK_DELETE: { const auto channel = discord.GetChannel(entry.TargetID); if (channel.has_value()) { - markup = "" + user.GetEscapedString() + " " + - "deleted " + + markup = user.GetEscapedBoldString() + + " deleted " + *entry.Options->Count + " messages in #" + Glib::Markup::escape_text(*channel->Name) + ""; } else { - markup = "" + user.GetEscapedString() + " " + - "deleted " + + markup = user.GetEscapedBoldString() + + " deleted " + *entry.Options->Count + " messages"; } } break; case AuditLogActionType::MESSAGE_PIN: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "pinned a message by " + + markup = user.GetEscapedBoldString() + + " pinned a message by " + target_user->GetEscapedString() + ""; } break; case AuditLogActionType::MESSAGE_UNPIN: { const auto target_user = discord.GetUser(entry.TargetID); - markup = "" + user.GetEscapedString() + " " + - "unpinned a message by " + + markup = user.GetEscapedBoldString() + + " unpinned a message by " + target_user->GetEscapedString() + ""; } break; -- cgit v1.2.3