More fixes, change rest of stripObjectToScalars to configAccessibleObj

This commit is contained in:
Dark 2021-07-21 22:14:09 +02:00
parent 4ad99975de
commit acb4913495
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
66 changed files with 623 additions and 192 deletions
backend/src/plugins/Post/util

View file

@ -1,6 +1,7 @@
import { Snowflake, TextChannel, User } from "discord.js";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { channelToConfigAccessibleChannel, userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger";
import { DBDateFormat, SECONDS, stripObjectToScalars } from "../../../utils";
@ -30,15 +31,15 @@ export async function scheduledPostLoop(pluginData: GuildPluginData<PostPluginTy
post.enable_mentions,
);
pluginData.state.logs.log(LogType.POSTED_SCHEDULED_MESSAGE, {
author: stripObjectToScalars(author),
channel: stripObjectToScalars(channel),
author: userToConfigAccessibleUser(author),
channel: channelToConfigAccessibleChannel(channel),
messageId: postedMessage.id,
});
} catch {
pluginData.state.logs.log(LogType.BOT_ALERT, {
body: `Failed to post scheduled message by {userMention(author)} to {channelMention(channel)}`,
channel: stripObjectToScalars(channel),
author: stripObjectToScalars(author),
channel: channelToConfigAccessibleChannel(channel),
author: userToConfigAccessibleUser(author),
});
logger.warn(
`Failed to post scheduled message to #${channel.name} (${channel.id}) on ${pluginData.guild.name} (${pluginData.guild.id})`,