TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 1 | import { GuildChannel, AuditLogEvent, ChannelType, TextChannel, VoiceChannel, StageChannel } from 'discord.js'; |
| 2 | import type { GuildAuditLogsEntry } from 'discord.js'; |
| 3 | //@ts-expect-error |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 4 | import humanizeDuration from "humanize-duration"; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 5 | import type { NucleusClient } from "../utils/client.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 6 | import getEmojiByName from "../utils/getEmojiByName.js"; |
TheCodedProf | b493b8a | 2023-01-18 21:11:00 -0500 | [diff] [blame] | 7 | import c from "../utils/client.js"; |
PineaFan | 19dc9b8 | 2023-01-19 12:25:54 +0000 | [diff] [blame] | 8 | import { capitalize } from "../utils/generateKeyValueList.js"; |
| 9 | |
TheCodedProf | b493b8a | 2023-01-18 21:11:00 -0500 | [diff] [blame] | 10 | let entry = c.logger.entry; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 11 | |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 12 | const channelTypeEmoji: Record<number, string> = { |
| 13 | 0: "Text", // Text channel |
| 14 | 2: "Voice", // Voice channel |
| 15 | 5: "Announcement", // Announcement channel |
| 16 | 13: "Stage", // Stage channel |
| 17 | 15: "Forum", // Forum channel |
| 18 | 99: "Rules" // Rules channel |
| 19 | }; |
| 20 | |
| 21 | interface channelChanges { |
TheCodedProf | b493b8a | 2023-01-18 21:11:00 -0500 | [diff] [blame] | 22 | channelId: ReturnType<typeof entry>; |
| 23 | channel: ReturnType<typeof entry>; |
| 24 | edited: ReturnType<typeof entry>; |
| 25 | editedBy: ReturnType<typeof entry>; |
| 26 | type?: ReturnType<typeof entry>; |
| 27 | name?: ReturnType<typeof entry>; |
| 28 | position?: ReturnType<typeof entry>; |
| 29 | description?: ReturnType<typeof entry>; |
| 30 | nsfw?: ReturnType<typeof entry>; |
| 31 | slowmode?: ReturnType<typeof entry>; |
| 32 | topic?: ReturnType<typeof entry>; |
| 33 | bitrate?: ReturnType<typeof entry>; |
| 34 | userLimit?: ReturnType<typeof entry>; |
TheCodedProf | b493b8a | 2023-01-18 21:11:00 -0500 | [diff] [blame] | 35 | parent?: ReturnType<typeof entry>; |
| 36 | permissionOverwrites?: ReturnType<typeof entry>; |
| 37 | region?: ReturnType<typeof entry>; |
| 38 | maxUsers?: ReturnType<typeof entry>; |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 39 | autoArchiveDuration?: ReturnType<typeof entry>; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | |
| 43 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 44 | export const event = "channelUpdate"; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 45 | |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 46 | export async function callback(client: NucleusClient, oldChannel: GuildChannel, newChannel: GuildChannel) { |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 47 | const { getAuditLog, log, isLogging, NucleusColors, renderDelta, renderUser, renderChannel } = client.logger; |
| 48 | if (!await isLogging(newChannel.guild.id, "channelUpdate")) return; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 49 | const config = await client.memory.readGuildInfo(newChannel.guild.id); |
TheCodedProf | b493b8a | 2023-01-18 21:11:00 -0500 | [diff] [blame] | 50 | entry = client.logger.entry; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 51 | if (newChannel.parent && newChannel.parent.id === config.tickets.category) return; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 52 | |
PineaFan | c4d6c3f | 2023-01-19 12:17:25 +0000 | [diff] [blame] | 53 | const auditLog: null | GuildAuditLogsEntry<AuditLogEvent.ChannelUpdate> = (await getAuditLog(newChannel.guild, AuditLogEvent.ChannelUpdate)) |
| 54 | .filter((entry: GuildAuditLogsEntry) => (entry.target as GuildChannel)!.id === newChannel.id)[0] as GuildAuditLogsEntry<AuditLogEvent.ChannelUpdate> | null; |
| 55 | if (!auditLog) return; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 56 | if (auditLog.executor!.id === client.user!.id) return; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 57 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 58 | let emoji: string; |
| 59 | let readableType: string; |
| 60 | let displayName: string; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 61 | const changes: channelChanges = { |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 62 | channelId: entry(newChannel.id, `\`${newChannel.id}\``), |
| 63 | channel: entry(newChannel.id, renderChannel(newChannel)), |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 64 | edited: entry(Date.now(), renderDelta(Date.now())), |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 65 | editedBy: entry(auditLog.executor!.id, renderUser((await newChannel.guild.members.fetch(auditLog.executor!.id)).user)), |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 66 | }; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 67 | if (oldChannel.name !== newChannel.name) changes.name = entry([oldChannel.name, newChannel.name], `${oldChannel.name} -> ${newChannel.name}`); |
| 68 | if (oldChannel.position !== newChannel.position) |
TheCodedProf | 60a1f49 | 2023-01-18 16:59:20 -0500 | [diff] [blame] | 69 | changes.position = entry([oldChannel.position.toString(), newChannel.position.toString()], `${oldChannel.position} -> ${newChannel.position}`); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 70 | |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 71 | switch (newChannel.type) { |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 72 | case ChannelType.PrivateThread: |
| 73 | case ChannelType.PublicThread: { |
| 74 | return; |
| 75 | } |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 76 | case ChannelType.GuildText: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 77 | emoji = "CHANNEL.TEXT.EDIT"; |
| 78 | readableType = "Text"; |
| 79 | displayName = "Text Channel"; |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 80 | let oldTopic = (oldChannel as TextChannel).topic ?? "*None*", |
| 81 | newTopic = (oldChannel as TextChannel).topic ?? "*None*"; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 82 | if (oldTopic) { |
| 83 | if (oldTopic.length > 256) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 84 | oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 85 | else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``; |
| 86 | } else { |
| 87 | oldTopic = "None"; |
| 88 | } |
| 89 | if (newTopic) { |
| 90 | if (newTopic.length > 256) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 91 | newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 92 | else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``; |
| 93 | } else { |
| 94 | newTopic = "None"; |
| 95 | } |
| 96 | const nsfw = ["", ""]; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 97 | nsfw[0] = (oldChannel as TextChannel).nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`; |
| 98 | nsfw[1] = (newChannel as TextChannel).nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`; |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 99 | if (oldTopic !== newTopic) |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 100 | changes.description = entry([(oldChannel as TextChannel).topic ?? "", (newChannel as TextChannel).topic ?? ""], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`); |
| 101 | if ((oldChannel as TextChannel).nsfw !== (newChannel as TextChannel).nsfw) changes.nsfw = entry([(oldChannel as TextChannel).nsfw ? "On" : "Off", (newChannel as TextChannel).nsfw ? "On" : "Off"], `${nsfw[0]} -> ${nsfw[1]}`); |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 102 | if ((oldChannel as TextChannel).rateLimitPerUser !== (newChannel as TextChannel).rateLimitPerUser) |
| 103 | changes.slowmode = entry( |
PineaFan | 638eb13 | 2023-01-19 10:41:22 +0000 | [diff] [blame] | 104 | [((oldChannel as TextChannel).rateLimitPerUser).toString(), ((newChannel as TextChannel).rateLimitPerUser).toString()], |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 105 | `${humanizeDuration((oldChannel as TextChannel).rateLimitPerUser * 1000)} -> ${humanizeDuration((newChannel as TextChannel).rateLimitPerUser * 1000)}` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 106 | ); |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 107 | if((oldChannel as TextChannel).defaultAutoArchiveDuration !== (newChannel as TextChannel).defaultAutoArchiveDuration) { |
| 108 | changes.autoArchiveDuration = entry( |
| 109 | [((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString(), ((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString()], |
| 110 | `${humanizeDuration(((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)} -> ${humanizeDuration(((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)}` |
| 111 | ); |
| 112 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 113 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 114 | break; |
| 115 | } |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 116 | case ChannelType.GuildAnnouncement: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 117 | emoji = "CHANNEL.TEXT.EDIT"; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 118 | readableType = "Announcement"; |
PineaFan | 638eb13 | 2023-01-19 10:41:22 +0000 | [diff] [blame] | 119 | displayName = "Announcement Channel"; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 120 | let oldTopic = (oldChannel as TextChannel).topic, |
| 121 | newTopic = (newChannel as TextChannel).topic; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 122 | if (oldTopic) { |
| 123 | if (oldTopic.length > 256) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 124 | oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 125 | else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``; |
| 126 | } else { |
| 127 | oldTopic = "None"; |
| 128 | } |
| 129 | if (newTopic) { |
| 130 | if (newTopic.length > 256) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 131 | newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 132 | else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``; |
| 133 | } else { |
| 134 | newTopic = "None"; |
| 135 | } |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 136 | if ((oldChannel as TextChannel).nsfw !== (newChannel as TextChannel).nsfw) { |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 137 | changes.nsfw = entry([(oldChannel as TextChannel).nsfw ? "On" : "Off", (newChannel as TextChannel).nsfw ? "On" : "Off"], `${(oldChannel as TextChannel).nsfw ? "On" : "Off"} -> ${(newChannel as TextChannel).nsfw ? "On" : "Off"}`); |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 138 | } |
| 139 | if((oldChannel as TextChannel).defaultAutoArchiveDuration !== (newChannel as TextChannel).defaultAutoArchiveDuration) { |
| 140 | changes.autoArchiveDuration = entry( |
| 141 | [((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString(), ((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320).toString()], |
| 142 | `${humanizeDuration(((oldChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)} -> ${humanizeDuration(((newChannel as TextChannel).defaultAutoArchiveDuration ?? 4320) * 60 * 1000)}` |
| 143 | ); |
| 144 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 145 | break; |
| 146 | } |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 147 | case ChannelType.GuildVoice: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 148 | emoji = "CHANNEL.VOICE.EDIT"; |
| 149 | readableType = "Voice"; |
| 150 | displayName = "Voice Channel"; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 151 | if ((oldChannel as VoiceChannel).bitrate !== (newChannel as VoiceChannel).bitrate) |
| 152 | changes.bitrate = entry([(oldChannel as VoiceChannel).bitrate.toString(), (newChannel as VoiceChannel).bitrate.toString()], `${(oldChannel as VoiceChannel).bitrate} -> ${(newChannel as VoiceChannel).bitrate}`); |
| 153 | if ((oldChannel as VoiceChannel).userLimit !== (newChannel as VoiceChannel).userLimit) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 154 | changes.maxUsers = entry( |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 155 | [(oldChannel as VoiceChannel).userLimit.toString(), (newChannel as VoiceChannel).userLimit.toString()], |
| 156 | `${(oldChannel as VoiceChannel).userLimit ? (oldChannel as VoiceChannel).userLimit : "Unlimited"} -> ${(newChannel as VoiceChannel).userLimit}` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 157 | ); |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 158 | if ((oldChannel as VoiceChannel).rtcRegion !== (newChannel as VoiceChannel).rtcRegion) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 159 | changes.region = entry( |
PineaFan | 19dc9b8 | 2023-01-19 12:25:54 +0000 | [diff] [blame] | 160 | [(oldChannel as VoiceChannel).rtcRegion ?? "automatic", (newChannel as VoiceChannel).rtcRegion ?? "automatic"], |
| 161 | `${capitalize((oldChannel as VoiceChannel).rtcRegion?.toUpperCase() ?? "automatic")} -> ${capitalize((newChannel as VoiceChannel).rtcRegion?.toUpperCase() ?? "automatic")}` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 162 | ); |
| 163 | break; |
| 164 | } |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 165 | case ChannelType.GuildStageVoice: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 166 | emoji = "CHANNEL.VOICE.EDIT"; |
| 167 | readableType = "Stage"; |
| 168 | displayName = "Stage Channel"; |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 169 | let oldTopic = (oldChannel as StageChannel).topic, |
| 170 | newTopic = (newChannel as StageChannel).topic; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 171 | if (oldTopic) { |
| 172 | if (oldTopic.length > 256) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 173 | oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 174 | else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``; |
| 175 | } else { |
| 176 | oldTopic = "None"; |
| 177 | } |
| 178 | if (newTopic) { |
| 179 | if (newTopic.length > 256) |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 180 | newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 181 | else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``; |
| 182 | } else { |
| 183 | newTopic = "None"; |
| 184 | } |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 185 | if ((oldChannel as StageChannel).bitrate !== (newChannel as StageChannel).bitrate) |
| 186 | changes.bitrate = entry([(oldChannel as StageChannel).bitrate.toString(), (newChannel as StageChannel).bitrate.toString()], `${(oldChannel as StageChannel).bitrate} -> ${(newChannel as StageChannel).bitrate}`); |
| 187 | if ((oldChannel as StageChannel).userLimit !== (newChannel as StageChannel).userLimit) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 188 | changes.maxUsers = entry( |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 189 | [(oldChannel as StageChannel).userLimit.toString(), (newChannel as StageChannel).userLimit.toString()], |
| 190 | `${(oldChannel as StageChannel).userLimit ? (oldChannel as StageChannel).userLimit : "Unlimited"} -> ${(newChannel as StageChannel).userLimit}` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 191 | ); |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 192 | if ((oldChannel as StageChannel).rtcRegion !== (newChannel as StageChannel).rtcRegion) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 193 | changes.region = entry( |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 194 | [(oldChannel as StageChannel).rtcRegion ?? "Automatic", (newChannel as StageChannel).rtcRegion ?? "Automatic"], |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame^] | 195 | `${capitalize((oldChannel as StageChannel).rtcRegion?.toLowerCase() ?? "automatic")} -> ${capitalize((newChannel as StageChannel).rtcRegion?.toLowerCase() ?? "automatic")}` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 196 | ); |
| 197 | break; |
| 198 | } |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 199 | case ChannelType.GuildCategory: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 200 | emoji = "CHANNEL.CATEGORY.EDIT"; |
| 201 | readableType = "Category"; |
| 202 | displayName = "Category"; |
| 203 | break; |
| 204 | } |
| 205 | default: { |
| 206 | emoji = "CHANNEL.TEXT.EDIT"; |
| 207 | readableType = "Channel"; |
| 208 | displayName = "Channel"; |
| 209 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 210 | } |
PineaFan | 638eb13 | 2023-01-19 10:41:22 +0000 | [diff] [blame] | 211 | const ocType = channelTypeEmoji[oldChannel.type], |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 212 | ncType = channelTypeEmoji[newChannel.type]; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 213 | if (oldChannel.type !== newChannel.type) |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 214 | changes.type = entry([ocType!, ncType!], `${ocType!} -> ${readableType}`); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 215 | if (!(Object.values(changes).length - 4)) return; |
| 216 | const data = { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 217 | meta: { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 218 | type: "channelUpdate", |
| 219 | displayName: displayName + " Edited", |
| 220 | calculateType: "channelUpdate", |
| 221 | color: NucleusColors.yellow, |
| 222 | emoji: emoji, |
TheCodedProf | 309d618 | 2023-01-18 18:10:29 -0500 | [diff] [blame] | 223 | timestamp: auditLog.createdTimestamp |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 224 | }, |
| 225 | list: changes, |
| 226 | hidden: { |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 227 | guild: newChannel.guild.id |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 228 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 229 | }; |
| 230 | log(data); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 231 | } |