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

@ -28,11 +28,11 @@ export const LogsGuildMemberAddEvt = logsEvt({
cases.sort((a, b) => (a.created_at > b.created_at ? -1 : 1));
if (cases.length) {
const recentCaseLines = [];
const recentCaseLines: string[] = [];
const recentCases = cases.slice(0, 2);
const casesPlugin = pluginData.getPlugin(CasesPlugin);
for (const theCase of recentCases) {
recentCaseLines.push(await casesPlugin.getCaseSummary(theCase));
recentCaseLines.push((await casesPlugin.getCaseSummary(theCase))!);
}
let recentCaseSummary = recentCaseLines.join("\n");

View file

@ -14,16 +14,17 @@ import { renderTemplate, TemplateParseError } from "../../../templateFormatter";
import { logger } from "../../../logger";
import moment from "moment-timezone";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { MessageContent } from "eris";
export async function getLogMessage(
pluginData: GuildPluginData<LogsPluginType>,
type: LogType,
data: any,
opts?: Pick<TLogChannel, "format" | "timestamp_format" | "include_embed_timestamp">,
): Promise<string> {
): Promise<MessageContent | null> {
const config = pluginData.config.get();
const format = opts?.format?.[LogType[type]] || config.format[LogType[type]] || "";
if (format === "" || format == null) return;
if (format === "" || format == null) return null;
// See comment on FORMAT_NO_TIMESTAMP in types.ts
const timestampFormat =
@ -45,7 +46,7 @@ export async function getLogMessage(
const usersOrMembers = Array.isArray(inputUserOrMember) ? inputUserOrMember : [inputUserOrMember];
const mentions = [];
const mentions: string[] = [];
for (const userOrMember of usersOrMembers) {
let user;
let member;
@ -91,7 +92,7 @@ export async function getLogMessage(
} catch (e) {
if (e instanceof TemplateParseError) {
logger.error(`Error when parsing template:\nError: ${e.message}\nTemplate: ${format}`);
return;
return null;
} else {
throw e;
}

View file

@ -109,13 +109,13 @@ export async function log(pluginData: GuildPluginData<LogsPluginType>, type: Log
if (!pluginData.state.batches.has(channel.id)) {
pluginData.state.batches.set(channel.id, []);
setTimeout(async () => {
const batchedMessage = pluginData.state.batches.get(channel.id).join("\n");
const batchedMessage = pluginData.state.batches.get(channel.id)!.join("\n");
pluginData.state.batches.delete(channel.id);
createChunkedMessage(channel, batchedMessage).catch(noop);
}, batchTime);
}
pluginData.state.batches.get(channel.id).push(message);
pluginData.state.batches.get(channel.id)!.push(message);
} else {
// If we're not batching log messages, just send them immediately
await createChunkedMessage(channel, message).catch(noop);