Skip to content

Commit 08f01a7

Browse files
committed
Update detritus version and member logging
1 parent 2b3ed43 commit 08f01a7

File tree

2 files changed

+64
-8
lines changed

2 files changed

+64
-8
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
"dependencies": {
1111
"@sentry/node": "^6.4.1",
1212
"chrono-node": "^2.3.8",
13-
"detritus-client": "^0.17.0-beta.11",
13+
"detritus-client": "^0.17.0-beta.12",
1414
"emoji-aware": "^3.0.5",
1515
"juration": "^0.1.1",
1616
"moment": "^2.29.1",
1717
"moment-duration-format": "^2.3.2",
1818
"moment-timezone": "^0.5.32",
1919
"redis": "^3.1.2",
20-
"typescript": "^4.6.4",
21-
"undici": "^5.1.1"
20+
"typescript": "^4.6.4"
2221
},
2322
"devDependencies": {
2423
"@types/moment-duration-format": "^2.2.2",

src/stores/guildlogging.ts

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
AuditLogActions,
55
AuditLogChangeKeys,
66
ClientEvents,
7+
DetritusKeys,
8+
DiscordKeys,
79
MessageFlags,
810
UserFlags as DiscordUserFlags,
911
MAX_ATTACHMENT_SIZE,
@@ -543,7 +545,17 @@ class GuildLoggingStore extends Store<string, GuildLogStorage> {
543545
}
544546

545547
{
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+
];
547559
const name = ClientEvents.GUILD_MEMBER_UPDATE;
548560

549561
const subscription = cluster.subscribe(name, async (payload) => {
@@ -596,7 +608,16 @@ class GuildLoggingStore extends Store<string, GuildLogStorage> {
596608
subscriptions.push(subscription);
597609
}
598610
{
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+
];
600621
const name = ClientEvents.GUILD_ROLE_UPDATE;
601622

602623
const subscription = cluster.subscribe(name, async (payload) => {
@@ -1008,6 +1029,19 @@ export function createLogPayload(
10081029
for (let audit of audits) {
10091030
for (let [x, change] of audit.changes) {
10101031
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;
10111045
case AuditLogChangeKeys.DEAF: {
10121046
if (change.newValue) {
10131047
description.push(`- Deafened`);
@@ -1071,6 +1105,19 @@ export function createLogPayload(
10711105

10721106
// for non-premium guilds and when someone unboosts/boosts
10731107
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+
10741121
if (member.deaf !== old.deaf || member.mute !== old.deaf) {
10751122
const text: Array<string> = [];
10761123
if (member.deaf !== old.deaf) {
@@ -1174,13 +1221,23 @@ export function createLogPayload(
11741221
}
11751222
}
11761223

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+
11771233
if (member.avatar !== old.avatar) {
1234+
description.push('- Server Avatar Change');
11781235
if (member.avatar && old.avatar) {
1179-
description.push('- Changed their Server Avatar');
1236+
description.push('-> Changed their Server Avatar');
11801237
} else if (member.avatar && !old.avatar) {
1181-
description.push('- Set their Server Avatar');
1238+
description.push('-> Set their Server Avatar');
11821239
} else if (!member.avatar && old.avatar) {
1183-
description.push('- Removed their Server Avatar');
1240+
description.push('-> Removed their Server Avatar');
11841241
}
11851242
}
11861243

0 commit comments

Comments
 (0)