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

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

@ -1,11 +1,12 @@
import { MessageEmbed, Snowflake } from "discord.js";
import { BaseGuildTextChannel, MessageEmbed, Snowflake, ThreadChannel } from "discord.js";
import { GuildPluginData } from "knub";
import cloneDeep from "lodash.clonedeep";
import { channelToConfigAccessibleChannel, userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { SavedMessage } from "../../../data/entities/SavedMessage";
import { LogType } from "../../../data/LogType";
import { resolveUser } from "../../../utils";
import { LogsPluginType } from "../types";
import { logMessageEdit } from "../logFunctions/logMessageEdit";
export async function onMessageUpdate(
pluginData: GuildPluginData<LogsPluginType>,
@ -48,11 +49,13 @@ export async function onMessageUpdate(
}
const user = await resolveUser(pluginData.client, savedMessage.user_id);
const channel = pluginData.guild.channels.resolve(savedMessage.channel_id as Snowflake)!;
const channel = pluginData.guild.channels.resolve(savedMessage.channel_id as Snowflake)! as
| BaseGuildTextChannel
| ThreadChannel;
pluginData.state.guildLogs.log(LogType.MESSAGE_EDIT, {
user: userToConfigAccessibleUser(user),
channel: channelToConfigAccessibleChannel(channel),
logMessageEdit(pluginData, {
user,
channel,
before: oldSavedMessage,
after: savedMessage,
});