mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Merge pull request #503 from rubyowo/feat/yearsandmonths_next
feat: fix leap year rules, add year and month to the delay string
This commit is contained in:
commit
e1966534d5
50 changed files with 175 additions and 102 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { In, InsertResult, Repository } from "typeorm";
|
import { FindOptionsWhere, In, InsertResult, Repository } from "typeorm";
|
||||||
import { FindOptionsWhere } from "typeorm";
|
|
||||||
import { Queue } from "../Queue.js";
|
import { Queue } from "../Queue.js";
|
||||||
import { chunkArray } from "../utils.js";
|
import { chunkArray } from "../utils.js";
|
||||||
import { BaseGuildRepository } from "./BaseGuildRepository.js";
|
import { BaseGuildRepository } from "./BaseGuildRepository.js";
|
||||||
|
|
34
backend/src/humanizeDuration.ts
Normal file
34
backend/src/humanizeDuration.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import humanizeduration from "humanize-duration";
|
||||||
|
|
||||||
|
export const delayStringMultipliers = {
|
||||||
|
y: 1000 * 60 * 60 * 24 * (365 + 1 / 4 - 1 / 100 + 1 / 400),
|
||||||
|
mo: (1000 * 60 * 60 * 24 * (365 + 1 / 4 - 1 / 100 + 1 / 400)) / 12,
|
||||||
|
w: 1000 * 60 * 60 * 24 * 7,
|
||||||
|
d: 1000 * 60 * 60 * 24,
|
||||||
|
h: 1000 * 60 * 60,
|
||||||
|
m: 1000 * 60,
|
||||||
|
s: 1000,
|
||||||
|
x: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const humanizeDurationShort = humanizeduration.humanizer({
|
||||||
|
language: "shortEn",
|
||||||
|
languages: {
|
||||||
|
shortEn: {
|
||||||
|
y: () => "y",
|
||||||
|
mo: () => "mo",
|
||||||
|
w: () => "w",
|
||||||
|
d: () => "d",
|
||||||
|
h: () => "h",
|
||||||
|
m: () => "m",
|
||||||
|
s: () => "s",
|
||||||
|
ms: () => "ms",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
spacer: "",
|
||||||
|
unitMeasures: delayStringMultipliers,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const humanizeDuration = humanizeduration.humanizer({
|
||||||
|
unitMeasures: delayStringMultipliers,
|
||||||
|
});
|
|
@ -1,18 +0,0 @@
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
|
|
||||||
export const humanizeDurationShort = humanizeDuration.humanizer({
|
|
||||||
language: "shortEn",
|
|
||||||
languages: {
|
|
||||||
shortEn: {
|
|
||||||
y: () => "y",
|
|
||||||
mo: () => "mo",
|
|
||||||
w: () => "w",
|
|
||||||
d: () => "d",
|
|
||||||
h: () => "h",
|
|
||||||
m: () => "m",
|
|
||||||
s: () => "s",
|
|
||||||
ms: () => "ms",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
spacer: "",
|
|
||||||
});
|
|
|
@ -44,7 +44,15 @@ import { availableGlobalPlugins, availableGuildPlugins } from "./plugins/availab
|
||||||
import { setProfiler } from "./profiler.js";
|
import { setProfiler } from "./profiler.js";
|
||||||
import { logRateLimit } from "./rateLimitStats.js";
|
import { logRateLimit } from "./rateLimitStats.js";
|
||||||
import { startUptimeCounter } from "./uptime.js";
|
import { startUptimeCounter } from "./uptime.js";
|
||||||
import { MINUTES, SECONDS, errorMessage, isDiscordAPIError, isDiscordHTTPError, sleep, successMessage } from "./utils.js";
|
import {
|
||||||
|
MINUTES,
|
||||||
|
SECONDS,
|
||||||
|
errorMessage,
|
||||||
|
isDiscordAPIError,
|
||||||
|
isDiscordHTTPError,
|
||||||
|
sleep,
|
||||||
|
successMessage,
|
||||||
|
} from "./utils.js";
|
||||||
import { DecayingCounter } from "./utils/DecayingCounter.js";
|
import { DecayingCounter } from "./utils/DecayingCounter.js";
|
||||||
import { enableProfiling } from "./utils/easyProfiler.js";
|
import { enableProfiling } from "./utils/easyProfiler.js";
|
||||||
import { loadYamlSafely } from "./utils/loadYamlSafely.js";
|
import { loadYamlSafely } from "./utils/loadYamlSafely.js";
|
||||||
|
|
|
@ -2,7 +2,12 @@ import { GuildPluginData } from "knub";
|
||||||
import { convertDelayStringToMS } from "../../../utils.js";
|
import { convertDelayStringToMS } from "../../../utils.js";
|
||||||
import { AutomodContext, AutomodPluginType, TRule } from "../types.js";
|
import { AutomodContext, AutomodPluginType, TRule } from "../types.js";
|
||||||
|
|
||||||
export function applyCooldown(pluginData: GuildPluginData<AutomodPluginType>, rule: TRule, ruleName: string, context: AutomodContext) {
|
export function applyCooldown(
|
||||||
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
|
rule: TRule,
|
||||||
|
ruleName: string,
|
||||||
|
context: AutomodContext,
|
||||||
|
) {
|
||||||
const cooldownKey = `${ruleName}-${context.user?.id}`;
|
const cooldownKey = `${ruleName}-${context.user?.id}`;
|
||||||
|
|
||||||
const cooldownTime = convertDelayStringToMS(rule.cooldown, "s");
|
const cooldownTime = convertDelayStringToMS(rule.cooldown, "s");
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { AutomodContext, AutomodPluginType, TRule } from "../types.js";
|
import { AutomodContext, AutomodPluginType, TRule } from "../types.js";
|
||||||
|
|
||||||
export function checkCooldown(pluginData: GuildPluginData<AutomodPluginType>, rule: TRule, ruleName: string, context: AutomodContext) {
|
export function checkCooldown(
|
||||||
|
pluginData: GuildPluginData<AutomodPluginType>,
|
||||||
|
rule: TRule,
|
||||||
|
ruleName: string,
|
||||||
|
context: AutomodContext,
|
||||||
|
) {
|
||||||
const cooldownKey = `${ruleName}-${context.user?.id}`;
|
const cooldownKey = `${ruleName}-${context.user?.id}`;
|
||||||
|
|
||||||
return pluginData.state.cooldownManager.isOnCooldown(cooldownKey);
|
return pluginData.state.cooldownManager.isOnCooldown(cooldownKey);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
|
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
|
||||||
import { humanizeDurationShort } from "../../../humanizeDurationShort.js";
|
import { humanizeDurationShort } from "../../../humanizeDuration.js";
|
||||||
import { getBaseUrl } from "../../../pluginUtils.js";
|
import { getBaseUrl } from "../../../pluginUtils.js";
|
||||||
import { convertDelayStringToMS, sorter, zDelayString } from "../../../utils.js";
|
import { convertDelayStringToMS, sorter, zDelayString } from "../../../utils.js";
|
||||||
import { RecentActionType } from "../constants.js";
|
import { RecentActionType } from "../constants.js";
|
||||||
|
|
|
@ -13,19 +13,20 @@ const baseConfig = z.strictObject({
|
||||||
filetype_blacklist: z.array(z.string().max(32)).max(255).default([]),
|
filetype_blacklist: z.array(z.string().max(32)).max(255).default([]),
|
||||||
filetype_whitelist: z.array(z.string().max(32)).max(255).default([]),
|
filetype_whitelist: z.array(z.string().max(32)).max(255).default([]),
|
||||||
});
|
});
|
||||||
const configWithWhitelist = baseConfig.merge(z.strictObject({
|
const configWithWhitelist = baseConfig.merge(
|
||||||
|
z.strictObject({
|
||||||
whitelist_enabled: z.literal(true),
|
whitelist_enabled: z.literal(true),
|
||||||
blacklist_enabled: z.literal(false).default(false),
|
blacklist_enabled: z.literal(false).default(false),
|
||||||
}));
|
}),
|
||||||
const configWithBlacklist = baseConfig.merge(z.strictObject({
|
);
|
||||||
|
const configWithBlacklist = baseConfig.merge(
|
||||||
|
z.strictObject({
|
||||||
blacklist_enabled: z.literal(true),
|
blacklist_enabled: z.literal(true),
|
||||||
whitelist_enabled: z.literal(false).default(false),
|
whitelist_enabled: z.literal(false).default(false),
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const configSchema = z.union([
|
const configSchema = z.union([configWithWhitelist, configWithBlacklist]);
|
||||||
configWithWhitelist,
|
|
||||||
configWithBlacklist,
|
|
||||||
]);
|
|
||||||
|
|
||||||
export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
|
export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
|
||||||
configSchema,
|
configSchema,
|
||||||
|
|
|
@ -12,19 +12,20 @@ const baseConfig = z.strictObject({
|
||||||
mime_type_blacklist: z.array(z.string().max(32)).max(255).default([]),
|
mime_type_blacklist: z.array(z.string().max(32)).max(255).default([]),
|
||||||
mime_type_whitelist: z.array(z.string().max(32)).max(255).default([]),
|
mime_type_whitelist: z.array(z.string().max(32)).max(255).default([]),
|
||||||
});
|
});
|
||||||
const configWithWhitelist = baseConfig.merge(z.strictObject({
|
const configWithWhitelist = baseConfig.merge(
|
||||||
|
z.strictObject({
|
||||||
whitelist_enabled: z.literal(true),
|
whitelist_enabled: z.literal(true),
|
||||||
blacklist_enabled: z.literal(false).default(false),
|
blacklist_enabled: z.literal(false).default(false),
|
||||||
}));
|
}),
|
||||||
const configWithBlacklist = baseConfig.merge(z.strictObject({
|
);
|
||||||
|
const configWithBlacklist = baseConfig.merge(
|
||||||
|
z.strictObject({
|
||||||
blacklist_enabled: z.literal(true),
|
blacklist_enabled: z.literal(true),
|
||||||
whitelist_enabled: z.literal(false).default(false),
|
whitelist_enabled: z.literal(false).default(false),
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const configSchema = z.union([
|
const configSchema = z.union([configWithWhitelist, configWithBlacklist]);
|
||||||
configWithWhitelist,
|
|
||||||
configWithBlacklist,
|
|
||||||
]);
|
|
||||||
|
|
||||||
export const MatchMimeTypeTrigger = automodTrigger<MatchResultType>()({
|
export const MatchMimeTypeTrigger = automodTrigger<MatchResultType>()({
|
||||||
configSchema,
|
configSchema,
|
||||||
|
|
|
@ -4,7 +4,13 @@ import { GuildPluginData } from "knub";
|
||||||
import { allowTimeout } from "../../../RegExpRunner.js";
|
import { allowTimeout } from "../../../RegExpRunner.js";
|
||||||
import { ZalgoRegex } from "../../../data/Zalgo.js";
|
import { ZalgoRegex } from "../../../data/Zalgo.js";
|
||||||
import { ISavedMessageEmbedData, SavedMessage } from "../../../data/entities/SavedMessage.js";
|
import { ISavedMessageEmbedData, SavedMessage } from "../../../data/entities/SavedMessage.js";
|
||||||
import { getInviteCodesInString, getUrlsInString, isGuildInvite, resolveInvite, resolveMember } from "../../../utils.js";
|
import {
|
||||||
|
getInviteCodesInString,
|
||||||
|
getUrlsInString,
|
||||||
|
isGuildInvite,
|
||||||
|
resolveInvite,
|
||||||
|
resolveMember,
|
||||||
|
} from "../../../utils.js";
|
||||||
import { CensorPluginType } from "../types.js";
|
import { CensorPluginType } from "../types.js";
|
||||||
import { censorMessage } from "./censorMessage.js";
|
import { censorMessage } from "./censorMessage.js";
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import {
|
||||||
TextInputBuilder,
|
TextInputBuilder,
|
||||||
TextInputStyle,
|
TextInputStyle,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { logger } from "../../../logger.js";
|
import { logger } from "../../../logger.js";
|
||||||
import { canActOn } from "../../../pluginUtils.js";
|
import { canActOn } from "../../../pluginUtils.js";
|
||||||
import { convertDelayStringToMS, renderUserUsername } from "../../../utils.js";
|
import { convertDelayStringToMS, renderUserUsername } from "../../../utils.js";
|
||||||
|
|
|
@ -7,9 +7,9 @@ import {
|
||||||
TextInputBuilder,
|
TextInputBuilder,
|
||||||
TextInputStyle,
|
TextInputStyle,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError.js";
|
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { logger } from "../../../logger.js";
|
import { logger } from "../../../logger.js";
|
||||||
import { canActOn } from "../../../pluginUtils.js";
|
import { canActOn } from "../../../pluginUtils.js";
|
||||||
import { convertDelayStringToMS } from "../../../utils.js";
|
import { convertDelayStringToMS } from "../../../utils.js";
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PluginOptions, guildPlugin } from "knub";
|
||||||
import { GuildCounters } from "../../data/GuildCounters.js";
|
import { GuildCounters } from "../../data/GuildCounters.js";
|
||||||
import { CounterTrigger, parseCounterConditionString } from "../../data/entities/CounterTrigger.js";
|
import { CounterTrigger, parseCounterConditionString } from "../../data/entities/CounterTrigger.js";
|
||||||
import { makePublicFn } from "../../pluginUtils.js";
|
import { makePublicFn } from "../../pluginUtils.js";
|
||||||
import { MINUTES, convertDelayStringToMS, values } from "../../utils.js";
|
import { MINUTES, convertDelayStringToMS } from "../../utils.js";
|
||||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||||
import { AddCounterCmd } from "./commands/AddCounterCmd.js";
|
import { AddCounterCmd } from "./commands/AddCounterCmd.js";
|
||||||
import { CountersListCmd } from "./commands/CountersListCmd.js";
|
import { CountersListCmd } from "./commands/CountersListCmd.js";
|
||||||
|
|
|
@ -125,9 +125,13 @@ export const AddCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
|
||||||
`Added ${amount} to **${args.counterName}** for <@!${user.id}> in <#${channel.id}>. The value is now ${newValue}.`,
|
`Added ${amount} to **${args.counterName}** for <@!${user.id}> in <#${channel.id}>. The value is now ${newValue}.`,
|
||||||
);
|
);
|
||||||
} else if (channel) {
|
} else if (channel) {
|
||||||
message.channel.send(`Added ${amount} to **${args.counterName}** in <#${channel.id}>. The value is now ${newValue}.`);
|
message.channel.send(
|
||||||
|
`Added ${amount} to **${args.counterName}** in <#${channel.id}>. The value is now ${newValue}.`,
|
||||||
|
);
|
||||||
} else if (user) {
|
} else if (user) {
|
||||||
message.channel.send(`Added ${amount} to **${args.counterName}** for <@!${user.id}>. The value is now ${newValue}.`);
|
message.channel.send(
|
||||||
|
`Added ${amount} to **${args.counterName}** for <@!${user.id}>. The value is now ${newValue}.`,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
message.channel.send(`Added ${amount} to **${args.counterName}**. The value is now ${newValue}.`);
|
message.channel.send(`Added ${amount} to **${args.counterName}**. The value is now ${newValue}.`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||||
import { registerExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop.js";
|
import { registerExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { MINUTES, SECONDS } from "../../../utils.js";
|
import { MINUTES, SECONDS } from "../../../utils.js";
|
||||||
import { locateUserCmd } from "../types.js";
|
import { locateUserCmd } from "../types.js";
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import {
|
||||||
import { LogsThreadCreateEvt, LogsThreadDeleteEvt, LogsThreadUpdateEvt } from "./events/LogsThreadModifyEvts.js";
|
import { LogsThreadCreateEvt, LogsThreadDeleteEvt, LogsThreadUpdateEvt } from "./events/LogsThreadModifyEvts.js";
|
||||||
import { LogsGuildMemberUpdateEvt } from "./events/LogsUserUpdateEvts.js";
|
import { LogsGuildMemberUpdateEvt } from "./events/LogsUserUpdateEvts.js";
|
||||||
import { LogsVoiceStateUpdateEvt } from "./events/LogsVoiceChannelEvts.js";
|
import { LogsVoiceStateUpdateEvt } from "./events/LogsVoiceChannelEvts.js";
|
||||||
import { FORMAT_NO_TIMESTAMP, LogsPluginType, zLogsConfig } from "./types.js";
|
import { LogsPluginType, zLogsConfig } from "./types.js";
|
||||||
import { getLogMessage } from "./util/getLogMessage.js";
|
import { getLogMessage } from "./util/getLogMessage.js";
|
||||||
import { log } from "./util/log.js";
|
import { log } from "./util/log.js";
|
||||||
import { onMessageDelete } from "./util/onMessageDelete.js";
|
import { onMessageDelete } from "./util/onMessageDelete.js";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { GuildMember } from "discord.js";
|
import { GuildMember } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { LogType } from "../../../data/LogType.js";
|
import { LogType } from "../../../data/LogType.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter.js";
|
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter.js";
|
||||||
import { memberToTemplateSafeMember } from "../../../utils/templateSafeObjects.js";
|
import { memberToTemplateSafeMember } from "../../../utils/templateSafeObjects.js";
|
||||||
import { LogsPluginType } from "../types.js";
|
import { LogsPluginType } from "../types.js";
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
userToTemplateSafeUser,
|
userToTemplateSafeUser,
|
||||||
} from "../../../utils/templateSafeObjects.js";
|
} from "../../../utils/templateSafeObjects.js";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
||||||
import { FORMAT_NO_TIMESTAMP, LogsPluginType } from "../types.js";
|
import { LogsPluginType } from "../types.js";
|
||||||
import { log } from "../util/log.js";
|
import { log } from "../util/log.js";
|
||||||
|
|
||||||
export interface LogMessageDeleteData {
|
export interface LogMessageDeleteData {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { GuildCases } from "../../data/GuildCases.js";
|
||||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||||
import { LogType } from "../../data/LogType.js";
|
import { LogType } from "../../data/LogType.js";
|
||||||
import { keys, zBoundedCharacters, zMessageContent, zRegex, zSnowflake } from "../../utils.js";
|
import { zBoundedCharacters, zMessageContent, zRegex, zSnowflake } from "../../utils.js";
|
||||||
import { MessageBuffer } from "../../utils/MessageBuffer.js";
|
import { MessageBuffer } from "../../utils/MessageBuffer.js";
|
||||||
import {
|
import {
|
||||||
TemplateSafeCase,
|
TemplateSafeCase,
|
||||||
|
|
|
@ -25,7 +25,7 @@ import {
|
||||||
TemplateSafeUser,
|
TemplateSafeUser,
|
||||||
} from "../../../utils/templateSafeObjects.js";
|
} from "../../../utils/templateSafeObjects.js";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
||||||
import { FORMAT_NO_TIMESTAMP, ILogTypeData, LogsPluginType, TLogChannel } from "../types.js";
|
import { ILogTypeData, LogsPluginType, TLogChannel } from "../types.js";
|
||||||
|
|
||||||
export async function getLogMessage<TLogType extends keyof ILogTypeData>(
|
export async function getLogMessage<TLogType extends keyof ILogTypeData>(
|
||||||
pluginData: GuildPluginData<LogsPluginType>,
|
pluginData: GuildPluginData<LogsPluginType>,
|
||||||
|
|
|
@ -3,7 +3,12 @@ import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||||
import { SaveMessagesToDBCmd } from "./commands/SaveMessagesToDB.js";
|
import { SaveMessagesToDBCmd } from "./commands/SaveMessagesToDB.js";
|
||||||
import { SavePinsToDBCmd } from "./commands/SavePinsToDB.js";
|
import { SavePinsToDBCmd } from "./commands/SavePinsToDB.js";
|
||||||
import { MessageCreateEvt, MessageDeleteBulkEvt, MessageDeleteEvt, MessageUpdateEvt } from "./events/SaveMessagesEvts.js";
|
import {
|
||||||
|
MessageCreateEvt,
|
||||||
|
MessageDeleteBulkEvt,
|
||||||
|
MessageDeleteEvt,
|
||||||
|
MessageUpdateEvt,
|
||||||
|
} from "./events/SaveMessagesEvts.js";
|
||||||
import { MessageSaverPluginType, zMessageSaverConfig } from "./types.js";
|
import { MessageSaverPluginType, zMessageSaverConfig } from "./types.js";
|
||||||
|
|
||||||
const defaultOptions: PluginOptions<MessageSaverPluginType> = {
|
const defaultOptions: PluginOptions<MessageSaverPluginType> = {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { getMemberLevel } from "knub/helpers";
|
import { getMemberLevel } from "knub/helpers";
|
||||||
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
||||||
import { clearExpiringTempban, registerExpiringTempban } from "../../../../data/loops/expiringTempbansLoop.js";
|
import { clearExpiringTempban, registerExpiringTempban } from "../../../../data/loops/expiringTempbansLoop.js";
|
||||||
|
import { humanizeDuration } from "../../../../humanizeDuration.js";
|
||||||
import { canActOn, getContextChannel } from "../../../../pluginUtils.js";
|
import { canActOn, getContextChannel } from "../../../../pluginUtils.js";
|
||||||
import { UnknownUser, UserNotificationMethod, renderUsername, resolveMember } from "../../../../utils.js";
|
import { UnknownUser, UserNotificationMethod, renderUsername, resolveMember } from "../../../../utils.js";
|
||||||
import { banLock } from "../../../../utils/lockNameHelpers.js";
|
import { banLock } from "../../../../utils/lockNameHelpers.js";
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { APIEmbed, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
import { APIEmbed, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { In } from "typeorm";
|
import { FindOptionsWhere, In } from "typeorm";
|
||||||
import { FindOptionsWhere } from "typeorm";
|
|
||||||
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
||||||
import { Case } from "../../../../data/entities/Case.js";
|
import { Case } from "../../../../data/entities/Case.js";
|
||||||
import { sendContextResponse } from "../../../../pluginUtils.js";
|
import { sendContextResponse } from "../../../../pluginUtils.js";
|
||||||
|
|
|
@ -2,7 +2,14 @@ import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } f
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { LogType } from "../../../../data/LogType.js";
|
import { LogType } from "../../../../data/LogType.js";
|
||||||
import { canActOn } from "../../../../pluginUtils.js";
|
import { canActOn } from "../../../../pluginUtils.js";
|
||||||
import { DAYS, SECONDS, UnknownUser, UserNotificationMethod, renderUsername, resolveMember } from "../../../../utils.js";
|
import {
|
||||||
|
DAYS,
|
||||||
|
SECONDS,
|
||||||
|
UnknownUser,
|
||||||
|
UserNotificationMethod,
|
||||||
|
renderUsername,
|
||||||
|
resolveMember,
|
||||||
|
} from "../../../../utils.js";
|
||||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
|
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
|
||||||
import {
|
import {
|
||||||
formatReasonWithAttachments,
|
formatReasonWithAttachments,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Attachment, ChatInputCommandInteraction, GuildMember, Message, Snowflak
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../../data/CaseTypes.js";
|
||||||
import { LogType } from "../../../../data/LogType.js";
|
import { LogType } from "../../../../data/LogType.js";
|
||||||
import { humanizeDurationShort } from "../../../../humanizeDurationShort.js";
|
import { humanizeDurationShort } from "../../../../humanizeDuration.js";
|
||||||
import { canActOn, getContextChannel, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
import { canActOn, getContextChannel, isContextInteraction, sendContextResponse } from "../../../../pluginUtils.js";
|
||||||
import { DAYS, MINUTES, SECONDS, noop } from "../../../../utils.js";
|
import { DAYS, MINUTES, SECONDS, noop } from "../../../../utils.js";
|
||||||
import { CasesPlugin } from "../../../Cases/CasesPlugin.js";
|
import { CasesPlugin } from "../../../Cases/CasesPlugin.js";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { ERRORS, RecoverablePluginError } from "../../../../RecoverablePluginError.js";
|
import { ERRORS, RecoverablePluginError } from "../../../../RecoverablePluginError.js";
|
||||||
|
import { humanizeDuration } from "../../../../humanizeDuration.js";
|
||||||
import { logger } from "../../../../logger.js";
|
import { logger } from "../../../../logger.js";
|
||||||
import {
|
import {
|
||||||
UnknownUser,
|
UnknownUser,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
import { Attachment, ChatInputCommandInteraction, GuildMember, Message, User } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
|
import { humanizeDuration } from "../../../../humanizeDuration.js";
|
||||||
import { UnknownUser, asSingleLine, renderUsername } from "../../../../utils.js";
|
import { UnknownUser, asSingleLine, renderUsername } from "../../../../utils.js";
|
||||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin.js";
|
import { MutesPlugin } from "../../../Mutes/MutesPlugin.js";
|
||||||
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
|
import { handleAttachmentLinkDetectionAndGetRestriction } from "../../functions/attachmentLinkReaction.js";
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { DiscordAPIError, Snowflake } from "discord.js";
|
import { DiscordAPIError, Snowflake } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../data/CaseTypes.js";
|
||||||
import { LogType } from "../../../data/LogType.js";
|
import { LogType } from "../../../data/LogType.js";
|
||||||
import { registerExpiringTempban } from "../../../data/loops/expiringTempbansLoop.js";
|
import { registerExpiringTempban } from "../../../data/loops/expiringTempbansLoop.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { logger } from "../../../logger.js";
|
import { logger } from "../../../logger.js";
|
||||||
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js";
|
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js";
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Snowflake } from "discord.js";
|
import { Snowflake } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../data/CaseTypes.js";
|
||||||
import { LogType } from "../../../data/LogType.js";
|
import { LogType } from "../../../data/LogType.js";
|
||||||
import { Tempban } from "../../../data/entities/Tempban.js";
|
import { Tempban } from "../../../data/entities/Tempban.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { logger } from "../../../logger.js";
|
import { logger } from "../../../logger.js";
|
||||||
import { resolveUser } from "../../../utils.js";
|
import { resolveUser } from "../../../utils.js";
|
||||||
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
||||||
|
|
|
@ -3,7 +3,13 @@ import { GuildPluginData } from "knub";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../data/CaseTypes.js";
|
||||||
import { LogType } from "../../../data/LogType.js";
|
import { LogType } from "../../../data/LogType.js";
|
||||||
import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter.js";
|
import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter.js";
|
||||||
import { createUserNotificationError, notifyUser, resolveUser, ucfirst, UserNotificationResult } from "../../../utils.js";
|
import {
|
||||||
|
createUserNotificationError,
|
||||||
|
notifyUser,
|
||||||
|
resolveUser,
|
||||||
|
ucfirst,
|
||||||
|
UserNotificationResult,
|
||||||
|
} from "../../../utils.js";
|
||||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js";
|
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js";
|
||||||
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||||
|
|
|
@ -2,7 +2,13 @@ import { GuildMember, Snowflake } from "discord.js";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../data/CaseTypes.js";
|
||||||
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js";
|
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js";
|
||||||
import { UserNotificationResult, createUserNotificationError, notifyUser, resolveUser, ucfirst } from "../../../utils.js";
|
import {
|
||||||
|
UserNotificationResult,
|
||||||
|
createUserNotificationError,
|
||||||
|
notifyUser,
|
||||||
|
resolveUser,
|
||||||
|
ucfirst,
|
||||||
|
} from "../../../utils.js";
|
||||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js";
|
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects.js";
|
||||||
import { waitForButtonConfirm } from "../../../utils/waitForInteraction.js";
|
import { waitForButtonConfirm } from "../../../utils/waitForInteraction.js";
|
||||||
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||||
import { humanizeDurationShort } from "../../../humanizeDurationShort.js";
|
import { humanizeDurationShort } from "../../../humanizeDuration.js";
|
||||||
import { getBaseUrl } from "../../../pluginUtils.js";
|
import { getBaseUrl } from "../../../pluginUtils.js";
|
||||||
import { DBDateFormat, MINUTES, renderUsername, resolveMember } from "../../../utils.js";
|
import { DBDateFormat, MINUTES, renderUsername, resolveMember } from "../../../utils.js";
|
||||||
import { IMuteWithDetails, mutesCmd } from "../types.js";
|
import { IMuteWithDetails, mutesCmd } from "../types.js";
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Snowflake } from "discord.js";
|
import { Snowflake } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError.js";
|
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError.js";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../data/CaseTypes.js";
|
||||||
|
@ -8,6 +7,7 @@ import { MuteTypes } from "../../../data/MuteTypes.js";
|
||||||
import { Case } from "../../../data/entities/Case.js";
|
import { Case } from "../../../data/entities/Case.js";
|
||||||
import { Mute } from "../../../data/entities/Mute.js";
|
import { Mute } from "../../../data/entities/Mute.js";
|
||||||
import { registerExpiringMute } from "../../../data/loops/expiringMutesLoop.js";
|
import { registerExpiringMute } from "../../../data/loops/expiringMutesLoop.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin.js";
|
import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin.js";
|
||||||
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js";
|
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js";
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Snowflake } from "discord.js";
|
import { Snowflake } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes.js";
|
import { CaseTypes } from "../../../data/CaseTypes.js";
|
||||||
import { AddMuteParams } from "../../../data/GuildMutes.js";
|
import { AddMuteParams } from "../../../data/GuildMutes.js";
|
||||||
import { MuteTypes } from "../../../data/MuteTypes.js";
|
import { MuteTypes } from "../../../data/MuteTypes.js";
|
||||||
import { Mute } from "../../../data/entities/Mute.js";
|
import { Mute } from "../../../data/entities/Mute.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { noop, resolveMember, resolveUser } from "../../../utils.js";
|
import { noop, resolveMember, resolveUser } from "../../../utils.js";
|
||||||
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
import { CasesPlugin } from "../../Cases/CasesPlugin.js";
|
||||||
import { CaseArgs } from "../../Cases/types.js";
|
import { CaseArgs } from "../../Cases/types.js";
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { getPhishermanDomainInfo, phishermanDomainIsSafe, trackPhishermanCaughtDomain } from "../../../data/Phisherman.js";
|
import {
|
||||||
|
getPhishermanDomainInfo,
|
||||||
|
phishermanDomainIsSafe,
|
||||||
|
trackPhishermanCaughtDomain,
|
||||||
|
} from "../../../data/Phisherman.js";
|
||||||
import { PhishermanDomainInfo } from "../../../data/types/phisherman.js";
|
import { PhishermanDomainInfo } from "../../../data/types/phisherman.js";
|
||||||
import { PhishermanPluginType } from "../types.js";
|
import { PhishermanPluginType } from "../types.js";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { escapeCodeBlock } from "discord.js";
|
import { escapeCodeBlock } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { createChunkedMessage, DBDateFormat, deactivateMentions, sorter, trimLines } from "../../../utils.js";
|
import { createChunkedMessage, DBDateFormat, deactivateMentions, sorter, trimLines } from "../../../utils.js";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
||||||
import { postCmd } from "../types.js";
|
import { postCmd } from "../types.js";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { GuildTextBasedChannel, Message } from "discord.js";
|
import { GuildTextBasedChannel, Message } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { registerUpcomingScheduledPost } from "../../../data/loops/upcomingScheduledPostsLoop.js";
|
import { registerUpcomingScheduledPost } from "../../../data/loops/upcomingScheduledPostsLoop.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { DBDateFormat, MINUTES, StrictMessageContent, errorMessage, renderUsername } from "../../../utils.js";
|
import { DBDateFormat, MINUTES, StrictMessageContent, errorMessage, renderUsername } from "../../../utils.js";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
import { LogsPlugin } from "../../Logs/LogsPlugin.js";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||||
import { registerUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop.js";
|
import { registerUpcomingReminder } from "../../../data/loops/upcomingRemindersLoop.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { convertDelayStringToMS, messageLink } from "../../../utils.js";
|
import { convertDelayStringToMS, messageLink } from "../../../utils.js";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
||||||
import { remindersCmd } from "../types.js";
|
import { remindersCmd } from "../types.js";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { createChunkedMessage, DBDateFormat, sorter } from "../../../utils.js";
|
import { createChunkedMessage, DBDateFormat, sorter } from "../../../utils.js";
|
||||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
||||||
import { remindersCmd } from "../types.js";
|
import { remindersCmd } from "../types.js";
|
||||||
|
|
|
@ -4,7 +4,10 @@ import { TRoleButtonsConfigItem } from "../types.js";
|
||||||
import { TooManyComponentsError } from "./TooManyComponentsError.js";
|
import { TooManyComponentsError } from "./TooManyComponentsError.js";
|
||||||
import { convertButtonStyleStringToEnum } from "./convertButtonStyleStringToEnum.js";
|
import { convertButtonStyleStringToEnum } from "./convertButtonStyleStringToEnum.js";
|
||||||
|
|
||||||
export function createButtonComponents(configItem: TRoleButtonsConfigItem, configName: string): Array<ActionRowBuilder<ButtonBuilder>> {
|
export function createButtonComponents(
|
||||||
|
configItem: TRoleButtonsConfigItem,
|
||||||
|
configName: string,
|
||||||
|
): Array<ActionRowBuilder<ButtonBuilder>> {
|
||||||
const rows: Array<ActionRowBuilder<ButtonBuilder>> = [];
|
const rows: Array<ActionRowBuilder<ButtonBuilder>> = [];
|
||||||
|
|
||||||
let currentRow = new ActionRowBuilder<ButtonBuilder>();
|
let currentRow = new ActionRowBuilder<ButtonBuilder>();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { slowmodeCmd } from "../types.js";
|
import { slowmodeCmd } from "../types.js";
|
||||||
|
|
||||||
export const SlowmodeGetCmd = slowmodeCmd({
|
export const SlowmodeGetCmd = slowmodeCmd({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { GuildChannel, TextChannel } from "discord.js";
|
import { GuildChannel, TextChannel } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { createChunkedMessage } from "knub/helpers";
|
import { createChunkedMessage } from "knub/helpers";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { errorMessage } from "../../../utils.js";
|
import { errorMessage } from "../../../utils.js";
|
||||||
import { slowmodeCmd } from "../types.js";
|
import { slowmodeCmd } from "../types.js";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { escapeInlineCode, PermissionsBitField } from "discord.js";
|
import { escapeInlineCode, PermissionsBitField } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { asSingleLine, DAYS, HOURS, MINUTES } from "../../../utils.js";
|
import { asSingleLine, DAYS, HOURS, MINUTES } from "../../../utils.js";
|
||||||
import { getMissingPermissions } from "../../../utils/getMissingPermissions.js";
|
import { getMissingPermissions } from "../../../utils/getMissingPermissions.js";
|
||||||
import { missingPermissionError } from "../../../utils/missingPermissionError.js";
|
import { missingPermissionError } from "../../../utils/missingPermissionError.js";
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Snowflake } from "discord.js";
|
import { Snowflake } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { PluginOptions, guildPlugin } from "knub";
|
import { PluginOptions, guildPlugin } from "knub";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { GuildArchives } from "../../data/GuildArchives.js";
|
import { GuildArchives } from "../../data/GuildArchives.js";
|
||||||
import { GuildLogs } from "../../data/GuildLogs.js";
|
import { GuildLogs } from "../../data/GuildLogs.js";
|
||||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
|
||||||
import { GuildTags } from "../../data/GuildTags.js";
|
import { GuildTags } from "../../data/GuildTags.js";
|
||||||
|
import { humanizeDuration } from "../../humanizeDuration.js";
|
||||||
import { makePublicFn } from "../../pluginUtils.js";
|
import { makePublicFn } from "../../pluginUtils.js";
|
||||||
import { convertDelayStringToMS } from "../../utils.js";
|
import { convertDelayStringToMS } from "../../utils.js";
|
||||||
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
import { CommonPlugin } from "../Common/CommonPlugin.js";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { APIEmbed, GuildChannel } from "discord.js";
|
import { APIEmbed, GuildChannel } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import LCL from "last-commit-log";
|
import LCL from "last-commit-log";
|
||||||
import shuffle from "lodash/shuffle.js";
|
import shuffle from "lodash/shuffle.js";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { rootDir } from "../../../paths.js";
|
import { rootDir } from "../../../paths.js";
|
||||||
import { getCurrentUptime } from "../../../uptime.js";
|
import { getCurrentUptime } from "../../../uptime.js";
|
||||||
import { resolveMember, sorter } from "../../../utils.js";
|
import { resolveMember, sorter } from "../../../utils.js";
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { allowTimeout } from "../../../RegExpRunner.js";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||||
import { LogType } from "../../../data/LogType.js";
|
import { LogType } from "../../../data/LogType.js";
|
||||||
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
|
import { SavedMessage } from "../../../data/entities/SavedMessage.js";
|
||||||
import { humanizeDurationShort } from "../../../humanizeDurationShort.js";
|
import { humanizeDurationShort } from "../../../humanizeDuration.js";
|
||||||
import { getBaseUrl } from "../../../pluginUtils.js";
|
import { getBaseUrl } from "../../../pluginUtils.js";
|
||||||
import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin.js";
|
import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin.js";
|
||||||
import { DAYS, SECONDS, chunkArray, getInviteCodesInString, noop } from "../../../utils.js";
|
import { DAYS, SECONDS, chunkArray, getInviteCodesInString, noop } from "../../../utils.js";
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { LoadedGuildPlugin, PluginCommandDefinition } from "knub";
|
import { LoadedGuildPlugin, PluginCommandDefinition } from "knub";
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
import { commandTypeHelpers as ct } from "../../../commandTypes.js";
|
||||||
|
import { env } from "../../../env.js";
|
||||||
import { createChunkedMessage } from "../../../utils.js";
|
import { createChunkedMessage } from "../../../utils.js";
|
||||||
import { utilityCmd } from "../types.js";
|
import { utilityCmd } from "../types.js";
|
||||||
import { env } from "../../../env.js";
|
|
||||||
|
|
||||||
export const HelpCmd = utilityCmd({
|
export const HelpCmd = utilityCmd({
|
||||||
trigger: "help",
|
trigger: "help",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { APIEmbed, ChannelType, Snowflake, StageChannel, VoiceChannel } from "discord.js";
|
import { APIEmbed, ChannelType, Snowflake, StageChannel, VoiceChannel } from "discord.js";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
|
import { humanizeDuration } from "../../../humanizeDuration.js";
|
||||||
import { EmbedWith, MINUTES, formatNumber, preEmbedPadding, trimLines, verboseUserMention } from "../../../utils.js";
|
import { EmbedWith, MINUTES, formatNumber, preEmbedPadding, trimLines, verboseUserMention } from "../../../utils.js";
|
||||||
import { UtilityPluginType } from "../types.js";
|
import { UtilityPluginType } from "../types.js";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { parseTemplate, renderParsedTemplate, renderTemplate, TemplateSafeValueContainer } from "./templateFormatter.js";
|
import {
|
||||||
|
parseTemplate,
|
||||||
|
renderParsedTemplate,
|
||||||
|
renderTemplate,
|
||||||
|
TemplateSafeValueContainer,
|
||||||
|
} from "./templateFormatter.js";
|
||||||
|
|
||||||
test("Parses plain string templates correctly", (t) => {
|
test("Parses plain string templates correctly", (t) => {
|
||||||
const result = parseTemplate("foo bar baz");
|
const result = parseTemplate("foo bar baz");
|
||||||
|
|
|
@ -29,7 +29,6 @@ import {
|
||||||
import emojiRegex from "emoji-regex";
|
import emojiRegex from "emoji-regex";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import https from "https";
|
import https from "https";
|
||||||
import humanizeDuration from "humanize-duration";
|
|
||||||
import isEqual from "lodash/isEqual.js";
|
import isEqual from "lodash/isEqual.js";
|
||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
import tlds from "tlds" assert { type: "json" };
|
import tlds from "tlds" assert { type: "json" };
|
||||||
|
@ -37,6 +36,7 @@ import tmp from "tmp";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import { z, ZodEffects, ZodError, ZodRecord, ZodString } from "zod";
|
import { z, ZodEffects, ZodError, ZodRecord, ZodString } from "zod";
|
||||||
import { ISavedMessageAttachmentData, SavedMessage } from "./data/entities/SavedMessage.js";
|
import { ISavedMessageAttachmentData, SavedMessage } from "./data/entities/SavedMessage.js";
|
||||||
|
import { delayStringMultipliers, humanizeDuration } from "./humanizeDuration.js";
|
||||||
import { getProfiler } from "./profiler.js";
|
import { getProfiler } from "./profiler.js";
|
||||||
import { SimpleCache } from "./SimpleCache.js";
|
import { SimpleCache } from "./SimpleCache.js";
|
||||||
import { sendDM } from "./utils/sendDM.js";
|
import { sendDM } from "./utils/sendDM.js";
|
||||||
|
@ -45,21 +45,14 @@ import { waitForButtonConfirm } from "./utils/waitForInteraction.js";
|
||||||
|
|
||||||
const fsp = fs.promises;
|
const fsp = fs.promises;
|
||||||
|
|
||||||
const delayStringMultipliers = {
|
|
||||||
w: 1000 * 60 * 60 * 24 * 7,
|
|
||||||
d: 1000 * 60 * 60 * 24,
|
|
||||||
h: 1000 * 60 * 60,
|
|
||||||
m: 1000 * 60,
|
|
||||||
s: 1000,
|
|
||||||
x: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MS = 1;
|
export const MS = 1;
|
||||||
export const SECONDS = 1000 * MS;
|
export const SECONDS = 1000 * MS;
|
||||||
export const MINUTES = 60 * SECONDS;
|
export const MINUTES = 60 * SECONDS;
|
||||||
export const HOURS = 60 * MINUTES;
|
export const HOURS = 60 * MINUTES;
|
||||||
export const DAYS = 24 * HOURS;
|
export const DAYS = 24 * HOURS;
|
||||||
export const WEEKS = 7 * 24 * HOURS;
|
export const WEEKS = 7 * DAYS;
|
||||||
|
export const YEARS = (365 + 1 / 4 - 1 / 100 + 1 / 400) * DAYS;
|
||||||
|
export const MONTHS = YEARS / 12;
|
||||||
|
|
||||||
export const EMPTY_CHAR = "\u200b";
|
export const EMPTY_CHAR = "\u200b";
|
||||||
|
|
||||||
|
@ -408,7 +401,7 @@ const MAX_DELAY_STRING_AMOUNT = 100 * 365 * DAYS;
|
||||||
* Turns a "delay string" such as "1h30m" to milliseconds
|
* Turns a "delay string" such as "1h30m" to milliseconds
|
||||||
*/
|
*/
|
||||||
export function convertDelayStringToMS(str, defaultUnit = "m"): number | null {
|
export function convertDelayStringToMS(str, defaultUnit = "m"): number | null {
|
||||||
const regex = /^([0-9]+)\s*([wdhms])?[a-z]*\s*/;
|
const regex = /^([0-9]+)\s*((?:mo?)|[ywdhs])?[a-z]*\s*/;
|
||||||
let match;
|
let match;
|
||||||
let ms = 0;
|
let ms = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue