Skip to content

Commit c4c881f

Browse files
committed
Allow voice mods to access modlogs
1 parent b8bb8b9 commit c4c881f

3 files changed

Lines changed: 130 additions & 64 deletions

File tree

src/modules/wheatley/components/moderation/moderation-common.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ensure_index } from "../../../../infra/database-interface.js";
1919
import { Wheatley } from "../../../../wheatley.js";
2020
import { colors, HOUR, MINUTE } from "../../../../common.js";
2121
import { parse_time_unit } from "../../../../utils/time.js";
22-
import Modlogs from "./modlogs.js";
22+
import Modlogs, { staff_moderation_display_options, public_moderation_display_options } from "./modlogs.js";
2323
import { TextBasedCommand } from "../../../../command-abstractions/text-based-command.js";
2424
import {
2525
moderation_state,
@@ -399,7 +399,11 @@ export abstract class ModerationComponent extends BotComponent {
399399
}
400400
await this.staff_action_log.send({
401401
embeds: [
402-
Modlogs.case_summary(entry, await this.wheatley.client.users.fetch(entry.user), true)
402+
Modlogs.case_summary(
403+
entry,
404+
await this.wheatley.client.users.fetch(entry.user),
405+
staff_moderation_display_options,
406+
)
403407
.setTitle(`${capitalize(this.type)} is being lifted (case ${entry.case_number})`)
404408
.setDescription(
405409
has_other_active
@@ -552,7 +556,11 @@ export abstract class ModerationComponent extends BotComponent {
552556
}
553557
const message_options: Discord.MessageCreateOptions = {
554558
embeds: [
555-
Modlogs.case_summary(moderation, await this.wheatley.client.users.fetch(moderation.user), true),
559+
Modlogs.case_summary(
560+
moderation,
561+
await this.wheatley.client.users.fetch(moderation.user),
562+
staff_moderation_display_options,
563+
),
556564
],
557565
};
558566
// Only include the red telephone button if this is not an automatic moderation
@@ -575,7 +583,7 @@ export abstract class ModerationComponent extends BotComponent {
575583
Modlogs.case_summary(
576584
moderation,
577585
await this.wheatley.client.users.fetch(moderation.user),
578-
false,
586+
public_moderation_display_options,
579587
),
580588
],
581589
})
@@ -887,17 +895,23 @@ export abstract class ModerationComponent extends BotComponent {
887895
});
888896
await this.staff_action_log.send({
889897
embeds: [
890-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), true)
898+
Modlogs.case_summary(
899+
res,
900+
await this.wheatley.client.users.fetch(res.user),
901+
staff_moderation_display_options,
902+
)
891903
.setTitle(`Removed case ${res.case_number}: Un${this.past_participle}`)
892904
.setDescription(remaining_message),
893905
],
894906
});
895907
if (res.type !== "note") {
896908
await this.public_action_log.send({
897909
embeds: [
898-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), false).setTitle(
899-
`Removed case ${res.case_number}: Un${this.past_participle}`,
900-
),
910+
Modlogs.case_summary(
911+
res,
912+
await this.wheatley.client.users.fetch(res.user),
913+
public_moderation_display_options,
914+
).setTitle(`Removed case ${res.case_number}: Un${this.past_participle}`),
901915
],
902916
});
903917
}

src/modules/wheatley/components/moderation/moderation-control.ts

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ModerationComponent, parse_duration } from "./moderation-common.js";
1010
import { moderation_entry } from "./schemata.js";
1111
import { CommandSetBuilder } from "../../../../command-abstractions/command-set-builder.js";
1212
import { colors } from "../../../../common.js";
13-
import Modlogs from "./modlogs.js";
13+
import Modlogs, { staff_moderation_display_options, public_moderation_display_options } from "./modlogs.js";
1414
import {
1515
EarlyReplyMode,
1616
TextBasedCommandBuilder,
@@ -150,17 +150,21 @@ export default class ModerationControl extends BotComponent {
150150
await this.reply_with_success(command, "Reason updated");
151151
await this.staff_action_log.send({
152152
embeds: [
153-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), true).setTitle(
154-
`Case ${res.case_number} reason updated`,
155-
),
153+
Modlogs.case_summary(
154+
res,
155+
await this.wheatley.client.users.fetch(res.user),
156+
staff_moderation_display_options,
157+
).setTitle(`Case ${res.case_number} reason updated`),
156158
],
157159
});
158160
if (res.type !== "note") {
159161
await this.public_action_log.send({
160162
embeds: [
161-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), false).setTitle(
162-
`Case ${res.case_number} reason updated`,
163-
),
163+
Modlogs.case_summary(
164+
res,
165+
await this.wheatley.client.users.fetch(res.user),
166+
public_moderation_display_options,
167+
).setTitle(`Case ${res.case_number} reason updated`),
164168
],
165169
});
166170
await this.notify_user(res.user, case_number, `**Reason:** ${reason}`);
@@ -186,9 +190,11 @@ export default class ModerationControl extends BotComponent {
186190
await this.reply_with_success(command, "Context updated");
187191
await this.staff_action_log.send({
188192
embeds: [
189-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), true).setTitle(
190-
`Case ${res.case_number} context updated`,
191-
),
193+
Modlogs.case_summary(
194+
res,
195+
await this.wheatley.client.users.fetch(res.user),
196+
staff_moderation_display_options,
197+
).setTitle(`Case ${res.case_number} context updated`),
192198
],
193199
});
194200
} else {
@@ -224,17 +230,21 @@ export default class ModerationControl extends BotComponent {
224230
this.wheatley.event_hub.emit("update_moderation", res);
225231
await this.staff_action_log.send({
226232
embeds: [
227-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), true).setTitle(
228-
`Case ${res.case_number} duration updated`,
229-
),
233+
Modlogs.case_summary(
234+
res,
235+
await this.wheatley.client.users.fetch(res.user),
236+
staff_moderation_display_options,
237+
).setTitle(`Case ${res.case_number} duration updated`),
230238
],
231239
});
232240
if (res.type !== "note") {
233241
await this.public_action_log.send({
234242
embeds: [
235-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), false).setTitle(
236-
`Case ${res.case_number} duration updated`,
237-
),
243+
Modlogs.case_summary(
244+
res,
245+
await this.wheatley.client.users.fetch(res.user),
246+
public_moderation_display_options,
247+
).setTitle(`Case ${res.case_number} duration updated`),
238248
],
239249
});
240250
const duration_str = res.duration ? time_to_human(res.duration) : "Permanent";
@@ -267,17 +277,21 @@ export default class ModerationControl extends BotComponent {
267277
this.wheatley.event_hub.emit("update_moderation", res);
268278
await this.staff_action_log.send({
269279
embeds: [
270-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), true).setTitle(
271-
`Case ${res.case_number} expunged`,
272-
),
280+
Modlogs.case_summary(
281+
res,
282+
await this.wheatley.client.users.fetch(res.user),
283+
staff_moderation_display_options,
284+
).setTitle(`Case ${res.case_number} expunged`),
273285
],
274286
});
275287
if (res.type !== "note") {
276288
await this.public_action_log.send({
277289
embeds: [
278-
Modlogs.case_summary(res, await this.wheatley.client.users.fetch(res.user), false).setTitle(
279-
`Case ${res.case_number} expunged`,
280-
),
290+
Modlogs.case_summary(
291+
res,
292+
await this.wheatley.client.users.fetch(res.user),
293+
public_moderation_display_options,
294+
).setTitle(`Case ${res.case_number} expunged`),
281295
],
282296
});
283297
await this.notify_user(res.user, case_number, `**Expunged:** ${reason ?? "No reason provided"}`);

0 commit comments

Comments
 (0)