forked from OpenGamers/abaddon
handle stage-related audit log action types
This commit is contained in:
@@ -40,6 +40,9 @@ enum class AuditLogActionType {
|
|||||||
INTEGRATION_CREATE = 80,
|
INTEGRATION_CREATE = 80,
|
||||||
INTEGRATION_UPDATE = 81,
|
INTEGRATION_UPDATE = 81,
|
||||||
INTEGRATION_DELETE = 82,
|
INTEGRATION_DELETE = 82,
|
||||||
|
STAGE_INSTANCE_CREATE = 83,
|
||||||
|
STAGE_INSTANCE_UPDATE = 84,
|
||||||
|
STAGE_INSTANCE_DELETE = 85,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AuditLogChange {
|
struct AuditLogChange {
|
||||||
|
|||||||
@@ -21,6 +21,22 @@ enum class ChannelType : int {
|
|||||||
GUILD_STAGE_VOICE = 13,
|
GUILD_STAGE_VOICE = 13,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class StagePrivacy {
|
||||||
|
PUBLIC = 1,
|
||||||
|
GUILD_ONLY = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr const char *GetStagePrivacyDisplayString(StagePrivacy e) {
|
||||||
|
switch (e) {
|
||||||
|
case StagePrivacy::PUBLIC:
|
||||||
|
return "Public";
|
||||||
|
case StagePrivacy::GUILD_ONLY:
|
||||||
|
return "Guild Only";
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ChannelData {
|
struct ChannelData {
|
||||||
Snowflake ID;
|
Snowflake ID;
|
||||||
ChannelType Type;
|
ChannelType Type;
|
||||||
|
|||||||
@@ -460,6 +460,82 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
|||||||
target_user->GetEscapedString() +
|
target_user->GetEscapedString() +
|
||||||
"</b>";
|
"</b>";
|
||||||
} break;
|
} break;
|
||||||
|
case AuditLogActionType::STAGE_INSTANCE_CREATE: {
|
||||||
|
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||||
|
if (channel.has_value()) {
|
||||||
|
markup = user_markup +
|
||||||
|
" started the stage for <b>" +
|
||||||
|
Glib::Markup::escape_text(*channel->Name) +
|
||||||
|
"</b>";
|
||||||
|
} else {
|
||||||
|
markup = user_markup +
|
||||||
|
" started the stage for <b>" +
|
||||||
|
std::to_string(*entry.Options->ChannelID) +
|
||||||
|
"</b>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.Changes.has_value()) {
|
||||||
|
for (const auto &change : *entry.Changes) {
|
||||||
|
if (change.Key == "topic" && change.NewValue.has_value()) {
|
||||||
|
extra_markup.push_back(
|
||||||
|
"Set the topic to <b>" +
|
||||||
|
Glib::Markup::escape_text(change.NewValue->get<std::string>()) +
|
||||||
|
"</b>");
|
||||||
|
} else if (change.Key == "privacy_level" && change.NewValue.has_value()) {
|
||||||
|
Glib::ustring str = Glib::Markup::escape_text(GetStagePrivacyDisplayString(change.NewValue->get<StagePrivacy>()));
|
||||||
|
extra_markup.push_back(
|
||||||
|
"Set the privacy level to <b>" +
|
||||||
|
str +
|
||||||
|
"</b>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case AuditLogActionType::STAGE_INSTANCE_UPDATE: {
|
||||||
|
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||||
|
if (channel.has_value()) {
|
||||||
|
markup = user_markup +
|
||||||
|
" updated the stage for <b>" +
|
||||||
|
Glib::Markup::escape_text(*channel->Name) +
|
||||||
|
"</b>";
|
||||||
|
} else {
|
||||||
|
markup = user_markup +
|
||||||
|
" updated the stage for <b>" +
|
||||||
|
std::to_string(*entry.Options->ChannelID) +
|
||||||
|
"</b>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.Changes.has_value()) {
|
||||||
|
for (const auto &change : *entry.Changes) {
|
||||||
|
if (change.Key == "topic" && change.NewValue.has_value()) {
|
||||||
|
extra_markup.push_back(
|
||||||
|
"Set the topic to <b>" +
|
||||||
|
Glib::Markup::escape_text(change.NewValue->get<std::string>()) +
|
||||||
|
"</b>");
|
||||||
|
} else if (change.Key == "privacy_level" && change.NewValue.has_value()) {
|
||||||
|
Glib::ustring str = Glib::Markup::escape_text(GetStagePrivacyDisplayString(change.NewValue->get<StagePrivacy>()));
|
||||||
|
extra_markup.push_back(
|
||||||
|
"Set the privacy level to <b>" +
|
||||||
|
str +
|
||||||
|
"</b>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case AuditLogActionType::STAGE_INSTANCE_DELETE: {
|
||||||
|
const auto channel = discord.GetChannel(*entry.Options->ChannelID);
|
||||||
|
if (channel.has_value()) {
|
||||||
|
markup = user_markup +
|
||||||
|
" ended the stage for <b>" +
|
||||||
|
Glib::Markup::escape_text(*channel->Name) +
|
||||||
|
"</b>";
|
||||||
|
} else {
|
||||||
|
markup = user_markup +
|
||||||
|
" ended the stage for <b>" +
|
||||||
|
std::to_string(*entry.Options->ChannelID) +
|
||||||
|
"</b>";
|
||||||
|
}
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
markup = "<i>Unknown action</i>";
|
markup = "<i>Unknown action</i>";
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user