3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Turn on strict TS compilation. Fix up and tweak types accordingly.

This commit is contained in:
Dragory 2020-11-09 20:03:57 +02:00
parent 690955a399
commit 629002b8d9
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
172 changed files with 720 additions and 534 deletions

View file

@ -9,6 +9,7 @@ import {
ucfirst,
UserNotificationResult,
resolveMember,
UserNotificationMethod,
} from "../../../utils";
import { renderTemplate } from "../../../templateFormatter";
import { TextChannel, User } from "eris";
@ -20,8 +21,8 @@ import { Case } from "../../../data/entities/Case";
export async function muteUser(
pluginData: GuildPluginData<MutesPluginType>,
userId: string,
muteTime: number = null,
reason: string = null,
muteTime?: number,
reason?: string,
muteOptions: MuteOptions = {},
) {
const lock = await pluginData.locks.acquire(`mute-${userId}`);
@ -90,7 +91,7 @@ export async function muteUser(
}));
if (muteMessage && user instanceof User) {
let contactMethods = [];
let contactMethods: UserNotificationMethod[] = [];
if (muteOptions?.contactMethods) {
contactMethods = muteOptions.contactMethods;
@ -112,18 +113,21 @@ export async function muteUser(
// Create/update a case
const casesPlugin = pluginData.getPlugin(CasesPlugin);
let theCase: Case;
let theCase: Case | undefined =
existingMute && existingMute.case_id ? await pluginData.state.cases.find(existingMute.case_id) : undefined;
if (existingMute && existingMute.case_id) {
if (theCase) {
// Update old case
// Since mutes can often have multiple notes (extraNotes), we won't post each case note individually,
// but instead we'll post the entire case afterwards
theCase = await pluginData.state.cases.find(existingMute.case_id);
const noteDetails = [`Mute updated to ${muteTime ? timeUntilUnmute : "indefinite"}`];
const reasons = [reason, ...(muteOptions.caseArgs?.extraNotes || [])];
const reasons = reason ? [reason] : [];
if (muteOptions.caseArgs?.extraNotes) {
reasons.push(...muteOptions.caseArgs.extraNotes);
}
for (const noteReason of reasons) {
await casesPlugin.createCaseNote({
caseId: existingMute.case_id,
caseId: existingMute!.case_id,
modId: muteOptions.caseArgs?.modId,
body: noteReason,
noteDetails,
@ -132,7 +136,7 @@ export async function muteUser(
}
if (muteOptions.caseArgs?.postInCaseLogOverride !== false) {
casesPlugin.postCaseToCaseLogChannel(existingMute.case_id);
casesPlugin.postCaseToCaseLogChannel(existingMute!.case_id);
}
} else {
// Create new case