Typed log functions + more
This commit is contained in:
parent
d2ac700143
commit
bed6589d48
166 changed files with 4021 additions and 869 deletions
|
@ -1,6 +1,6 @@
|
|||
import { MessageOptions, Permissions, Snowflake, TextChannel, User } from "discord.js";
|
||||
import * as t from "io-ts";
|
||||
import { userToConfigAccessibleUser } from "../../../utils/configAccessibleObjects";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { renderTemplate } from "../../../templateFormatter";
|
||||
import {
|
||||
|
@ -16,6 +16,7 @@ import {
|
|||
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
|
||||
import { automodAction } from "../helpers";
|
||||
import { AutomodContext } from "../types";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
|
||||
export const ReplyAction = automodAction({
|
||||
configType: t.union([
|
||||
|
@ -48,7 +49,7 @@ export const ReplyAction = automodAction({
|
|||
|
||||
const renderReplyText = async str =>
|
||||
renderTemplate(str, {
|
||||
user: userToConfigAccessibleUser(user),
|
||||
user: userToTemplateSafeUser(user),
|
||||
});
|
||||
const formatted =
|
||||
typeof actionConfig === "string"
|
||||
|
@ -65,7 +66,7 @@ export const ReplyAction = automodAction({
|
|||
Permissions.FLAGS.SEND_MESSAGES | Permissions.FLAGS.VIEW_CHANNEL,
|
||||
)
|
||||
) {
|
||||
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Missing permissions to reply in ${verboseChannelMention(channel)} in Automod rule \`${ruleName}\``,
|
||||
});
|
||||
continue;
|
||||
|
@ -76,7 +77,7 @@ export const ReplyAction = automodAction({
|
|||
typeof formatted !== "string" &&
|
||||
!hasDiscordPermissions(channel.permissionsFor(pluginData.client.user!.id), Permissions.FLAGS.EMBED_LINKS)
|
||||
) {
|
||||
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Missing permissions to reply **with an embed** in ${verboseChannelMention(
|
||||
channel,
|
||||
)} in Automod rule \`${ruleName}\``,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue