forked from OpenGamers/abaddon
add thread stuff to audit log
This commit is contained in:
@@ -43,6 +43,12 @@ enum class AuditLogActionType {
|
|||||||
STAGE_INSTANCE_CREATE = 83,
|
STAGE_INSTANCE_CREATE = 83,
|
||||||
STAGE_INSTANCE_UPDATE = 84,
|
STAGE_INSTANCE_UPDATE = 84,
|
||||||
STAGE_INSTANCE_DELETE = 85,
|
STAGE_INSTANCE_DELETE = 85,
|
||||||
|
STICKER_CREATE = 90,
|
||||||
|
STICKER_UPDATE = 91,
|
||||||
|
STICKER_DELETE = 92,
|
||||||
|
THREAD_CREATE = 110,
|
||||||
|
THREAD_UPDATE = 111,
|
||||||
|
THREAD_DELETE = 112,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AuditLogChange {
|
struct AuditLogChange {
|
||||||
|
|||||||
@@ -537,6 +537,70 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) {
|
|||||||
"</b>";
|
"</b>";
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case AuditLogActionType::THREAD_CREATE: {
|
||||||
|
const auto channel = discord.GetChannel(entry.TargetID);
|
||||||
|
markup = user_markup +
|
||||||
|
" created a thread <b>" +
|
||||||
|
(channel.has_value()
|
||||||
|
? Glib::Markup::escape_text(*channel->Name)
|
||||||
|
: Glib::ustring(*entry.GetNewFromKey<std::string>("name"))) +
|
||||||
|
"</b>";
|
||||||
|
if (entry.Changes.has_value()) {
|
||||||
|
for (const auto &change : *entry.Changes) {
|
||||||
|
if (change.Key == "name")
|
||||||
|
extra_markup.push_back("Set the name to <b>" + Glib::Markup::escape_text(change.NewValue->get<std::string>()) + "</b>");
|
||||||
|
else if (change.Key == "archived")
|
||||||
|
extra_markup.push_back(change.NewValue->get<bool>() ? "Archived the thread" : "Unarchived the thread");
|
||||||
|
else if (change.Key == "auto_archive_duration")
|
||||||
|
extra_markup.push_back("Set auto archive duration to <b>"s + std::to_string(change.NewValue->get<int>()) + " minutes</b>"s);
|
||||||
|
else if (change.Key == "rate_limit_per_user" && change.NewValue.has_value()) {
|
||||||
|
const int secs = change.NewValue->get<int>();
|
||||||
|
if (secs == 0)
|
||||||
|
extra_markup.push_back("Disabled slowmode");
|
||||||
|
else
|
||||||
|
extra_markup.push_back("Set slowmode to <b>" +
|
||||||
|
std::to_string(secs) + " seconds</b>");
|
||||||
|
} else if (change.Key == "locked")
|
||||||
|
extra_markup.push_back(change.NewValue->get<bool>() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case AuditLogActionType::THREAD_UPDATE: {
|
||||||
|
const auto channel = discord.GetChannel(entry.TargetID);
|
||||||
|
markup = user_markup +
|
||||||
|
" made changes to the thread <b>" +
|
||||||
|
(channel.has_value()
|
||||||
|
? Glib::Markup::escape_text(*channel->Name)
|
||||||
|
: Glib::ustring(entry.TargetID)) +
|
||||||
|
"</b>";
|
||||||
|
for (const auto &change : *entry.Changes) {
|
||||||
|
if (change.Key == "name")
|
||||||
|
extra_markup.push_back(
|
||||||
|
"Changed the name from <b>" +
|
||||||
|
Glib::Markup::escape_text(change.OldValue->get<std::string>()) +
|
||||||
|
"</b> to <b>" +
|
||||||
|
Glib::Markup::escape_text(change.NewValue->get<std::string>()) +
|
||||||
|
"</b>");
|
||||||
|
else if (change.Key == "auto_archive_duration")
|
||||||
|
extra_markup.push_back("Set auto archive duration to <b>"s + std::to_string(change.NewValue->get<int>()) + " minutes</b>"s);
|
||||||
|
else if (change.Key == "rate_limit_per_user" && change.NewValue.has_value()) {
|
||||||
|
const int secs = change.NewValue->get<int>();
|
||||||
|
if (secs == 0)
|
||||||
|
extra_markup.push_back("Disabled slowmode");
|
||||||
|
else
|
||||||
|
extra_markup.push_back("Set slowmode to <b>" +
|
||||||
|
std::to_string(secs) +
|
||||||
|
" seconds</b>");
|
||||||
|
} else if (change.Key == "locked")
|
||||||
|
extra_markup.push_back(change.NewValue->get<bool>() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators");
|
||||||
|
else if (change.Key == "archived")
|
||||||
|
extra_markup.push_back(change.NewValue->get<bool>() ? "Archived the thread" : "Unarchived the thread");
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case AuditLogActionType::THREAD_DELETE: {
|
||||||
|
markup = user_markup +
|
||||||
|
" deleted the thread <b>" + Glib::Markup::escape_text(*entry.GetOldFromKey<std::string>("name")) + "</b>";
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
markup = "<i>Unknown action</i>";
|
markup = "<i>Unknown action</i>";
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user