// SPDX-License-Identifier: AGPL-3.0-or-later import type {Channel} from '../models/Channel'; import type {Guild} from '../models/Guild'; import type {GuildEmoji} from '../models/GuildEmoji'; import type {GuildSticker} from '../models/GuildSticker'; import {toIdString, toSortedIdArray} from './IdUtils'; export function serializeGuildForAudit(guild: Guild): Record { return { guild_id: guild.id.toString(), name: guild.name, owner_id: guild.ownerId.toString(), vanity_url_code: guild.vanityUrlCode ?? null, icon_hash: guild.iconHash ?? null, banner_hash: guild.bannerHash ?? null, banner_width: guild.bannerWidth ?? null, banner_height: guild.bannerHeight ?? null, splash_hash: guild.splashHash ?? null, splash_width: guild.splashWidth ?? null, splash_height: guild.splashHeight ?? null, splash_card_alignment: guild.splashCardAlignment, embed_splash_hash: guild.embedSplashHash ?? null, embed_splash_width: guild.embedSplashWidth ?? null, embed_splash_height: guild.embedSplashHeight ?? null, features: toSortedIdArray(guild.features), verification_level: guild.verificationLevel, mfa_level: guild.mfaLevel, nsfw_level: guild.nsfwLevel, nsfw: guild.nsfw, content_warning_level: guild.contentWarningLevel, content_warning_text: guild.contentWarningText, explicit_content_filter: guild.explicitContentFilter, default_message_notifications: guild.defaultMessageNotifications, system_channel_id: toIdString(guild.systemChannelId), system_channel_flags: guild.systemChannelFlags, rules_channel_id: toIdString(guild.rulesChannelId), afk_channel_id: toIdString(guild.afkChannelId), afk_timeout: guild.afkTimeout, disabled_operations: guild.disabledOperations, member_count: guild.memberCount, message_history_cutoff: guild.messageHistoryCutoff ? guild.messageHistoryCutoff.toISOString() : null, }; } export function serializeChannelForAudit(channel: Channel): Record { return { channel_id: channel.id.toString(), type: channel.type, name: channel.name ?? null, topic: channel.topic ?? null, parent_id: toIdString(channel.parentId), position: channel.position, nsfw: channel.nsfwOverride, content_warning_level: channel.contentWarningLevel, content_warning_text: channel.contentWarningText, rate_limit_per_user: channel.rateLimitPerUser, user_limit: channel.userLimit, voice_connection_limit: channel.voiceConnectionLimit, bitrate: channel.bitrate, rtc_region: channel.rtcRegion ?? null, permission_overwrite_count: channel.permissionOverwrites ? channel.permissionOverwrites.size : 0, }; } export function serializeEmojiForAudit(emoji: GuildEmoji): Record { return { emoji_id: emoji.id.toString(), name: emoji.name, animated: emoji.isAnimated, creator_id: emoji.creatorId.toString(), }; } export function serializeStickerForAudit(sticker: GuildSticker): Record { return { sticker_id: sticker.id.toString(), name: sticker.name, description: sticker.description, animated: sticker.animated, creator_id: sticker.creatorId.toString(), }; }