3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 04:45:02 +00:00

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

View file

@ -2,6 +2,7 @@ import { Channel, Message, TextChannel } from "discord.js";
import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { channelToConfigAccessibleChannel, userToConfigAccessibleUser } from "src/utils/configAccessibleObjects";
import { LogType } from "../../../data/LogType";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { DBDateFormat, errorMessage, MINUTES, StrictMessageContent, stripObjectToScalars } from "../../../utils";
@ -158,8 +159,8 @@ export async function actualPostCmd(
if (opts.repeat) {
pluginData.state.logs.log(LogType.SCHEDULED_REPEATED_MESSAGE, {
author: stripObjectToScalars(msg.author),
channel: stripObjectToScalars(targetChannel),
author: userToConfigAccessibleUser(msg.author),
channel: channelToConfigAccessibleChannel(targetChannel),
datetime: postAt.format(timeAndDate.getDateFormat("pretty_datetime")),
date: postAt.format(timeAndDate.getDateFormat("date")),
time: postAt.format(timeAndDate.getDateFormat("time")),
@ -168,8 +169,8 @@ export async function actualPostCmd(
});
} else {
pluginData.state.logs.log(LogType.SCHEDULED_MESSAGE, {
author: stripObjectToScalars(msg.author),
channel: stripObjectToScalars(targetChannel),
author: userToConfigAccessibleUser(msg.author),
channel: channelToConfigAccessibleChannel(targetChannel),
datetime: postAt.format(timeAndDate.getDateFormat("pretty_datetime")),
date: postAt.format(timeAndDate.getDateFormat("date")),
time: postAt.format(timeAndDate.getDateFormat("time")),
@ -184,8 +185,8 @@ export async function actualPostCmd(
if (opts.repeat) {
pluginData.state.logs.log(LogType.REPEATED_MESSAGE, {
author: stripObjectToScalars(msg.author),
channel: stripObjectToScalars(targetChannel),
author: userToConfigAccessibleUser(msg.author),
channel: channelToConfigAccessibleChannel(targetChannel),
datetime: postAt.format(timeAndDate.getDateFormat("pretty_datetime")),
date: postAt.format(timeAndDate.getDateFormat("date")),
time: postAt.format(timeAndDate.getDateFormat("time")),

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})`,