mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 11:07:19 +00:00
chore: format
This commit is contained in:
parent
6c55b98eee
commit
aaf4e02c5f
56 changed files with 282 additions and 255 deletions
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ChannelType, PermissionsBitField, Snowflake } from "discord.js";
|
||||
import { PermissionsBitField, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { LogType } from "../../../data/LogType.js";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { escapeInlineCode } from "discord.js";
|
||||
import z from "zod/v4";
|
||||
import { asSingleLine, messageSummary, verboseChannelMention } from "../../../utils.js";
|
||||
import { automodTrigger } from "../helpers.js";
|
||||
import z from "zod/v4";
|
||||
|
||||
interface MatchResultType {
|
||||
matchedType: string;
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
import { escapeCodeBlock, InteractionEditReplyOptions, InteractionReplyOptions, MessageCreateOptions, MessageEditOptions } from "discord.js";
|
||||
import {
|
||||
escapeCodeBlock,
|
||||
InteractionEditReplyOptions,
|
||||
InteractionReplyOptions,
|
||||
MessageCreateOptions,
|
||||
MessageEditOptions,
|
||||
} from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { CaseTypes } from "../../../data/CaseTypes.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, PluginOverride, guildPlugin } from "knub";
|
||||
import { PluginOverride, guildPlugin } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||
import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners.js";
|
||||
|
|
|
@ -18,7 +18,10 @@ export const zCensorConfig = z.strictObject({
|
|||
domain_blacklist: z.array(zBoundedCharacters(0, 255)).nullable().default(null),
|
||||
blocked_tokens: z.array(zBoundedCharacters(0, 2000)).nullable().default(null),
|
||||
blocked_words: z.array(zBoundedCharacters(0, 2000)).nullable().default(null),
|
||||
blocked_regex: z.array(zRegex(z.string().max(1000))).nullable().default(null),
|
||||
blocked_regex: z
|
||||
.array(zRegex(z.string().max(1000)))
|
||||
.nullable()
|
||||
.default(null),
|
||||
});
|
||||
|
||||
export interface CensorPluginType extends BasePluginType {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { BasePluginType, guildPluginMessageCommand, pluginUtils } from "knub";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
import { z } from "zod/v4";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
|
||||
export const zChannelArchiverPluginConfig = z.strictObject({});
|
||||
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
import {
|
||||
Attachment,
|
||||
MessageMentionOptions,
|
||||
SendableChannels,
|
||||
TextBasedChannel
|
||||
} from "discord.js";
|
||||
import { Attachment, MessageMentionOptions, SendableChannels, TextBasedChannel } from "discord.js";
|
||||
import { guildPlugin } from "knub";
|
||||
import { GenericCommandSource, sendContextResponse } from "../../pluginUtils.js";
|
||||
import { errorMessage, successMessage } from "../../utils.js";
|
||||
|
@ -28,9 +23,7 @@ export const CommonPlugin = guildPlugin<CommonPluginType>()({
|
|||
) => {
|
||||
const emoji = getSuccessEmoji(pluginData);
|
||||
const formattedBody = successMessage(body, emoji);
|
||||
const content = allowedMentions
|
||||
? { content: formattedBody, allowedMentions }
|
||||
: { content: formattedBody };
|
||||
const content = allowedMentions ? { content: formattedBody, allowedMentions } : { content: formattedBody };
|
||||
if ("isSendable" in context) {
|
||||
return context.send(content);
|
||||
}
|
||||
|
@ -46,9 +39,7 @@ export const CommonPlugin = guildPlugin<CommonPluginType>()({
|
|||
) => {
|
||||
const emoji = getErrorEmoji(pluginData);
|
||||
const formattedBody = errorMessage(body, emoji);
|
||||
const content = allowedMentions
|
||||
? { content: formattedBody, allowedMentions }
|
||||
: { content: formattedBody };
|
||||
const content = allowedMentions ? { content: formattedBody, allowedMentions } : { content: formattedBody };
|
||||
if ("isSendable" in context) {
|
||||
return context.send(content);
|
||||
}
|
||||
|
@ -67,9 +58,7 @@ export const CommonPlugin = guildPlugin<CommonPluginType>()({
|
|||
);
|
||||
}
|
||||
if (!channel.isSendable()) {
|
||||
throw new Error(
|
||||
"Passed attachment storage channel is not sendable",
|
||||
);
|
||||
throw new Error("Passed attachment storage channel is not sendable");
|
||||
}
|
||||
|
||||
return channel.send({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, PluginOverride, guildPlugin } from "knub";
|
||||
import { PluginOverride, guildPlugin } from "knub";
|
||||
import { GuildCases } from "../../data/GuildCases.js";
|
||||
import { CasesPlugin } from "../Cases/CasesPlugin.js";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin.js";
|
||||
|
|
|
@ -34,7 +34,7 @@ export async function cleanAction(
|
|||
.catch((err) => logger.error(`Clean interaction reply failed: ${err}`));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const targetChannel = await pluginData.guild.channels.fetch(targetChannelId);
|
||||
if (!targetChannel?.isTextBased()) {
|
||||
await interaction
|
||||
|
@ -62,7 +62,11 @@ export async function cleanAction(
|
|||
|
||||
if (fetchMessagesResult.messages.length > 0) {
|
||||
await utility.cleanMessages(targetChannel, fetchMessagesResult.messages, interaction.user);
|
||||
interaction.editReply(`Cleaned ${fetchMessagesResult.messages.length} ${fetchMessagesResult.messages.length === 1 ? "message" : "messages"}`);
|
||||
interaction.editReply(
|
||||
`Cleaned ${fetchMessagesResult.messages.length} ${
|
||||
fetchMessagesResult.messages.length === 1 ? "message" : "messages"
|
||||
}`,
|
||||
);
|
||||
} else {
|
||||
interaction.editReply("No messages to clean");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import { EventEmitter } from "events";
|
||||
import { PluginOptions, PluginOverride, guildPlugin } from "knub";
|
||||
import { PluginOverride, guildPlugin } from "knub";
|
||||
import { GuildCounters } from "../../data/GuildCounters.js";
|
||||
import { buildCounterConditionString, CounterTrigger, getReverseCounterComparisonOp, parseCounterConditionString } from "../../data/entities/CounterTrigger.js";
|
||||
import {
|
||||
CounterTrigger,
|
||||
buildCounterConditionString,
|
||||
getReverseCounterComparisonOp,
|
||||
parseCounterConditionString,
|
||||
} from "../../data/entities/CounterTrigger.js";
|
||||
import { makePublicFn } from "../../pluginUtils.js";
|
||||
import { MINUTES, convertDelayStringToMS } from "../../utils.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
|
@ -98,7 +103,9 @@ export const CountersPlugin = guildPlugin<CountersPluginType>()({
|
|||
// Initialize triggers
|
||||
for (const [triggerName, trigger] of Object.entries(counter.triggers)) {
|
||||
const parsedCondition = parseCounterConditionString(trigger.condition)!;
|
||||
const rawReverseCondition = trigger.reverse_condition || buildCounterConditionString(getReverseCounterComparisonOp(parsedCondition[0]), parsedCondition[1]);
|
||||
const rawReverseCondition =
|
||||
trigger.reverse_condition ||
|
||||
buildCounterConditionString(getReverseCounterComparisonOp(parsedCondition[0]), parsedCondition[1]);
|
||||
const parsedReverseCondition = parseCounterConditionString(rawReverseCondition)!;
|
||||
const counterTrigger = await state.counters.initCounterTrigger(
|
||||
dbCounter.id,
|
||||
|
|
|
@ -15,19 +15,18 @@ import Timeout = NodeJS.Timeout;
|
|||
const MAX_COUNTERS = 5;
|
||||
const MAX_TRIGGERS_PER_COUNTER = 5;
|
||||
|
||||
export const zTrigger = z
|
||||
.strictObject({
|
||||
// Dummy type because name gets replaced by the property key in transform()
|
||||
pretty_name: zBoundedCharacters(0, 100).nullable().default(null),
|
||||
condition: zBoundedCharacters(1, 64).refine((str) => parseCounterConditionString(str) !== null, {
|
||||
message: "Invalid counter trigger condition",
|
||||
}),
|
||||
reverse_condition: zBoundedCharacters(1, 64)
|
||||
.refine((str) => parseCounterConditionString(str) !== null, {
|
||||
message: "Invalid counter trigger reverse condition",
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
export const zTrigger = z.strictObject({
|
||||
// Dummy type because name gets replaced by the property key in transform()
|
||||
pretty_name: zBoundedCharacters(0, 100).nullable().default(null),
|
||||
condition: zBoundedCharacters(1, 64).refine((str) => parseCounterConditionString(str) !== null, {
|
||||
message: "Invalid counter trigger condition",
|
||||
}),
|
||||
reverse_condition: zBoundedCharacters(1, 64)
|
||||
.refine((str) => parseCounterConditionString(str) !== null, {
|
||||
message: "Invalid counter trigger reverse condition",
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const zTriggerFromString = zBoundedCharacters(0, 100).transform((val, ctx) => {
|
||||
const parsedCondition = parseCounterConditionString(val);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Message } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { TemplateSafeValueContainer } from "../../../templateFormatter.js";
|
||||
import { ActionError } from "../ActionError.js";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Guild } from "discord.js";
|
||||
import { BasePluginType, GlobalPluginData, globalPlugin, globalPluginEventListener } from "knub";
|
||||
import { GlobalPluginData, globalPlugin, globalPluginEventListener } from "knub";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds.js";
|
||||
import { Configs } from "../../data/Configs.js";
|
||||
import { env } from "../../env.js";
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import z from "zod/v4";
|
||||
import { guildPlugin } from "knub";
|
||||
import { Queue } from "../../Queue.js";
|
||||
import { Webhooks } from "../../data/Webhooks.js";
|
||||
import { makePublicFn } from "../../pluginUtils.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { onGuildEvent } from "../../data/GuildEvents.js";
|
||||
import { GuildVCAlerts } from "../../data/GuildVCAlerts.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
import { SaveMessagesToDBCmd } from "./commands/SaveMessagesToDB.js";
|
||||
|
|
|
@ -31,7 +31,7 @@ export const AddCaseMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const member = msg.member || await msg.guild.members.fetch(msg.author.id);
|
||||
const member = msg.member || (await msg.guild.members.fetch(msg.author.id));
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = member;
|
||||
|
|
|
@ -41,7 +41,7 @@ export const BanMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const member = msg.member || await msg.guild.members.fetch(msg.author.id);
|
||||
const member = msg.member || (await msg.guild.members.fetch(msg.author.id));
|
||||
|
||||
// The moderator who did the action is the message author or, if used, the specified -mod
|
||||
let mod = member;
|
||||
|
|
|
@ -41,7 +41,7 @@ export const CasesUserMsgCmd = modActionsMsgCmd({
|
|||
pluginData.state.common.sendErrorMessage(msg, `User not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const member = await resolveMessageMember(msg);
|
||||
|
||||
return actualCasesCmd(
|
||||
|
|
|
@ -48,12 +48,7 @@ export async function actualDeleteCaseCmd(
|
|||
content: "Delete the following case? Answer 'Yes' to continue, 'No' to cancel.",
|
||||
});
|
||||
|
||||
const reply = await helpers.waitForReply(
|
||||
pluginData.client,
|
||||
channel,
|
||||
author.id,
|
||||
15 * SECONDS,
|
||||
);
|
||||
const reply = await helpers.waitForReply(pluginData.client, channel, author.id, 15 * SECONDS);
|
||||
const normalizedReply = (reply?.content || "").toLowerCase().trim();
|
||||
if (normalizedReply !== "yes" && normalizedReply !== "y") {
|
||||
sendContextResponse(context, "Cancelled. Case was not deleted.");
|
||||
|
|
|
@ -39,7 +39,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const authorMember = await resolveMessageMember(msg)
|
||||
const authorMember = await resolveMessageMember(msg);
|
||||
const memberToMute = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||
|
||||
// Make sure we're allowed to mute this user
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { hasPermission } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { resolveUser } from "../../../../utils.js";
|
||||
import { readContactMethodsFromArgs } from "../../functions/readContactMethodsFromArgs.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualKickCmd } from "./actualKickCmd.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
|
||||
const opts = {
|
||||
mod: ct.member({ option: true }),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { getContextChannel, resolveMessageMember, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualMassBanCmd } from "./actualMassBanCmd.js";
|
||||
|
||||
|
|
|
@ -3,7 +3,14 @@ import { GuildPluginData } from "knub";
|
|||
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
||||
import { LogType } from "../../../../data/LogType.js";
|
||||
import { humanizeDurationShort } from "../../../../humanizeDuration.js";
|
||||
import { canActOn, deleteContextResponse, editContextResponse, getConfigForContext, getContextChannel, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import {
|
||||
canActOn,
|
||||
deleteContextResponse,
|
||||
editContextResponse,
|
||||
getConfigForContext,
|
||||
isContextInteraction,
|
||||
sendContextResponse,
|
||||
} from "../../../../pluginUtils.js";
|
||||
import { DAYS, MINUTES, SECONDS, noop } from "../../../../utils.js";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin.js";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin.js";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { getContextChannel, resolveMessageMember, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualMassMuteCmd } from "./actualMassMuteCmd.js";
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import { GuildPluginData } from "knub";
|
|||
import { LogType } from "../../../../data/LogType.js";
|
||||
import { logger } from "../../../../logger.js";
|
||||
import { canActOn, deleteContextResponse, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { noop } from "../../../../utils.js";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin.js";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin.js";
|
||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
|
||||
|
@ -11,7 +12,6 @@ import {
|
|||
formatReasonWithMessageLinkForAttachments,
|
||||
} from "../../functions/formatReasonForAttachments.js";
|
||||
import { ModActionsPluginType } from "../../types.js";
|
||||
import { noop } from "../../../../utils.js";
|
||||
|
||||
export async function actualMassMuteCmd(
|
||||
pluginData: GuildPluginData<ModActionsPluginType>,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { waitForReply } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../../commandTypes.js";
|
||||
import { getContextChannel, resolveMessageMember, sendContextResponse } from "../../../../pluginUtils.js";
|
||||
import { resolveMessageMember } from "../../../../pluginUtils.js";
|
||||
import { modActionsMsgCmd } from "../../types.js";
|
||||
import { actualMassUnbanCmd } from "./actualMassUnbanCmd.js";
|
||||
|
||||
|
|
|
@ -30,16 +30,28 @@ export const zModActionsConfig = z.strictObject({
|
|||
message_on_ban: z.boolean().default(false),
|
||||
message_channel: z.nullable(z.string()).default(null),
|
||||
warn_message: z.nullable(z.string()).default("You have received a warning on the {guildName} server: {reason}"),
|
||||
kick_message: z.nullable(z.string()).default("You have been kicked from the {guildName} server. Reason given: {reason}"),
|
||||
ban_message: z.nullable(z.string()).default("You have been banned from the {guildName} server. Reason given: {reason}"),
|
||||
tempban_message: z.nullable(z.string()).default("You have been banned from the {guildName} server for {banTime}. Reason given: {reason}"),
|
||||
kick_message: z
|
||||
.nullable(z.string())
|
||||
.default("You have been kicked from the {guildName} server. Reason given: {reason}"),
|
||||
ban_message: z
|
||||
.nullable(z.string())
|
||||
.default("You have been banned from the {guildName} server. Reason given: {reason}"),
|
||||
tempban_message: z
|
||||
.nullable(z.string())
|
||||
.default("You have been banned from the {guildName} server for {banTime}. Reason given: {reason}"),
|
||||
alert_on_rejoin: z.boolean().default(false),
|
||||
alert_channel: z.nullable(z.string()).default(null),
|
||||
warn_notify_enabled: z.boolean().default(false),
|
||||
warn_notify_threshold: z.number().default(5),
|
||||
warn_notify_message: z.string().default("The user already has **{priorWarnings}** warnings!\n Please check their prior cases and assess whether or not to warn anyways.\n Proceed with the warning?"),
|
||||
warn_notify_message: z
|
||||
.string()
|
||||
.default(
|
||||
"The user already has **{priorWarnings}** warnings!\n Please check their prior cases and assess whether or not to warn anyways.\n Proceed with the warning?",
|
||||
),
|
||||
ban_delete_message_days: z.number().default(1),
|
||||
attachment_link_reaction: z.nullable(z.union([z.literal("none"), z.literal("warn"), z.literal("restrict")])).default("warn"),
|
||||
attachment_link_reaction: z
|
||||
.nullable(z.union([z.literal("none"), z.literal("warn"), z.literal("restrict")]))
|
||||
.default("warn"),
|
||||
can_note: z.boolean().default(false),
|
||||
can_warn: z.boolean().default(false),
|
||||
can_mute: z.boolean().default(false),
|
||||
|
|
|
@ -23,7 +23,10 @@ export const zMutesConfig = z.strictObject({
|
|||
message_on_update: z.boolean().default(false),
|
||||
message_channel: z.string().nullable().default(null),
|
||||
mute_message: z.string().nullable().default("You have been muted on the {guildName} server. Reason given: {reason}"),
|
||||
timed_mute_message: z.string().nullable().default("You have been muted on the {guildName} server for {time}. Reason given: {reason}"),
|
||||
timed_mute_message: z
|
||||
.string()
|
||||
.nullable()
|
||||
.default("You have been muted on the {guildName} server for {time}. Reason given: {reason}"),
|
||||
update_mute_message: z.string().nullable().default("Your mute on the {guildName} server has been updated to {time}."),
|
||||
remove_roles_on_mute: z.union([z.boolean(), z.array(zSnowflake)]).default(false),
|
||||
restore_roles_on_mute: z.union([z.boolean(), z.array(zSnowflake)]).default(false),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { Queue } from "../../Queue.js";
|
||||
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory.js";
|
||||
import { UsernameHistory } from "../../data/UsernameHistory.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
import { GuildPersistedData } from "../../data/GuildPersistedData.js";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { Queue } from "../../Queue.js";
|
||||
import { GuildReactionRoles } from "../../data/GuildReactionRoles.js";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
import { canUseEmoji, isDiscordAPIError, isValidEmoji, noop, trimPluginDescription } from "../../../utils.js";
|
||||
import { canReadChannel } from "../../../utils/canReadChannel.js";
|
||||
import { TReactionRolePair, reactionRolesCmd } from "../types.js";
|
||||
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
|
||||
const CLEAR_ROLES_EMOJI = "❌";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { onGuildEvent } from "../../data/GuildEvents.js";
|
||||
import { GuildReminders } from "../../data/GuildReminders.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin.js";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CooldownManager, PluginOptions, guildPlugin } from "knub";
|
||||
import { CooldownManager, guildPlugin } from "knub";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
import { RoleAddCmd } from "./commands/RoleAddCmd.js";
|
||||
import { RoleHelpCmd } from "./commands/RoleHelpCmd.js";
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Role, Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers.js";
|
||||
import { selfGrantableRolesCmd } from "../types.js";
|
||||
import { findMatchingRoles } from "../util/findMatchingRoles.js";
|
||||
import { getApplyingEntries } from "../util/getApplyingEntries.js";
|
||||
import { normalizeRoleNames } from "../util/normalizeRoleNames.js";
|
||||
import { splitRoleNames } from "../util/splitRoleNames.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
|
||||
export const RoleAddCmd = selfGrantableRolesCmd({
|
||||
trigger: ["role", "role add"],
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers.js";
|
||||
import { selfGrantableRolesCmd } from "../types.js";
|
||||
import { findMatchingRoles } from "../util/findMatchingRoles.js";
|
||||
import { getApplyingEntries } from "../util/getApplyingEntries.js";
|
||||
import { normalizeRoleNames } from "../util/normalizeRoleNames.js";
|
||||
import { splitRoleNames } from "../util/splitRoleNames.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
|
||||
export const RoleRemoveCmd = selfGrantableRolesCmd({
|
||||
trigger: "role remove",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { MessageCreateOptions } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { logger } from "../../../logger.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
import { TemplateParseError } from "../../../templateFormatter.js";
|
||||
import { memberToTemplateSafeMember, userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js";
|
||||
import { tagsCmd } from "../types.js";
|
||||
import { renderTagBody } from "../util/renderTagBody.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
|
||||
export const TagEvalCmd = tagsCmd({
|
||||
trigger: "tag eval",
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones.js";
|
||||
import { makePublicFn } from "../../pluginUtils.js";
|
||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||
import { ResetTimezoneCmd } from "./commands/ResetTimezoneCmd.js";
|
||||
import { SetTimezoneCmd } from "./commands/SetTimezoneCmd.js";
|
||||
import { ViewTimezoneCmd } from "./commands/ViewTimezoneCmd.js";
|
||||
import { defaultDateFormats } from "./defaultDateFormats.js";
|
||||
import { getDateFormat } from "./functions/getDateFormat.js";
|
||||
import { getGuildTz } from "./functions/getGuildTz.js";
|
||||
import { getMemberTz } from "./functions/getMemberTz.js";
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Snowflake, TextChannel } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
import { messageLink } from "../../../utils.js";
|
||||
import { canReadChannel } from "../../../utils/canReadChannel.js";
|
||||
import { utilityCmd } from "../types.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
|
||||
export const ContextCmd = utilityCmd({
|
||||
trigger: "context",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import { getChannelId, getRoleId } from "knub/helpers";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
import { isValidSnowflake, noop, parseInviteCodeInput, resolveInvite, resolveUser } from "../../../utils.js";
|
||||
import { canReadChannel } from "../../../utils/canReadChannel.js";
|
||||
import { resolveMessageTarget } from "../../../utils/resolveMessageTarget.js";
|
||||
|
@ -15,7 +16,6 @@ import { getServerInfoEmbed } from "../functions/getServerInfoEmbed.js";
|
|||
import { getSnowflakeInfoEmbed } from "../functions/getSnowflakeInfoEmbed.js";
|
||||
import { getUserInfoEmbed } from "../functions/getUserInfoEmbed.js";
|
||||
import { utilityCmd } from "../types.js";
|
||||
import { resolveMessageMember } from "../../../pluginUtils.js";
|
||||
|
||||
export const InfoCmd = utilityCmd({
|
||||
trigger: "info",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { UtilityPluginType } from "../types.js";
|
||||
import { GuildBasedChannel, Snowflake, TextBasedChannel, User } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
|
||||
import { LogType } from "../../../data/LogType.js";
|
||||
import { chunkArray } from "../../../utils.js";
|
||||
import { getBaseUrl } from "../../../pluginUtils.js";
|
||||
import { chunkArray } from "../../../utils.js";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||
import { UtilityPluginType } from "../types.js";
|
||||
|
||||
export async function cleanMessages(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { GuildBasedChannel, Message, OmitPartialGroupDMChannel, Snowflake, TextBasedChannel } from "discord.js";
|
||||
import { DAYS, getInviteCodesInString } from "../../../utils.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { UtilityPluginType } from "../types.js";
|
||||
import { snowflakeToTimestamp } from "../../../utils/snowflakeToTimestamp.js";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
|
||||
import { humanizeDurationShort } from "../../../humanizeDuration.js";
|
||||
import { allowTimeout } from "../../../RegExpRunner.js";
|
||||
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
|
||||
import { DAYS, getInviteCodesInString } from "../../../utils.js";
|
||||
import { snowflakeToTimestamp } from "../../../utils/snowflakeToTimestamp.js";
|
||||
import { UtilityPluginType } from "../types.js";
|
||||
|
||||
const MAX_CLEAN_COUNT = 300;
|
||||
const MAX_CLEAN_TIME = 1 * DAYS;
|
||||
|
@ -33,7 +33,11 @@ export interface ErrorResult {
|
|||
|
||||
export type FetchChannelMessagesToCleanResult = SuccessResult | ErrorResult;
|
||||
|
||||
export async function fetchChannelMessagesToClean(pluginData: GuildPluginData<UtilityPluginType>, targetChannel: GuildBasedChannel & TextBasedChannel, opts: FetchChannelMessagesToCleanOpts): Promise<FetchChannelMessagesToCleanResult> {
|
||||
export async function fetchChannelMessagesToClean(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
targetChannel: GuildBasedChannel & TextBasedChannel,
|
||||
opts: FetchChannelMessagesToCleanOpts,
|
||||
): Promise<FetchChannelMessagesToCleanResult> {
|
||||
if (opts.count > MAX_CLEAN_COUNT || opts.count <= 0) {
|
||||
return { error: `Clean count must be between 1 and ${MAX_CLEAN_COUNT}` };
|
||||
}
|
||||
|
@ -75,7 +79,10 @@ export async function fetchChannelMessagesToClean(pluginData: GuildPluginData<Ut
|
|||
break;
|
||||
}
|
||||
if (message.createdTimestamp < timestampCutoff) continue;
|
||||
if (opts.matchContent && !(await pluginData.state.regexRunner.exec(opts.matchContent, contentString).catch(allowTimeout))) {
|
||||
if (
|
||||
opts.matchContent &&
|
||||
!(await pluginData.state.regexRunner.exec(opts.matchContent, contentString).catch(allowTimeout))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import { APIEmbed, ChannelType } from "discord.js";
|
|||
import { GuildPluginData } from "knub";
|
||||
import {
|
||||
EmbedWith,
|
||||
GroupDMInvite,
|
||||
formatNumber,
|
||||
inviteHasCounts,
|
||||
isGroupDMInvite,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { PluginOptions, guildPlugin } from "knub";
|
||||
import { guildPlugin } from "knub";
|
||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin.js";
|
||||
import { SendWelcomeMessageEvt } from "./events/SendWelcomeMessageEvt.js";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue