Typed log functions + more

This commit is contained in:
Dragory 2021-08-18 01:51:42 +03:00
parent d2ac700143
commit bed6589d48
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
166 changed files with 4021 additions and 869 deletions

View file

@ -37,7 +37,7 @@ import moment from "moment-timezone";
import tlds from "tlds";
import tmp from "tmp";
import { URL } from "url";
import { SavedMessage } from "./data/entities/SavedMessage";
import { ISavedMessageAttachmentData, SavedMessage } from "./data/entities/SavedMessage";
import { SimpleCache } from "./SimpleCache";
import { ChannelTypeStrings } from "./types";
import { sendDM } from "./utils/sendDM";
@ -1332,7 +1332,7 @@ export function messageSummary(msg: SavedMessage) {
if (msg.data.attachments) {
result +=
"Attachments:\n" +
msg.data.attachments.map((a: MessageAttachment) => disableLinkPreviews(a.url)).join("\n") +
msg.data.attachments.map((a: ISavedMessageAttachmentData) => disableLinkPreviews(a.url)).join("\n") +
"\n";
}
@ -1355,7 +1355,7 @@ export function verboseUserName(user: User | UnknownUser): string {
return `**${user.tag}** (\`${user.id}\`)`;
}
export function verboseChannelMention(channel: GuildChannel): string {
export function verboseChannelMention(channel: GuildChannel | ThreadChannel): string {
const plainTextName =
channel.type === ChannelTypeStrings.VOICE || channel.type === ChannelTypeStrings.STAGE
? channel.name
@ -1500,4 +1500,9 @@ export function unique<T>(arr: T[]): T[] {
return Array.from(new Set(arr));
}
// From https://github.com/microsoft/TypeScript/pull/29955#issuecomment-470062531
export function isTruthy<T>(value: T): value is Exclude<T, false | null | undefined | "" | 0> {
return Boolean(value);
}
export const DBDateFormat = "YYYY-MM-DD HH:mm:ss";