3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00
zeppelin/backend/src/plugins/Logs/logFunctions/logScheduledMessage.ts

35 lines
1.2 KiB
TypeScript

import { GuildPluginData } from "knub";
import { LogsPluginType } from "../types";
import { LogType } from "../../../data/LogType";
import { log } from "../util/log";
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { BaseGuildTextChannel, GuildTextBasedChannel, ThreadChannel, User } from "discord.js";
import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { resolveChannelIds } from "../../../utils/resolveChannelIds";
interface LogScheduledMessageData {
author: User;
channel: GuildTextBasedChannel;
datetime: string;
date: string;
time: string;
}
export function logScheduledMessage(pluginData: GuildPluginData<LogsPluginType>, data: LogScheduledMessageData) {
return log(
pluginData,
LogType.SCHEDULED_MESSAGE,
createTypedTemplateSafeValueContainer({
author: userToTemplateSafeUser(data.author),
channel: channelToTemplateSafeChannel(data.channel),
datetime: data.datetime,
date: data.date,
time: data.time,
}),
{
userId: data.author.id,
bot: data.author.bot,
...resolveChannelIds(data.channel),
},
);
}