|
4 | 4 | AuditLogActions,
|
5 | 5 | AuditLogChangeKeys,
|
6 | 6 | ClientEvents,
|
| 7 | + DetritusKeys, |
| 8 | + DiscordKeys, |
7 | 9 | MessageFlags,
|
8 | 10 | UserFlags as DiscordUserFlags,
|
9 | 11 | MAX_ATTACHMENT_SIZE,
|
@@ -543,7 +545,17 @@ class GuildLoggingStore extends Store<string, GuildLogStorage> {
|
543 | 545 | }
|
544 | 546 |
|
545 | 547 | {
|
546 |
| - const keys = ['avatar', 'deaf', 'hoistedRole', 'mute', 'nick', 'premiumSince', 'roles']; |
| 548 | + const keys = [ |
| 549 | + DetritusKeys[DiscordKeys.AVATAR], |
| 550 | + DetritusKeys[DiscordKeys.COMMUNICATION_DISABLED_UNTIL], |
| 551 | + DetritusKeys[DiscordKeys.DEAF], |
| 552 | + DetritusKeys[DiscordKeys.HOISTED_ROLE], |
| 553 | + DetritusKeys[DiscordKeys.IS_PENDING], |
| 554 | + DetritusKeys[DiscordKeys.MUTE], |
| 555 | + DetritusKeys[DiscordKeys.NICK], |
| 556 | + DetritusKeys[DiscordKeys.PREMIUM_SINCE], |
| 557 | + DetritusKeys[DiscordKeys.ROLES], |
| 558 | + ]; |
547 | 559 | const name = ClientEvents.GUILD_MEMBER_UPDATE;
|
548 | 560 |
|
549 | 561 | const subscription = cluster.subscribe(name, async (payload) => {
|
@@ -596,7 +608,16 @@ class GuildLoggingStore extends Store<string, GuildLogStorage> {
|
596 | 608 | subscriptions.push(subscription);
|
597 | 609 | }
|
598 | 610 | {
|
599 |
| - const keys = ['color', 'hoist', 'icon', 'mentionable', 'name', 'permissions', 'position', 'unicodeEmoji']; |
| 611 | + const keys = [ |
| 612 | + DetritusKeys[DiscordKeys.COLOR], |
| 613 | + DetritusKeys[DiscordKeys.HOIST], |
| 614 | + DetritusKeys[DiscordKeys.ICON], |
| 615 | + DetritusKeys[DiscordKeys.MENTIONABLE], |
| 616 | + DetritusKeys[DiscordKeys.NAME], |
| 617 | + DetritusKeys[DiscordKeys.PERMISSIONS], |
| 618 | + DetritusKeys[DiscordKeys.POSITION], |
| 619 | + DetritusKeys[DiscordKeys.UNICODE_EMOJI], |
| 620 | + ]; |
600 | 621 | const name = ClientEvents.GUILD_ROLE_UPDATE;
|
601 | 622 |
|
602 | 623 | const subscription = cluster.subscribe(name, async (payload) => {
|
@@ -1008,6 +1029,19 @@ export function createLogPayload(
|
1008 | 1029 | for (let audit of audits) {
|
1009 | 1030 | for (let [x, change] of audit.changes) {
|
1010 | 1031 | switch (change.key) {
|
| 1032 | + case AuditLogChangeKeys.COMMUNICATION_DISABLED_UNTIL: { |
| 1033 | + description.push(`- Timeout Change`); |
| 1034 | + if (change.newValue) { |
| 1035 | + // must check if oldValue is newer than now to consider it a change |
| 1036 | + if (change.oldValue && Date.now() < Date.parse(change.oldValue)) { |
| 1037 | + description.push(`-> Timeout changed from ${change.oldValue} to ${change.newValue}`); |
| 1038 | + } else { |
| 1039 | + description.push(`-> Timed out until ${change.newValue}`); |
| 1040 | + } |
| 1041 | + } else { |
| 1042 | + description.push(`-> Timeout Cleared`); |
| 1043 | + } |
| 1044 | + }; break; |
1011 | 1045 | case AuditLogChangeKeys.DEAF: {
|
1012 | 1046 | if (change.newValue) {
|
1013 | 1047 | description.push(`- Deafened`);
|
@@ -1071,6 +1105,19 @@ export function createLogPayload(
|
1071 | 1105 |
|
1072 | 1106 | // for non-premium guilds and when someone unboosts/boosts
|
1073 | 1107 | if (!audits) {
|
| 1108 | + if (member.communicationDisabledUntilUnix !== old.communicationDisabledUntilUnix) { |
| 1109 | + description.push(`- Timeout Change`); |
| 1110 | + if (member.communicationDisabledUntilUnix) { |
| 1111 | + if (old.communicationDisabledUntilUnix && Date.now() < old.communicationDisabledUntilUnix) { |
| 1112 | + description.push(`-> Timeout changed from ${old.communicationDisabledUntil} to ${member.communicationDisabledUntil}`); |
| 1113 | + } else { |
| 1114 | + description.push(`-> Timed out until ${member.communicationDisabledUntil}`); |
| 1115 | + } |
| 1116 | + } else { |
| 1117 | + description.push(`-> Timeout Cleared`); |
| 1118 | + } |
| 1119 | + } |
| 1120 | + |
1074 | 1121 | if (member.deaf !== old.deaf || member.mute !== old.deaf) {
|
1075 | 1122 | const text: Array<string> = [];
|
1076 | 1123 | if (member.deaf !== old.deaf) {
|
@@ -1174,13 +1221,23 @@ export function createLogPayload(
|
1174 | 1221 | }
|
1175 | 1222 | }
|
1176 | 1223 |
|
| 1224 | + if (member.isPending !== old.isPending) { |
| 1225 | + description.push(`- Pending Change`); |
| 1226 | + if (member.isPending) { |
| 1227 | + description.push('-> Is Pending'); |
| 1228 | + } else { |
| 1229 | + description.push(`-> No longer pending`); |
| 1230 | + } |
| 1231 | + } |
| 1232 | + |
1177 | 1233 | if (member.avatar !== old.avatar) {
|
| 1234 | + description.push('- Server Avatar Change'); |
1178 | 1235 | if (member.avatar && old.avatar) {
|
1179 |
| - description.push('- Changed their Server Avatar'); |
| 1236 | + description.push('-> Changed their Server Avatar'); |
1180 | 1237 | } else if (member.avatar && !old.avatar) {
|
1181 |
| - description.push('- Set their Server Avatar'); |
| 1238 | + description.push('-> Set their Server Avatar'); |
1182 | 1239 | } else if (!member.avatar && old.avatar) {
|
1183 |
| - description.push('- Removed their Server Avatar'); |
| 1240 | + description.push('-> Removed their Server Avatar'); |
1184 | 1241 | }
|
1185 | 1242 | }
|
1186 | 1243 |
|
|
0 commit comments