the funny

This commit is contained in:
Lara 2024-11-02 14:55:29 +02:00
parent 5a555b7bb0
commit 09a573a2d3
Signed by: laratheprotogen
GPG key ID: 5C0296EB3165F98B
118 changed files with 15738 additions and 24427 deletions

View file

@ -1,6 +1,7 @@
FROM node:20 FROM node:20
RUN mkdir /zeppelin RUN mkdir /zeppelin
RUN corepack enable
RUN chown node:node /zeppelin RUN chown node:node /zeppelin
USER node USER node
@ -8,7 +9,8 @@ USER node
ARG API_URL ARG API_URL
# Install dependencies before copying over any other files # Install dependencies before copying over any other files
COPY --chown=node:node package.json package-lock.json /zeppelin RUN corepack prepare --activate pnpm@latest
COPY --chown=node:node package.json pnpm-lock.yaml pnpm-workspace.yaml /zeppelin
RUN mkdir /zeppelin/backend RUN mkdir /zeppelin/backend
COPY --chown=node:node backend/package.json /zeppelin/backend COPY --chown=node:node backend/package.json /zeppelin/backend
RUN mkdir /zeppelin/shared RUN mkdir /zeppelin/shared
@ -17,18 +19,18 @@ RUN mkdir /zeppelin/dashboard
COPY --chown=node:node dashboard/package.json /zeppelin/dashboard COPY --chown=node:node dashboard/package.json /zeppelin/dashboard
WORKDIR /zeppelin WORKDIR /zeppelin
RUN npm ci RUN pnpm i
COPY --chown=node:node . /zeppelin COPY --chown=node:node . /zeppelin
# Build backend # Build backend
WORKDIR /zeppelin/backend WORKDIR /zeppelin/backend
RUN npm run build RUN pnpm run build
# Build dashboard # Build dashboard
WORKDIR /zeppelin/dashboard WORKDIR /zeppelin/dashboard
RUN npm run build RUN pnpm run build
# Prune dev dependencies # Prune dev dependencies
WORKDIR /zeppelin WORKDIR /zeppelin
RUN npm prune --omit=dev RUN pnpm prune --prod

View file

@ -32,12 +32,13 @@
}, },
"dependencies": { "dependencies": {
"@silvia-odwyer/photon-node": "^0.3.1", "@silvia-odwyer/photon-node": "^0.3.1",
"@zeppelinbot/shared": "workspace:*",
"bufferutil": "^4.0.3", "bufferutil": "^4.0.3",
"clinic": "^13.0.0", "clinic": "^13.0.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"deep-diff": "^1.0.2", "deep-diff": "^1.0.2",
"discord.js": "^14.14.1", "discord.js": "^14.16.3",
"dotenv": "^4.0.0", "dotenv": "^4.0.0",
"emoji-regex": "^8.0.0", "emoji-regex": "^8.0.0",
"escape-string-regexp": "^1.0.5", "escape-string-regexp": "^1.0.5",
@ -48,12 +49,14 @@
"knub": "^32.0.0-next.21", "knub": "^32.0.0-next.21",
"knub-command-manager": "^9.1.0", "knub-command-manager": "^9.1.0",
"last-commit-log": "^2.1.0", "last-commit-log": "^2.1.0",
"lodash": "^4.17.21",
"lodash.chunk": "^4.2.0", "lodash.chunk": "^4.2.0",
"lodash.clonedeep": "^4.5.0", "lodash.clonedeep": "^4.5.0",
"lodash.difference": "^4.5.0", "lodash.difference": "^4.5.0",
"lodash.intersection": "^4.4.0", "lodash.intersection": "^4.4.0",
"lodash.isequal": "^4.5.0", "lodash.isequal": "^4.5.0",
"lodash.pick": "^4.4.0", "lodash.pick": "^4.4.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.21", "moment-timezone": "^0.5.21",
"multer": "^1.4.5-lts.1", "multer": "^1.4.5-lts.1",
"mysql2": "^3.9.3", "mysql2": "^3.9.3",
@ -76,7 +79,7 @@
"utf-8-validate": "^5.0.5", "utf-8-validate": "^5.0.5",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"yawn-yaml": "github:dragory/yawn-yaml#string-number-fix-build", "yawn-yaml": "github:dragory/yawn-yaml#string-number-fix-build",
"zlib-sync": "^0.1.7", "zlib-sync": "^0.1.9",
"zod": "^3.7.2" "zod": "^3.7.2"
}, },
"devDependencies": { "devDependencies": {
@ -84,6 +87,7 @@
"@types/express": "^4.16.1", "@types/express": "^4.16.1",
"@types/jest": "^24.0.15", "@types/jest": "^24.0.15",
"@types/js-yaml": "^3.12.1", "@types/js-yaml": "^3.12.1",
"@types/lodash": "^4.17.13",
"@types/lodash.at": "^4.6.3", "@types/lodash.at": "^4.6.3",
"@types/moment-timezone": "^0.5.6", "@types/moment-timezone": "^0.5.6",
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",

View file

@ -47,7 +47,7 @@ export class SimpleCache<T = any> {
if (this.maxItems && this.store.size > this.maxItems) { if (this.maxItems && this.store.size > this.maxItems) {
const keyToDelete = this.store.keys().next().value; const keyToDelete = this.store.keys().next().value;
this.store.delete(keyToDelete); this.store.delete(keyToDelete!);
} }
} }

View file

@ -3,7 +3,7 @@ import { Repository } from "typeorm";
import { DBDateFormat } from "../utils"; import { DBDateFormat } from "../utils";
import { BaseRepository } from "./BaseRepository"; import { BaseRepository } from "./BaseRepository";
import { dataSource } from "./dataSource"; import { dataSource } from "./dataSource";
import { ApiUserInfoData, ApiUserInfo as ApiUserInfoEntity } from "./entities/ApiUserInfo"; import { ApiUserInfo as ApiUserInfoEntity, ApiUserInfoData } from "./entities/ApiUserInfo";
export class ApiUserInfo extends BaseRepository { export class ApiUserInfo extends BaseRepository {
private apiUserInfo: Repository<ApiUserInfoEntity>; private apiUserInfo: Repository<ApiUserInfoEntity>;

View file

@ -1,7 +1,7 @@
import { Guild, Snowflake } from "discord.js"; import { Guild, Snowflake } from "discord.js";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { Repository } from "typeorm"; import { Repository } from "typeorm";
import { TemplateSafeValueContainer, renderTemplate } from "../templateFormatter"; import { renderTemplate, TemplateSafeValueContainer } from "../templateFormatter";
import { renderUsername, trimLines } from "../utils"; import { renderUsername, trimLines } from "../utils";
import { decrypt, encrypt } from "../utils/crypt"; import { decrypt, encrypt } from "../utils/crypt";
import { isDefaultSticker } from "../utils/isDefaultSticker"; import { isDefaultSticker } from "../utils/isDefaultSticker";

View file

@ -5,7 +5,7 @@ import { DAYS, DBDateFormat, HOURS, MINUTES } from "../utils";
import { BaseGuildRepository } from "./BaseGuildRepository"; import { BaseGuildRepository } from "./BaseGuildRepository";
import { dataSource } from "./dataSource"; import { dataSource } from "./dataSource";
import { Counter } from "./entities/Counter"; import { Counter } from "./entities/Counter";
import { CounterTrigger, TriggerComparisonOp, isValidCounterComparisonOp } from "./entities/CounterTrigger"; import { CounterTrigger, isValidCounterComparisonOp, TriggerComparisonOp } from "./entities/CounterTrigger";
import { CounterTriggerState } from "./entities/CounterTriggerState"; import { CounterTriggerState } from "./entities/CounterTriggerState";
import { CounterValue } from "./entities/CounterValue"; import { CounterValue } from "./entities/CounterValue";

View file

@ -44,7 +44,7 @@ import { baseGuildPlugins, globalPlugins, guildPlugins } from "./plugins/availab
import { setProfiler } from "./profiler"; import { setProfiler } from "./profiler";
import { logRateLimit } from "./rateLimitStats"; import { logRateLimit } from "./rateLimitStats";
import { startUptimeCounter } from "./uptime"; import { startUptimeCounter } from "./uptime";
import { MINUTES, SECONDS, errorMessage, isDiscordAPIError, isDiscordHTTPError, sleep, successMessage } from "./utils"; import { errorMessage, isDiscordAPIError, isDiscordHTTPError, MINUTES, SECONDS, sleep, successMessage } from "./utils";
import { DecayingCounter } from "./utils/DecayingCounter"; import { DecayingCounter } from "./utils/DecayingCounter";
import { enableProfiling } from "./utils/easyProfiler"; import { enableProfiling } from "./utils/easyProfiler";
import { loadYamlSafely } from "./utils/loadYamlSafely"; import { loadYamlSafely } from "./utils/loadYamlSafely";

View file

@ -3,12 +3,14 @@
*/ */
import { import {
DMChannel,
GuildMember, GuildMember,
Message, Message,
MessageCreateOptions, MessageCreateOptions,
MessageMentionOptions, MessageMentionOptions,
PermissionsBitField, PermissionsBitField,
TextBasedChannel, TextBasedChannel,
TextChannel,
} from "discord.js"; } from "discord.js";
import { AnyPluginData, BasePluginData, CommandContext, ExtendedMatchParams, GuildPluginData, helpers } from "knub"; import { AnyPluginData, BasePluginData, CommandContext, ExtendedMatchParams, GuildPluginData, helpers } from "knub";
import { logger } from "./logger"; import { logger } from "./logger";
@ -61,7 +63,7 @@ export async function sendSuccessMessage(
? { content: formattedBody, allowedMentions } ? { content: formattedBody, allowedMentions }
: { content: formattedBody }; : { content: formattedBody };
return channel return ((channel as TextChannel) || DMChannel)
.send({ ...content }) // Force line break .send({ ...content }) // Force line break
.catch((err) => { .catch((err) => {
const channelInfo = "guild" in channel ? `${channel.id} (${channel.guild.id})` : channel.id; const channelInfo = "guild" in channel ? `${channel.id} (${channel.guild.id})` : channel.id;
@ -82,7 +84,7 @@ export async function sendErrorMessage(
? { content: formattedBody, allowedMentions } ? { content: formattedBody, allowedMentions }
: { content: formattedBody }; : { content: formattedBody };
return channel return ((channel as TextChannel) || DMChannel)
.send({ ...content }) // Force line break .send({ ...content }) // Force line break
.catch((err) => { .catch((err) => {
const channelInfo = "guild" in channel ? `${channel.id} (${channel.guild.id})` : channel.id; const channelInfo = "guild" in channel ? `${channel.id} (${channel.guild.id})` : channel.id;

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { LogsPlugin } from "../Logs/LogsPlugin"; import { LogsPlugin } from "../Logs/LogsPlugin";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildAutoReactions } from "../../data/GuildAutoReactions"; import { GuildAutoReactions } from "../../data/GuildAutoReactions";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { LogsPlugin } from "../Logs/LogsPlugin"; import { LogsPlugin } from "../Logs/LogsPlugin";

View file

@ -1,7 +1,7 @@
import { PermissionsBitField, PermissionsString } from "discord.js"; import { PermissionsBitField, PermissionsString } from "discord.js";
import { U } from "ts-toolbelt"; import { U } from "ts-toolbelt";
import z from "zod"; import z from "zod";
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter";
import { isValidSnowflake, keys, noop, zBoundedCharacters } from "../../../utils"; import { isValidSnowflake, keys, noop, zBoundedCharacters } from "../../../utils";
import { import {
guildToTemplateSafeGuild, guildToTemplateSafeGuild,

View file

@ -1,6 +1,6 @@
import { GuildTextBasedChannel, MessageCreateOptions, PermissionsBitField, Snowflake, User } from "discord.js"; import { GuildTextBasedChannel, MessageCreateOptions, PermissionsBitField, Snowflake, User } from "discord.js";
import z from "zod"; import z from "zod";
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter";
import { import {
convertDelayStringToMS, convertDelayStringToMS,
noop, noop,

View file

@ -1,7 +1,7 @@
import { ChannelType, GuildTextThreadCreateOptions, ThreadAutoArchiveDuration, ThreadChannel } from "discord.js"; import { ChannelType, GuildTextThreadCreateOptions, ThreadAutoArchiveDuration, ThreadChannel } from "discord.js";
import z from "zod"; import z from "zod";
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter";
import { MINUTES, convertDelayStringToMS, noop, zBoundedCharacters, zDelayString } from "../../../utils"; import { convertDelayStringToMS, MINUTES, noop, zBoundedCharacters, zDelayString } from "../../../utils";
import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { savedMessageToTemplateSafeSavedMessage, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { automodAction } from "../helpers"; import { automodAction } from "../helpers";

View file

@ -1,7 +1,7 @@
import { Snowflake } from "discord.js"; import { Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError"; import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { UserNotificationMethod, disableUserNotificationStrings } from "../../../utils"; import { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils";
import { AutomodPluginType } from "../types"; import { AutomodPluginType } from "../types";
export function resolveActionContactMethods( export function resolveActionContactMethods(

View file

@ -51,10 +51,10 @@ export const MatchInvitesTrigger = automodTrigger<MatchResultType>()({
const invite = await resolveInvite(pluginData.client, code); const invite = await resolveInvite(pluginData.client, code);
if (!invite || !isGuildInvite(invite)) return { extra: { type, code } }; if (!invite || !isGuildInvite(invite)) return { extra: { type, code } };
if (trigger.include_guilds && trigger.include_guilds.includes(invite.guild.id)) { if (trigger.include_guilds && trigger.include_guilds.includes(await zSnowflake.parseAsync(invite.guild.id))) {
return { extra: { type, code, invite } }; return { extra: { type, code, invite } };
} }
if (trigger.exclude_guilds && !trigger.exclude_guilds.includes(invite.guild.id)) { if (trigger.exclude_guilds && !trigger.exclude_guilds.includes(await zSnowflake.parseAsync(invite.guild.id))) {
return { extra: { type, code, invite } }; return { extra: { type, code, invite } };
} }
} }

View file

@ -1,4 +1,4 @@
import { User, escapeBold, type Snowflake } from "discord.js"; import { escapeBold, type Snowflake, User } from "discord.js";
import z from "zod"; import z from "zod";
import { renderUsername } from "../../../utils"; import { renderUsername } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";

View file

@ -1,4 +1,4 @@
import { User, escapeBold, type Snowflake } from "discord.js"; import { escapeBold, type Snowflake, User } from "discord.js";
import z from "zod"; import z from "zod";
import { renderUsername } from "../../../utils.js"; import { renderUsername } from "../../../utils.js";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";

View file

@ -1,4 +1,4 @@
import { User, escapeBold, type Snowflake } from "discord.js"; import { escapeBold, type Snowflake, User } from "discord.js";
import z from "zod"; import z from "zod";
import { renderUsername } from "../../../utils.js"; import { renderUsername } from "../../../utils.js";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";

View file

@ -1,4 +1,4 @@
import { User, escapeBold, type Snowflake } from "discord.js"; import { escapeBold, type Snowflake, User } from "discord.js";
import z from "zod"; import z from "zod";
import { renderUsername } from "../../../utils"; import { renderUsername } from "../../../utils";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";

View file

@ -10,12 +10,11 @@ import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { SavedMessage } from "../../data/entities/SavedMessage"; import { SavedMessage } from "../../data/entities/SavedMessage";
import { entries, zBoundedRecord, zDelayString } from "../../utils"; import { entries, zBoundedRecord, zDelayString } from "../../utils";
import { CounterEvents } from "../Counters/types"; import { CounterEvents } from "../Counters/types";
import { ModActionType, ModActionsEvents } from "../ModActions/types"; import { ModActionsEvents, ModActionType } from "../ModActions/types";
import { MutesEvents } from "../Mutes/types"; import { MutesEvents } from "../Mutes/types";
import { availableActions } from "./actions/availableActions"; import { availableActions } from "./actions/availableActions";
import { RecentActionType } from "./constants"; import { RecentActionType } from "./constants";
import { availableTriggers } from "./triggers/availableTriggers"; import { availableTriggers } from "./triggers/availableTriggers";
import Timeout = NodeJS.Timeout; import Timeout = NodeJS.Timeout;
export type ZTriggersMapHelper = { export type ZTriggersMapHelper = {

View file

@ -1,6 +1,7 @@
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { isStaffPreFilter, sendErrorMessage } from "../../../pluginUtils"; import { isStaffPreFilter, sendErrorMessage } from "../../../pluginUtils";
import { botControlCmd } from "../types"; import { botControlCmd } from "../types";
import { TextBasedChannelFields } from "discord.js";
export const ChannelToServerCmd = botControlCmd({ export const ChannelToServerCmd = botControlCmd({
trigger: ["channel_to_server", "channel2server"], trigger: ["channel_to_server", "channel2server"],
@ -16,7 +17,7 @@ export const ChannelToServerCmd = botControlCmd({
async run({ pluginData, message: msg, args }) { async run({ pluginData, message: msg, args }) {
const channel = pluginData.client.channels.cache.get(args.channelId); const channel = pluginData.client.channels.cache.get(args.channelId);
if (!channel) { if (!channel) {
sendErrorMessage(pluginData, msg.channel, "Channel not found in cache!"); await sendErrorMessage(pluginData, msg.channel, "Channel not found in cache!");
return; return;
} }
@ -25,6 +26,8 @@ export const ChannelToServerCmd = botControlCmd({
const guild = "guild" in channel ? channel.guild : null; const guild = "guild" in channel ? channel.guild : null;
const guildInfo = guild ? `${guild.name} (\`${guild.id}\`)` : "Not a server"; const guildInfo = guild ? `${guild.name} (\`${guild.id}\`)` : "Not a server";
msg.channel.send(`**Channel:** ${channelName} (\`${channel.type}\`) (<#${channel.id}>)\n**Server:** ${guildInfo}`); await (msg.channel as TextBasedChannelFields).send(
`**Channel:** ${channelName} (\`${channel.type}\`) (<#${channel.id}>)\n**Server:** ${guildInfo}`,
);
}, },
}); });

View file

@ -4,6 +4,7 @@ import { GuildArchives } from "../../../data/GuildArchives";
import { getBaseUrl } from "../../../pluginUtils"; import { getBaseUrl } from "../../../pluginUtils";
import { sorter } from "../../../utils"; import { sorter } from "../../../utils";
import { botControlCmd } from "../types"; import { botControlCmd } from "../types";
import { TextBasedChannelFields } from "discord.js";
const sortProps = { const sortProps = {
totalTime: "TOTAL TIME", totalTime: "TOTAL TIME",
@ -51,6 +52,6 @@ export const ProfilerDataCmd = botControlCmd({
const archiveId = await archives.create(formatted, moment().add(1, "hour")); const archiveId = await archives.create(formatted, moment().add(1, "hour"));
const archiveUrl = archives.getUrl(getBaseUrl(pluginData), archiveId); const archiveUrl = archives.getUrl(getBaseUrl(pluginData), archiveId);
msg.channel.send(`Link: ${archiveUrl}`); await (msg.channel as TextBasedChannelFields).send(`Link: ${archiveUrl}`);
}, },
}); });

View file

@ -3,6 +3,7 @@ import { GuildArchives } from "../../../data/GuildArchives";
import { getBaseUrl, sendSuccessMessage } from "../../../pluginUtils"; import { getBaseUrl, sendSuccessMessage } from "../../../pluginUtils";
import { getRateLimitStats } from "../../../rateLimitStats"; import { getRateLimitStats } from "../../../rateLimitStats";
import { botControlCmd } from "../types"; import { botControlCmd } from "../types";
import { TextBasedChannelFields } from "discord.js";
export const RateLimitPerformanceCmd = botControlCmd({ export const RateLimitPerformanceCmd = botControlCmd({
trigger: ["rate_limit_performance"], trigger: ["rate_limit_performance"],
@ -34,6 +35,6 @@ export const RateLimitPerformanceCmd = botControlCmd({
const archives = GuildArchives.getGuildInstance("0"); const archives = GuildArchives.getGuildInstance("0");
const archiveId = await archives.create(fullText, moment().add(1, "hour")); const archiveId = await archives.create(fullText, moment().add(1, "hour"));
const archiveUrl = archives.getUrl(getBaseUrl(pluginData), archiveId); const archiveUrl = archives.getUrl(getBaseUrl(pluginData), archiveId);
msg.channel.send(`Link: ${archiveUrl}`); await (msg.channel as TextBasedChannelFields).send(`Link: ${archiveUrl}`);
}, },
}); });

View file

@ -1,6 +1,7 @@
import { isStaffPreFilter, sendErrorMessage } from "../../../pluginUtils"; import { isStaffPreFilter, sendErrorMessage } from "../../../pluginUtils";
import { getActiveReload, setActiveReload } from "../activeReload"; import { getActiveReload, setActiveReload } from "../activeReload";
import { botControlCmd } from "../types"; import { botControlCmd } from "../types";
import { TextBasedChannelFields } from "discord.js";
export const ReloadGlobalPluginsCmd = botControlCmd({ export const ReloadGlobalPluginsCmd = botControlCmd({
trigger: "bot_reload_global_plugins", trigger: "bot_reload_global_plugins",
@ -14,13 +15,13 @@ export const ReloadGlobalPluginsCmd = botControlCmd({
const guildId = "guild" in message.channel ? message.channel.guild.id : null; const guildId = "guild" in message.channel ? message.channel.guild.id : null;
if (!guildId) { if (!guildId) {
sendErrorMessage(pluginData, message.channel, "This command can only be used in a server"); await sendErrorMessage(pluginData, message.channel, "This command can only be used in a server");
return; return;
} }
setActiveReload(guildId, message.channel.id); setActiveReload(guildId, message.channel.id);
await message.channel.send("Reloading global plugins..."); await (message.channel as TextBasedChannelFields).send("Reloading global plugins...");
pluginData.getKnubInstance().reloadGlobalContext(); await pluginData.getKnubInstance().reloadGlobalContext();
}, },
}); });

View file

@ -2,6 +2,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { getTopRestCallStats } from "../../../restCallStats"; import { getTopRestCallStats } from "../../../restCallStats";
import { createChunkedMessage } from "../../../utils"; import { createChunkedMessage } from "../../../utils";
import { botControlCmd } from "../types"; import { botControlCmd } from "../types";
import { TextChannel } from "discord.js";
const leadingPathRegex = /(?<=\().+\/backend\//g; const leadingPathRegex = /(?<=\().+\/backend\//g;
@ -20,6 +21,6 @@ export const RestPerformanceCmd = botControlCmd({
const cleanSource = callStats.source.replace(leadingPathRegex, ""); const cleanSource = callStats.source.replace(leadingPathRegex, "");
return `**${callStats.count} calls**\n${callStats.method.toUpperCase()} ${callStats.path}\n${cleanSource}`; return `**${callStats.count} calls**\n${callStats.method.toUpperCase()} ${callStats.path}\n${cleanSource}`;
}); });
createChunkedMessage(msg.channel, `Top rest calls:\n\n${formatted.join("\n")}`); await createChunkedMessage(msg.channel as TextChannel, `Top rest calls:\n\n${formatted.join("\n")}`);
}, },
}); });

View file

@ -3,6 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { isStaffPreFilter } from "../../../pluginUtils"; import { isStaffPreFilter } from "../../../pluginUtils";
import { createChunkedMessage, getUser, renderUsername, sorter } from "../../../utils"; import { createChunkedMessage, getUser, renderUsername, sorter } from "../../../utils";
import { botControlCmd } from "../types"; import { botControlCmd } from "../types";
import { TextBasedChannelFields, TextChannel } from "discord.js";
export const ServersCmd = botControlCmd({ export const ServersCmd = botControlCmd({
trigger: ["servers", "guilds"], trigger: ["servers", "guilds"],
@ -52,16 +53,16 @@ export const ServersCmd = botControlCmd({
owner.id owner.id
}\`)`; }\`)`;
}); });
createChunkedMessage(msg.channel, lines.join("\n")); await createChunkedMessage(msg.channel as TextChannel, lines.join("\n"));
} else { } else {
msg.channel.send("No servers matched the filters"); await (msg.channel as TextBasedChannelFields).send("No servers matched the filters");
} }
} else { } else {
const total = joinedGuilds.length; const total = joinedGuilds.length;
const initialized = joinedGuilds.filter((g) => loadedGuildsMap.has(g.id)).length; const initialized = joinedGuilds.filter((g) => loadedGuildsMap.has(g.id)).length;
const unInitialized = total - initialized; const unInitialized = total - initialized;
msg.channel.send( await (msg.channel as TextBasedChannelFields).send(
`I am on **${total} total servers**, of which **${initialized} are initialized** and **${unInitialized} are not initialized**`, `I am on **${total} total servers**, of which **${initialized} are initialized** and **${unInitialized} are not initialized**`,
); );
} }

View file

@ -1,6 +1,6 @@
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError"; import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { UnknownUser, renderUsername, resolveUser } from "../../../utils"; import { renderUsername, resolveUser, UnknownUser } from "../../../utils";
import { CaseNoteArgs, CasesPluginType } from "../types"; import { CaseNoteArgs, CasesPluginType } from "../types";
import { postCaseToCaseLogChannel } from "./postToCaseLogChannel"; import { postCaseToCaseLogChannel } from "./postToCaseLogChannel";
import { resolveCaseId } from "./resolveCaseId"; import { resolveCaseId } from "./resolveCaseId";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners"; import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners";

View file

@ -5,7 +5,14 @@ import cloneDeep from "lodash.clonedeep";
import { allowTimeout } from "../../../RegExpRunner"; import { allowTimeout } from "../../../RegExpRunner";
import { ZalgoRegex } from "../../../data/Zalgo"; import { ZalgoRegex } from "../../../data/Zalgo";
import { SavedMessage } from "../../../data/entities/SavedMessage"; import { SavedMessage } from "../../../data/entities/SavedMessage";
import { getInviteCodesInString, getUrlsInString, isGuildInvite, resolveInvite, resolveMember } from "../../../utils"; import {
getInviteCodesInString,
getUrlsInString,
isGuildInvite,
resolveInvite,
resolveMember,
zSnowflake,
} from "../../../utils";
import { CensorPluginType } from "../types"; import { CensorPluginType } from "../types";
import { censorMessage } from "./censorMessage"; import { censorMessage } from "./censorMessage";
@ -58,18 +65,18 @@ export async function applyFiltersToMsg(
for (const invite of invites) { for (const invite of invites) {
// Always filter unknown invites if invite filtering is enabled // Always filter unknown invites if invite filtering is enabled
if (invite == null) { if (invite == null) {
censorMessage(pluginData, savedMessage, `unknown invite not found in whitelist`); await censorMessage(pluginData, savedMessage, `unknown invite not found in whitelist`);
return true; return true;
} }
if (!isGuildInvite(invite) && !allowGroupDMInvites) { if (!isGuildInvite(invite) && !allowGroupDMInvites) {
censorMessage(pluginData, savedMessage, `group dm invites are not allowed`); await censorMessage(pluginData, savedMessage, `group dm invites are not allowed`);
return true; return true;
} }
if (isGuildInvite(invite)) { if (isGuildInvite(invite)) {
if (inviteGuildWhitelist && !inviteGuildWhitelist.includes(invite.guild!.id)) { if (inviteGuildWhitelist && !inviteGuildWhitelist.includes(await zSnowflake.parseAsync(invite.guild!.id))) {
censorMessage( await censorMessage(
pluginData, pluginData,
savedMessage, savedMessage,
`invite guild (**${invite.guild!.name}** \`${invite.guild!.id}\`) not found in whitelist`, `invite guild (**${invite.guild!.name}** \`${invite.guild!.id}\`) not found in whitelist`,
@ -77,8 +84,8 @@ export async function applyFiltersToMsg(
return true; return true;
} }
if (inviteGuildBlacklist && inviteGuildBlacklist.includes(invite.guild!.id)) { if (inviteGuildBlacklist && inviteGuildBlacklist.includes(await zSnowflake.parseAsync(invite.guild!.id))) {
censorMessage( await censorMessage(
pluginData, pluginData,
savedMessage, savedMessage,
`invite guild (**${invite.guild!.name}** \`${invite.guild!.id}\`) found in blacklist`, `invite guild (**${invite.guild!.name}** \`${invite.guild!.id}\`) found in blacklist`,

View file

@ -2,7 +2,7 @@ import { Snowflake } from "discord.js";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { isOwner, sendErrorMessage } from "../../../pluginUtils"; import { isOwner, sendErrorMessage } from "../../../pluginUtils";
import { SECONDS, confirm, noop, renderUsername } from "../../../utils"; import { confirm, noop, renderUsername, SECONDS } from "../../../utils";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin"; import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { rehostAttachment } from "../rehostAttachment"; import { rehostAttachment } from "../rehostAttachment";
import { channelArchiverCmd } from "../types"; import { channelArchiverCmd } from "../types";

View file

@ -1,6 +1,7 @@
import { Attachment, GuildTextBasedChannel, MessageCreateOptions } from "discord.js"; import { Attachment, GuildTextBasedChannel, MessageCreateOptions } from "discord.js";
import fs from "fs"; import fs from "fs";
import { downloadFile } from "../../utils"; import { downloadFile } from "../../utils";
const fsp = fs.promises; const fsp = fs.promises;
const MAX_ATTACHMENT_REHOST_SIZE = 1024 * 1024 * 8; const MAX_ATTACHMENT_REHOST_SIZE = 1024 * 1024 * 8;

View file

@ -1,6 +1,7 @@
import { StageChannel, VoiceChannel } from "discord.js"; import { StageChannel, VoiceChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types"; import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";
import { zSnowflake } from "../../../utils";
const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = { const defaultCompanionChannelOpts: Partial<TCompanionChannelOpts> = {
enabled: true, enabled: true,
@ -15,8 +16,8 @@ export async function getCompanionChannelOptsForVoiceChannelId(
return Object.values(config.entries) return Object.values(config.entries)
.filter( .filter(
(opts) => (opts) =>
opts.voice_channel_ids.includes(voiceChannel.id) || opts.voice_channel_ids.includes(zSnowflake.parse(voiceChannel.id)) ||
(voiceChannel.parentId && opts.voice_channel_ids.includes(voiceChannel.parentId)), (voiceChannel.parentId && opts.voice_channel_ids.includes(zSnowflake.parse(voiceChannel.parentId))),
) )
.map((opts) => Object.assign({}, defaultCompanionChannelOpts, opts)); .map((opts) => Object.assign({}, defaultCompanionChannelOpts, opts));
} }

View file

@ -1,7 +1,7 @@
import { PermissionsBitField, Snowflake, StageChannel, TextChannel, VoiceChannel } from "discord.js"; import { PermissionsBitField, Snowflake, StageChannel, TextChannel, VoiceChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { MINUTES, isDiscordAPIError } from "../../../utils"; import { isDiscordAPIError, MINUTES } from "../../../utils";
import { filterObject } from "../../../utils/filterObject"; import { filterObject } from "../../../utils/filterObject";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types"; import { CompanionChannelsPluginType, TCompanionChannelOpts } from "../types";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildContextMenuLinks } from "../../data/GuildContextMenuLinks"; import { GuildContextMenuLinks } from "../../data/GuildContextMenuLinks";
import { LogsPlugin } from "../Logs/LogsPlugin"; import { LogsPlugin } from "../Logs/LogsPlugin";
import { MutesPlugin } from "../Mutes/MutesPlugin"; import { MutesPlugin } from "../Mutes/MutesPlugin";

View file

@ -1,9 +1,8 @@
import { EventEmitter } from "events"; import { guildPlugin, PluginOptions } from "knub";
import { PluginOptions, guildPlugin } from "knub";
import { GuildCounters } from "../../data/GuildCounters"; import { GuildCounters } from "../../data/GuildCounters";
import { CounterTrigger, parseCounterConditionString } from "../../data/entities/CounterTrigger"; import { CounterTrigger, parseCounterConditionString } from "../../data/entities/CounterTrigger";
import { makePublicFn } from "../../pluginUtils"; import { makePublicFn } from "../../pluginUtils";
import { MINUTES, convertDelayStringToMS, values } from "../../utils"; import { convertDelayStringToMS, MINUTES, values } from "../../utils";
import { AddCounterCmd } from "./commands/AddCounterCmd"; import { AddCounterCmd } from "./commands/AddCounterCmd";
import { CountersListCmd } from "./commands/CountersListCmd"; import { CountersListCmd } from "./commands/CountersListCmd";
import { ResetAllCounterValuesCmd } from "./commands/ResetAllCounterValuesCmd"; import { ResetAllCounterValuesCmd } from "./commands/ResetAllCounterValuesCmd";
@ -19,6 +18,7 @@ import { offCounterEvent } from "./functions/offCounterEvent";
import { onCounterEvent } from "./functions/onCounterEvent"; import { onCounterEvent } from "./functions/onCounterEvent";
import { setCounterValue } from "./functions/setCounterValue"; import { setCounterValue } from "./functions/setCounterValue";
import { CountersPluginType, zCountersConfig } from "./types"; import { CountersPluginType, zCountersConfig } from "./types";
import { EventEmitter } from "events";
const DECAY_APPLY_INTERVAL = 5 * MINUTES; const DECAY_APPLY_INTERVAL = 5 * MINUTES;

View file

@ -3,7 +3,7 @@ import { guildPluginMessageCommand } from "knub";
import { waitForReply } from "knub/helpers"; import { waitForReply } from "knub/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { UnknownUser, resolveUser } from "../../../utils"; import { resolveUser, UnknownUser } from "../../../utils";
import { changeCounterValue } from "../functions/changeCounterValue"; import { changeCounterValue } from "../functions/changeCounterValue";
import { CountersPluginType } from "../types"; import { CountersPluginType } from "../types";

View file

@ -3,7 +3,7 @@ import { guildPluginMessageCommand } from "knub";
import { waitForReply } from "knub/helpers"; import { waitForReply } from "knub/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { UnknownUser, resolveUser } from "../../../utils"; import { resolveUser, UnknownUser } from "../../../utils";
import { setCounterValue } from "../functions/setCounterValue"; import { setCounterValue } from "../functions/setCounterValue";
import { CountersPluginType } from "../types"; import { CountersPluginType } from "../types";

View file

@ -3,7 +3,7 @@ import { guildPluginMessageCommand } from "knub";
import { waitForReply } from "knub/helpers"; import { waitForReply } from "knub/helpers";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { UnknownUser, resolveUser } from "../../../utils"; import { resolveUser, UnknownUser } from "../../../utils";
import { setCounterValue } from "../functions/setCounterValue"; import { setCounterValue } from "../functions/setCounterValue";
import { CountersPluginType } from "../types"; import { CountersPluginType } from "../types";

View file

@ -3,8 +3,8 @@ import { BasePluginType } from "knub";
import z from "zod"; import z from "zod";
import { GuildCounters, MAX_COUNTER_VALUE, MIN_COUNTER_VALUE } from "../../data/GuildCounters"; import { GuildCounters, MAX_COUNTER_VALUE, MIN_COUNTER_VALUE } from "../../data/GuildCounters";
import { import {
CounterTrigger,
buildCounterConditionString, buildCounterConditionString,
CounterTrigger,
getReverseCounterComparisonOp, getReverseCounterComparisonOp,
parseCounterConditionString, parseCounterConditionString,
} from "../../data/entities/CounterTrigger"; } from "../../data/entities/CounterTrigger";

View file

@ -2,7 +2,7 @@ import { GuildChannel, GuildMember, User } from "discord.js";
import { guildPlugin, guildPluginMessageCommand, parseSignature } from "knub"; import { guildPlugin, guildPluginMessageCommand, parseSignature } from "knub";
import { TSignature } from "knub-command-manager"; import { TSignature } from "knub-command-manager";
import { commandTypes } from "../../commandTypes"; import { commandTypes } from "../../commandTypes";
import { TemplateSafeValueContainer, createTypedTemplateSafeValueContainer } from "../../templateFormatter"; import { createTypedTemplateSafeValueContainer, TemplateSafeValueContainer } from "../../templateFormatter";
import { UnknownUser } from "../../utils"; import { UnknownUser } from "../../utils";
import { isScalar } from "../../utils/isScalar"; import { isScalar } from "../../utils/isScalar";
import { import {

View file

@ -1,7 +1,7 @@
import { Snowflake, TextChannel } from "discord.js"; import { Snowflake, TextChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import z from "zod"; import z from "zod";
import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter";
import { zBoundedCharacters, zSnowflake } from "../../../utils"; import { zBoundedCharacters, zSnowflake } from "../../../utils";
import { ActionError } from "../ActionError"; import { ActionError } from "../ActionError";
import { catchTemplateError } from "../catchTemplateError"; import { catchTemplateError } from "../catchTemplateError";

View file

@ -2,7 +2,7 @@ import { Snowflake, VoiceChannel } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import z from "zod"; import z from "zod";
import { canActOn } from "../../../pluginUtils"; import { canActOn } from "../../../pluginUtils";
import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter";
import { resolveMember, zSnowflake } from "../../../utils"; import { resolveMember, zSnowflake } from "../../../utils";
import { ActionError } from "../ActionError"; import { ActionError } from "../ActionError";
import { catchTemplateError } from "../catchTemplateError"; import { catchTemplateError } from "../catchTemplateError";

View file

@ -1,5 +1,5 @@
import { Guild } from "discord.js"; import { Guild } from "discord.js";
import { BasePluginType, GlobalPluginData, globalPlugin, globalPluginEventListener } from "knub"; import { BasePluginType, globalPlugin, GlobalPluginData, globalPluginEventListener } from "knub";
import z from "zod"; import z from "zod";
import { AllowedGuilds } from "../../data/AllowedGuilds"; import { AllowedGuilds } from "../../data/AllowedGuilds";
import { Configs } from "../../data/Configs"; import { Configs } from "../../data/Configs";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import z from "zod"; import z from "zod";
import { Queue } from "../../Queue"; import { Queue } from "../../Queue";
import { Webhooks } from "../../data/Webhooks"; import { Webhooks } from "../../data/Webhooks";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { onGuildEvent } from "../../data/GuildEvents"; import { onGuildEvent } from "../../data/GuildEvents";
import { GuildVCAlerts } from "../../data/GuildVCAlerts"; import { GuildVCAlerts } from "../../data/GuildVCAlerts";
import { FollowCmd } from "./commands/FollowCmd"; import { FollowCmd } from "./commands/FollowCmd";

View file

@ -3,6 +3,7 @@ import { clearExpiringVCAlert } from "../../../data/loops/expiringVCAlertsLoop";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { createChunkedMessage, sorter } from "../../../utils"; import { createChunkedMessage, sorter } from "../../../utils";
import { locateUserCmd } from "../types"; import { locateUserCmd } from "../types";
import { TextChannel } from "discord.js";
export const ListFollowCmd = locateUserCmd({ export const ListFollowCmd = locateUserCmd({
trigger: ["follows", "fs"], trigger: ["follows", "fs"],
@ -13,7 +14,7 @@ export const ListFollowCmd = locateUserCmd({
async run({ message: msg, pluginData }) { async run({ message: msg, pluginData }) {
const alerts = await pluginData.state.alerts.getAlertsByRequestorId(msg.member.id); const alerts = await pluginData.state.alerts.getAlertsByRequestorId(msg.member.id);
if (alerts.length === 0) { if (alerts.length === 0) {
sendErrorMessage(pluginData, msg.channel, "You have no active alerts!"); await sendErrorMessage(pluginData, msg.channel, "You have no active alerts!");
return; return;
} }
@ -26,7 +27,7 @@ export const ListFollowCmd = locateUserCmd({
alert.body alert.body
}\` **Active:** ${alert.active.valueOf()}`; }\` **Active:** ${alert.active.valueOf()}`;
}); });
await createChunkedMessage(msg.channel, lines.join("\n")); await createChunkedMessage(msg.channel as TextChannel, lines.join("\n"));
}, },
}); });

View file

@ -1,4 +1,4 @@
import { CooldownManager, PluginOptions, guildPlugin } from "knub"; import { CooldownManager, guildPlugin, PluginOptions } from "knub";
import DefaultLogMessages from "../../data/DefaultLogMessages.json"; import DefaultLogMessages from "../../data/DefaultLogMessages.json";
import { GuildArchives } from "../../data/GuildArchives"; import { GuildArchives } from "../../data/GuildArchives";
import { GuildCases } from "../../data/GuildCases"; import { GuildCases } from "../../data/GuildCases";

View file

@ -3,7 +3,7 @@ import { GuildPluginData } from "knub";
import { allowTimeout } from "../../../RegExpRunner"; import { allowTimeout } from "../../../RegExpRunner";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { TypedTemplateSafeValueContainer } from "../../../templateFormatter"; import { TypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { MINUTES, isDiscordAPIError } from "../../../utils"; import { isDiscordAPIError, MINUTES, zSnowflake } from "../../../utils";
import { MessageBuffer } from "../../../utils/MessageBuffer"; import { MessageBuffer } from "../../../utils/MessageBuffer";
import { InternalPosterPlugin } from "../../InternalPoster/InternalPosterPlugin"; import { InternalPosterPlugin } from "../../InternalPoster/InternalPosterPlugin";
import { ILogTypeData, LogsPluginType, TLogChannel, TLogChannelMap } from "../types"; import { ILogTypeData, LogsPluginType, TLogChannel, TLogChannelMap } from "../types";
@ -28,7 +28,11 @@ async function shouldExclude(
opts: TLogChannel, opts: TLogChannel,
exclusionData: ExclusionData, exclusionData: ExclusionData,
): Promise<boolean> { ): Promise<boolean> {
if (opts.excluded_users && exclusionData.userId && opts.excluded_users.includes(exclusionData.userId)) { if (
opts.excluded_users &&
exclusionData.userId &&
opts.excluded_users.includes(zSnowflake.parse(exclusionData.userId))
) {
return true; return true;
} }
@ -38,21 +42,33 @@ async function shouldExclude(
if (opts.excluded_roles && exclusionData.roles) { if (opts.excluded_roles && exclusionData.roles) {
for (const role of exclusionData.roles) { for (const role of exclusionData.roles) {
if (opts.excluded_roles.includes(role)) { if (opts.excluded_roles.includes(await zSnowflake.parseAsync(role))) {
return true; return true;
} }
} }
} }
if (opts.excluded_channels && exclusionData.channel && opts.excluded_channels.includes(exclusionData.channel)) { if (
opts.excluded_channels &&
exclusionData.channel &&
opts.excluded_channels.includes(await zSnowflake.parseAsync(exclusionData.channel))
) {
return true; return true;
} }
if (opts.excluded_categories && exclusionData.category && opts.excluded_categories.includes(exclusionData.category)) { if (
opts.excluded_categories &&
exclusionData.category &&
opts.excluded_categories.includes(await zSnowflake.parseAsync(exclusionData.category))
) {
return true; return true;
} }
if (opts.excluded_threads && exclusionData.thread && opts.excluded_threads.includes(exclusionData.thread)) { if (
opts.excluded_threads &&
exclusionData.thread &&
opts.excluded_threads.includes(await zSnowflake.parseAsync(exclusionData.thread))
) {
return true; return true;
} }
@ -83,20 +99,20 @@ export async function log<TLogType extends keyof ILogTypeData>(
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake); const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!channel?.isTextBased()) continue; if (!channel?.isTextBased()) continue;
if (pluginData.state.channelCooldowns.isOnCooldown(channelId)) continue; if (pluginData.state.channelCooldowns.isOnCooldown(channelId)) continue;
if (opts.include?.length && !opts.include.includes(typeStr)) continue; if (opts!.include?.length && !opts!.include.includes(typeStr)) continue;
if (opts.exclude && opts.exclude.includes(typeStr)) continue; if (opts!.exclude && opts!.exclude.includes(typeStr)) continue;
if (await shouldExclude(pluginData, opts, exclusionData)) continue; if (await shouldExclude(pluginData, opts!, exclusionData)) continue;
const message = await getLogMessage(pluginData, type, data, { const message = await getLogMessage(pluginData, type, data, {
format: opts.format, format: opts!.format,
include_embed_timestamp: opts.include_embed_timestamp, include_embed_timestamp: opts!.include_embed_timestamp,
timestamp_format: opts.timestamp_format, timestamp_format: opts!.timestamp_format,
}); });
if (!message) return; if (!message) return;
// Initialize message buffer for this channel // Initialize message buffer for this channel
if (!pluginData.state.buffers.has(channelId)) { if (!pluginData.state.buffers.has(channelId)) {
const batchTime = Math.min(Math.max(opts.batch_time ?? DEFAULT_BATCH_TIME, MIN_BATCH_TIME), MAX_BATCH_TIME); const batchTime = Math.min(Math.max(opts!.batch_time ?? DEFAULT_BATCH_TIME, MIN_BATCH_TIME), MAX_BATCH_TIME);
const internalPosterPlugin = pluginData.getPlugin(InternalPosterPlugin); const internalPosterPlugin = pluginData.getPlugin(InternalPosterPlugin);
pluginData.state.buffers.set( pluginData.state.buffers.set(
channelId, channelId,

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { SaveMessagesToDBCmd } from "./commands/SaveMessagesToDB"; import { SaveMessagesToDBCmd } from "./commands/SaveMessagesToDB";
import { SavePinsToDBCmd } from "./commands/SavePinsToDB"; import { SavePinsToDBCmd } from "./commands/SavePinsToDB";

View file

@ -1,5 +1,4 @@
import { Message } from "discord.js"; import { Message } from "discord.js";
import { EventEmitter } from "events";
import { guildPlugin } from "knub"; import { guildPlugin } from "knub";
import { Queue } from "../../Queue"; import { Queue } from "../../Queue";
import { GuildCases } from "../../data/GuildCases"; import { GuildCases } from "../../data/GuildCases";
@ -48,6 +47,7 @@ import { onModActionsEvent } from "./functions/onModActionsEvent";
import { updateCase } from "./functions/updateCase"; import { updateCase } from "./functions/updateCase";
import { warnMember } from "./functions/warnMember"; import { warnMember } from "./functions/warnMember";
import { ModActionsPluginType, zModActionsConfig } from "./types"; import { ModActionsPluginType, zModActionsConfig } from "./types";
import { EventEmitter } from "events";
const defaultOptions = { const defaultOptions = {
config: { config: {

View file

@ -1,7 +1,7 @@
import { APIEmbed } from "discord.js"; import { APIEmbed } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { UnknownUser, emptyEmbedValue, renderUsername, resolveMember, resolveUser, trimLines } from "../../../utils"; import { emptyEmbedValue, renderUsername, resolveMember, resolveUser, trimLines, UnknownUser } from "../../../utils";
import { asyncMap } from "../../../utils/async"; import { asyncMap } from "../../../utils/async";
import { createPaginatedMessage } from "../../../utils/createPaginatedMessage"; import { createPaginatedMessage } from "../../../utils/createPaginatedMessage";
import { getGuildPrefix } from "../../../utils/getGuildPrefix"; import { getGuildPrefix } from "../../../utils/getGuildPrefix";

View file

@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin"; import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
import { UnknownUser, chunkArray, emptyEmbedValue, renderUsername, resolveMember, resolveUser } from "../../../utils"; import { chunkArray, emptyEmbedValue, renderUsername, resolveMember, resolveUser, UnknownUser } from "../../../utils";
import { asyncMap } from "../../../utils/async"; import { asyncMap } from "../../../utils/async";
import { createPaginatedMessage } from "../../../utils/createPaginatedMessage.js"; import { createPaginatedMessage } from "../../../utils/createPaginatedMessage.js";
import { getGuildPrefix } from "../../../utils/getGuildPrefix"; import { getGuildPrefix } from "../../../utils/getGuildPrefix";

View file

@ -2,7 +2,7 @@ import { helpers } from "knub";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { Case } from "../../../data/entities/Case"; import { Case } from "../../../data/entities/Case";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { SECONDS, renderUsername, trimLines } from "../../../utils"; import { renderUsername, SECONDS, trimLines } from "../../../utils";
import { CasesPlugin } from "../../Cases/CasesPlugin"; import { CasesPlugin } from "../../Cases/CasesPlugin";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin"; import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";

View file

@ -7,7 +7,7 @@ import { LogType } from "../../../data/LogType";
import { humanizeDurationShort } from "../../../humanizeDurationShort"; import { humanizeDurationShort } from "../../../humanizeDurationShort";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin"; import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
import { DAYS, MINUTES, SECONDS, noop } from "../../../utils"; import { DAYS, MINUTES, noop, SECONDS } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments"; import { formatReasonWithAttachments } from "../functions/formatReasonWithAttachments";
import { ignoreEvent } from "../functions/ignoreEvent"; import { ignoreEvent } from "../functions/ignoreEvent";

View file

@ -1,7 +1,7 @@
import { AuditLogEvent, User } from "discord.js"; import { AuditLogEvent, User } from "discord.js";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case"; import { Case } from "../../../data/entities/Case";
import { UnknownUser, resolveUser } from "../../../utils"; import { resolveUser, UnknownUser } from "../../../utils";
import { findMatchingAuditLogEntry } from "../../../utils/findMatchingAuditLogEntry"; import { findMatchingAuditLogEntry } from "../../../utils/findMatchingAuditLogEntry";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { CasesPlugin } from "../../Cases/CasesPlugin"; import { CasesPlugin } from "../../Cases/CasesPlugin";

View file

@ -2,7 +2,7 @@ import { AuditLogEvent, User } from "discord.js";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case"; import { Case } from "../../../data/entities/Case";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
import { UnknownUser, resolveUser } from "../../../utils"; import { resolveUser, UnknownUser } from "../../../utils";
import { findMatchingAuditLogEntry } from "../../../utils/findMatchingAuditLogEntry"; import { findMatchingAuditLogEntry } from "../../../utils/findMatchingAuditLogEntry";
import { CasesPlugin } from "../../Cases/CasesPlugin"; import { CasesPlugin } from "../../Cases/CasesPlugin";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";

View file

@ -1,7 +1,7 @@
import { AuditLogEvent, User } from "discord.js"; import { AuditLogEvent, User } from "discord.js";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { Case } from "../../../data/entities/Case"; import { Case } from "../../../data/entities/Case";
import { UnknownUser, resolveUser } from "../../../utils"; import { resolveUser, UnknownUser } from "../../../utils";
import { findMatchingAuditLogEntry } from "../../../utils/findMatchingAuditLogEntry"; import { findMatchingAuditLogEntry } from "../../../utils/findMatchingAuditLogEntry";
import { CasesPlugin } from "../../Cases/CasesPlugin"; import { CasesPlugin } from "../../Cases/CasesPlugin";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";

View file

@ -3,7 +3,7 @@ import { GuildPluginData } from "knub";
import { hasPermission } from "knub/helpers"; import { hasPermission } from "knub/helpers";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { DAYS, SECONDS, errorMessage, renderUsername, resolveMember, resolveUser } from "../../../utils"; import { DAYS, errorMessage, renderUsername, resolveMember, resolveUser, SECONDS } from "../../../utils";
import { IgnoredEventType, ModActionsPluginType } from "../types"; import { IgnoredEventType, ModActionsPluginType } from "../types";
import { formatReasonWithAttachments } from "./formatReasonWithAttachments"; import { formatReasonWithAttachments } from "./formatReasonWithAttachments";
import { ignoreEvent } from "./ignoreEvent"; import { ignoreEvent } from "./ignoreEvent";

View file

@ -4,7 +4,7 @@ import { GuildPluginData } from "knub";
import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError"; import { ERRORS, RecoverablePluginError } from "../../../RecoverablePluginError";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { UnknownUser, asSingleLine, isDiscordAPIError, renderUsername } from "../../../utils"; import { asSingleLine, isDiscordAPIError, renderUsername, UnknownUser } from "../../../utils";
import { MutesPlugin } from "../../Mutes/MutesPlugin"; import { MutesPlugin } from "../../Mutes/MutesPlugin";
import { MuteResult } from "../../Mutes/types"; import { MuteResult } from "../../Mutes/types";
import { ModActionsPluginType } from "../types"; import { ModActionsPluginType } from "../types";

View file

@ -3,7 +3,7 @@ import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { hasPermission, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin"; import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
import { UnknownUser, asSingleLine, renderUsername } from "../../../utils"; import { asSingleLine, renderUsername, UnknownUser } from "../../../utils";
import { ModActionsPluginType } from "../types"; import { ModActionsPluginType } from "../types";
import { formatReasonWithAttachments } from "./formatReasonWithAttachments"; import { formatReasonWithAttachments } from "./formatReasonWithAttachments";

View file

@ -5,16 +5,16 @@ import { CaseTypes } from "../../../data/CaseTypes";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { registerExpiringTempban } from "../../../data/loops/expiringTempbansLoop"; import { registerExpiringTempban } from "../../../data/loops/expiringTempbansLoop";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter";
import { import {
DAYS,
SECONDS,
UserNotificationResult,
createUserNotificationError, createUserNotificationError,
DAYS,
notifyUser, notifyUser,
resolveMember, resolveMember,
resolveUser, resolveUser,
SECONDS,
ucfirst, ucfirst,
UserNotificationResult,
} from "../../../utils"; } from "../../../utils";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { CasesPlugin } from "../../Cases/CasesPlugin"; import { CasesPlugin } from "../../Cases/CasesPlugin";

View file

@ -1,6 +1,6 @@
import { PermissionsBitField, Snowflake } from "discord.js"; import { PermissionsBitField, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { SECONDS, isDiscordAPIError, isDiscordHTTPError, sleep } from "../../../utils"; import { isDiscordAPIError, isDiscordHTTPError, SECONDS, sleep } from "../../../utils";
import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions"; import { hasDiscordPermissions } from "../../../utils/hasDiscordPermissions";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { ModActionsPluginType } from "../types"; import { ModActionsPluginType } from "../types";

View file

@ -1,8 +1,8 @@
import { GuildMember, Snowflake } from "discord.js"; import { GuildMember, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { CaseTypes } from "../../../data/CaseTypes"; import { CaseTypes } from "../../../data/CaseTypes";
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter";
import { UserNotificationResult, createUserNotificationError, notifyUser, resolveUser, ucfirst } from "../../../utils"; import { createUserNotificationError, notifyUser, resolveUser, ucfirst, UserNotificationResult } from "../../../utils";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { waitForButtonConfirm } from "../../../utils/waitForInteraction"; import { waitForButtonConfirm } from "../../../utils/waitForInteraction";
import { CasesPlugin } from "../../Cases/CasesPlugin"; import { CasesPlugin } from "../../Cases/CasesPlugin";

View file

@ -1,5 +1,4 @@
import { GuildMember, Snowflake } from "discord.js"; import { GuildMember, Snowflake } from "discord.js";
import { EventEmitter } from "events";
import { guildPlugin } from "knub"; import { guildPlugin } from "knub";
import { GuildArchives } from "../../data/GuildArchives"; import { GuildArchives } from "../../data/GuildArchives";
import { GuildCases } from "../../data/GuildCases"; import { GuildCases } from "../../data/GuildCases";
@ -24,6 +23,7 @@ import { onMutesEvent } from "./functions/onMutesEvent";
import { renewTimeoutMute } from "./functions/renewTimeoutMute"; import { renewTimeoutMute } from "./functions/renewTimeoutMute";
import { unmuteUser } from "./functions/unmuteUser"; import { unmuteUser } from "./functions/unmuteUser";
import { MutesPluginType, zMutesConfig } from "./types"; import { MutesPluginType, zMutesConfig } from "./types";
import { EventEmitter } from "events";
const defaultOptions = { const defaultOptions = {
config: { config: {

View file

@ -9,15 +9,15 @@ import { Case } from "../../../data/entities/Case";
import { Mute } from "../../../data/entities/Mute"; import { Mute } from "../../../data/entities/Mute";
import { registerExpiringMute } from "../../../data/loops/expiringMutesLoop"; import { registerExpiringMute } from "../../../data/loops/expiringMutesLoop";
import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin"; import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin";
import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter";
import { import {
UserNotificationMethod,
UserNotificationResult,
noop, noop,
notifyUser, notifyUser,
resolveMember, resolveMember,
resolveUser, resolveUser,
ucfirst, ucfirst,
UserNotificationMethod,
UserNotificationResult,
} from "../../../utils"; } from "../../../utils";
import { muteLock } from "../../../utils/lockNameHelpers"; import { muteLock } from "../../../utils/lockNameHelpers";
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { Queue } from "../../Queue"; import { Queue } from "../../Queue";
import { GuildNicknameHistory } from "../../data/GuildNicknameHistory"; import { GuildNicknameHistory } from "../../data/GuildNicknameHistory";
import { UsernameHistory } from "../../data/UsernameHistory"; import { UsernameHistory } from "../../data/UsernameHistory";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";
import { GuildPersistedData } from "../../data/GuildPersistedData"; import { GuildPersistedData } from "../../data/GuildPersistedData";
import { LogsPlugin } from "../Logs/LogsPlugin"; import { LogsPlugin } from "../Logs/LogsPlugin";

View file

@ -8,7 +8,7 @@ import { getMissingPermissions } from "../../../utils/getMissingPermissions";
import { missingPermissionError } from "../../../utils/missingPermissionError"; import { missingPermissionError } from "../../../utils/missingPermissionError";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin"; import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin";
import { PersistPluginType, persistEvt } from "../types"; import { persistEvt, PersistPluginType } from "../types";
const p = PermissionFlagsBits; const p = PermissionFlagsBits;

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { hasPhishermanMasterAPIKey, phishermanApiKeyIsValid } from "../../data/Phisherman"; import { hasPhishermanMasterAPIKey, phishermanApiKeyIsValid } from "../../data/Phisherman";
import { makePublicFn } from "../../pluginUtils"; import { makePublicFn } from "../../pluginUtils";
import { getDomainInfo } from "./functions/getDomainInfo"; import { getDomainInfo } from "./functions/getDomainInfo";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildPingableRoles } from "../../data/GuildPingableRoles"; import { GuildPingableRoles } from "../../data/GuildPingableRoles";
import { PingableRoleDisableCmd } from "./commands/PingableRoleDisableCmd"; import { PingableRoleDisableCmd } from "./commands/PingableRoleDisableCmd";
import { PingableRoleEnableCmd } from "./commands/PingableRoleEnableCmd"; import { PingableRoleEnableCmd } from "./commands/PingableRoleEnableCmd";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { onGuildEvent } from "../../data/GuildEvents"; import { onGuildEvent } from "../../data/GuildEvents";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";

View file

@ -1,4 +1,4 @@
import { escapeCodeBlock } from "discord.js"; import { escapeCodeBlock, TextChannel } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { createChunkedMessage, DBDateFormat, deactivateMentions, sorter, trimLines } from "../../../utils"; import { createChunkedMessage, DBDateFormat, deactivateMentions, sorter, trimLines } from "../../../utils";
@ -58,6 +58,6 @@ export const ScheduledPostsListCmd = postCmd({
Use \`scheduled_posts <num>\` to view a scheduled post in full Use \`scheduled_posts <num>\` to view a scheduled post in full
Use \`scheduled_posts delete <num>\` to delete a scheduled post Use \`scheduled_posts delete <num>\` to delete a scheduled post
`); `);
createChunkedMessage(msg.channel, finalMessage); createChunkedMessage(msg.channel as TextChannel, finalMessage);
}, },
}); });

View file

@ -1,10 +1,10 @@
import { GuildTextBasedChannel, Message } from "discord.js"; import { GuildTextBasedChannel, Message, TextBasedChannelFields } from "discord.js";
import humanizeDuration from "humanize-duration"; 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"; import { registerUpcomingScheduledPost } from "../../../data/loops/upcomingScheduledPostsLoop";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { DBDateFormat, MINUTES, StrictMessageContent, errorMessage, renderUsername } from "../../../utils"; import { DBDateFormat, errorMessage, MINUTES, renderUsername, StrictMessageContent } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin"; import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { PostPluginType } from "../types"; import { PostPluginType } from "../types";
@ -29,12 +29,12 @@ export async function actualPostCmd(
} = {}, } = {},
) { ) {
if (!targetChannel.isTextBased()) { if (!targetChannel.isTextBased()) {
msg.channel.send(errorMessage("Specified channel is not a text-based channel")); await (msg.channel as TextBasedChannelFields).send(errorMessage("Specified channel is not a text-based channel"));
return; return;
} }
if (content == null && msg.attachments.size === 0) { if (content == null && msg.attachments.size === 0) {
msg.channel.send(errorMessage("Message content or attachment required")); await (msg.channel as TextBasedChannelFields).send(errorMessage("Message content or attachment required"));
return; return;
} }

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { Queue } from "../../Queue"; import { Queue } from "../../Queue";
import { GuildReactionRoles } from "../../data/GuildReactionRoles"; import { GuildReactionRoles } from "../../data/GuildReactionRoles";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";

View file

@ -3,7 +3,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { canUseEmoji, isDiscordAPIError, isValidEmoji, noop, trimPluginDescription } from "../../../utils"; import { canUseEmoji, isDiscordAPIError, isValidEmoji, noop, trimPluginDescription } from "../../../utils";
import { canReadChannel } from "../../../utils/canReadChannel"; import { canReadChannel } from "../../../utils/canReadChannel";
import { TReactionRolePair, reactionRolesCmd } from "../types"; import { reactionRolesCmd, TReactionRolePair } from "../types";
import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage"; import { applyReactionRoleReactionsToMessage } from "../util/applyReactionRoleReactionsToMessage";
const CLEAR_ROLES_EMOJI = "❌"; const CLEAR_ROLES_EMOJI = "❌";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { onGuildEvent } from "../../data/GuildEvents"; import { onGuildEvent } from "../../data/GuildEvents";
import { GuildReminders } from "../../data/GuildReminders"; import { GuildReminders } from "../../data/GuildReminders";
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin"; import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";

View file

@ -4,6 +4,7 @@ import { sendErrorMessage } from "../../../pluginUtils";
import { createChunkedMessage, DBDateFormat, sorter } from "../../../utils"; import { createChunkedMessage, DBDateFormat, sorter } from "../../../utils";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin"; import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { remindersCmd } from "../types"; import { remindersCmd } from "../types";
import { TextChannel } from "discord.js";
export const RemindersCmd = remindersCmd({ export const RemindersCmd = remindersCmd({
trigger: "reminders", trigger: "reminders",
@ -32,6 +33,6 @@ export const RemindersCmd = remindersCmd({
return `\`${paddedNum}.\` \`${prettyRemindAt} (${result})\` ${reminder.body}`; return `\`${paddedNum}.\` \`${prettyRemindAt} (${result})\` ${reminder.body}`;
}); });
createChunkedMessage(msg.channel, lines.join("\n")); await createChunkedMessage(msg.channel as TextChannel, lines.join("\n"));
}, },
}); });

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";
import { LogsPlugin } from "../Logs/LogsPlugin"; import { LogsPlugin } from "../Logs/LogsPlugin";
import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin"; import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin";

View file

@ -1,4 +1,4 @@
import { CooldownManager, PluginOptions, guildPlugin } from "knub"; import { CooldownManager, guildPlugin, PluginOptions } from "knub";
import { RoleAddCmd } from "./commands/RoleAddCmd"; import { RoleAddCmd } from "./commands/RoleAddCmd";
import { RoleHelpCmd } from "./commands/RoleHelpCmd"; import { RoleHelpCmd } from "./commands/RoleHelpCmd";
import { RoleRemoveCmd } from "./commands/RoleRemoveCmd"; import { RoleRemoveCmd } from "./commands/RoleRemoveCmd";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildSlowmodes } from "../../data/GuildSlowmodes"; import { GuildSlowmodes } from "../../data/GuildSlowmodes";

View file

@ -1,4 +1,4 @@
import { Message } from "discord.js"; import { Message, TextBasedChannelFields } from "discord.js";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { noop } from "../../../utils"; import { noop } from "../../../utils";
import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions"; import { getMissingChannelPermissions } from "../../../utils/getMissingChannelPermissions";
@ -26,7 +26,7 @@ export async function actualDisableSlowmodeCmd(msg: Message, args, pluginData) {
return; return;
} }
const initMsg = await msg.channel.send("Disabling slowmode..."); const initMsg = await (msg.channel as TextBasedChannelFields).send("Disabling slowmode...");
// Disable bot-maintained slowmode // Disable bot-maintained slowmode
let failedUsers: string[] = []; let failedUsers: string[] = [];

View file

@ -2,7 +2,7 @@ import { GuildTextBasedChannel, Snowflake } from "discord.js";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { logger } from "../../../logger"; import { logger } from "../../../logger";
import { UnknownUser, isDiscordAPIError, verboseChannelMention, verboseUserMention } from "../../../utils"; import { isDiscordAPIError, UnknownUser, verboseChannelMention, verboseUserMention } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { SlowmodePluginType } from "../types"; import { SlowmodePluginType } from "../types";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildArchives } from "../../data/GuildArchives"; import { GuildArchives } from "../../data/GuildArchives";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";
import { GuildMutes } from "../../data/GuildMutes"; import { GuildMutes } from "../../data/GuildMutes";

View file

@ -9,7 +9,7 @@ import { logger } from "../../../logger";
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin"; import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin"; import { MutesPlugin } from "../../../plugins/Mutes/MutesPlugin";
import { MuteResult } from "../../../plugins/Mutes/types"; import { MuteResult } from "../../../plugins/Mutes/types";
import { DBDateFormat, convertDelayStringToMS, noop, resolveMember, trimLines } from "../../../utils"; import { convertDelayStringToMS, DBDateFormat, noop, resolveMember, trimLines } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { RecentActionType, SpamPluginType, TBaseSingleSpamConfig } from "../types"; import { RecentActionType, SpamPluginType, TBaseSingleSpamConfig } from "../types";
import { addRecentAction } from "./addRecentAction"; import { addRecentAction } from "./addRecentAction";

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { GuildSavedMessages } from "../../data/GuildSavedMessages";
import { GuildStarboardMessages } from "../../data/GuildStarboardMessages"; import { GuildStarboardMessages } from "../../data/GuildStarboardMessages";
import { GuildStarboardReactions } from "../../data/GuildStarboardReactions"; import { GuildStarboardReactions } from "../../data/GuildStarboardReactions";

View file

@ -1,6 +1,6 @@
import { GuildChannel, Message } from "discord.js"; import { GuildChannel, Message } from "discord.js";
import path from "path"; import path from "path";
import { EMPTY_CHAR, EmbedWith, renderUsername } from "../../../utils"; import { EmbedWith, EMPTY_CHAR, renderUsername } from "../../../utils";
const imageAttachmentExtensions = ["jpeg", "jpg", "png", "gif", "webp"]; const imageAttachmentExtensions = ["jpeg", "jpg", "png", "gif", "webp"];
const audioAttachmentExtensions = ["wav", "mp3", "m4a"]; const audioAttachmentExtensions = ["wav", "mp3", "m4a"];

View file

@ -1,6 +1,6 @@
import { Snowflake } from "discord.js"; import { Snowflake } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { GuildArchives } from "../../data/GuildArchives"; import { GuildArchives } from "../../data/GuildArchives";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";

View file

@ -1,6 +1,6 @@
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { TemplateParseError, parseTemplate } from "../../../templateFormatter"; import { parseTemplate, TemplateParseError } from "../../../templateFormatter";
import { tagsCmd } from "../types"; import { tagsCmd } from "../types";
export const TagCreateCmd = tagsCmd({ export const TagCreateCmd = tagsCmd({

View file

@ -2,6 +2,7 @@ import escapeStringRegexp from "escape-string-regexp";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { createChunkedMessage } from "../../../utils"; import { createChunkedMessage } from "../../../utils";
import { tagsCmd } from "../types"; import { tagsCmd } from "../types";
import { TextChannel } from "discord.js";
export const TagListCmd = tagsCmd({ export const TagListCmd = tagsCmd({
trigger: ["tag list", "tags", "taglist"], trigger: ["tag list", "tags", "taglist"],
@ -46,6 +47,6 @@ export const TagListCmd = tagsCmd({
.map((key) => `[${key}] ${tagGroups[key].join(", ")}`) .map((key) => `[${key}] ${tagGroups[key].join(", ")}`)
.join("\n"); .join("\n");
createChunkedMessage(msg.channel, `Available tags (use with ${prefix}tag): \`\`\`${tagList}\`\`\``); createChunkedMessage(msg.channel as TextChannel, `Available tags (use with ${prefix}tag): \`\`\`${tagList}\`\`\``);
}, },
}); });

View file

@ -1,5 +1,5 @@
import { ExtendedMatchParams, GuildPluginData } from "knub"; import { ExtendedMatchParams, GuildPluginData } from "knub";
import { TTag, TagsPluginType } from "../types"; import { TagsPluginType, TTag } from "../types";
export async function findTagByName( export async function findTagByName(
pluginData: GuildPluginData<TagsPluginType>, pluginData: GuildPluginData<TagsPluginType>,

View file

@ -2,7 +2,7 @@ import { GuildMember } from "discord.js";
import escapeStringRegexp from "escape-string-regexp"; import escapeStringRegexp from "escape-string-regexp";
import { ExtendedMatchParams, GuildPluginData } from "knub"; import { ExtendedMatchParams, GuildPluginData } from "knub";
import { StrictMessageContent } from "../../../utils"; import { StrictMessageContent } from "../../../utils";
import { TTagCategory, TagsPluginType } from "../types"; import { TagsPluginType, TTagCategory } from "../types";
import { renderTagFromString } from "./renderTagFromString"; import { renderTagFromString } from "./renderTagFromString";
interface BaseResult { interface BaseResult {

View file

@ -1,7 +1,7 @@
import { ExtendedMatchParams, GuildPluginData } from "knub"; import { ExtendedMatchParams, GuildPluginData } from "knub";
import { TemplateSafeValue, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter"; import { renderTemplate, TemplateSafeValue, TemplateSafeValueContainer } from "../../../templateFormatter";
import { StrictMessageContent, renderRecursively } from "../../../utils"; import { renderRecursively, StrictMessageContent } from "../../../utils";
import { TTag, TagsPluginType } from "../types"; import { TagsPluginType, TTag } from "../types";
import { findTagByName } from "./findTagByName"; import { findTagByName } from "./findTagByName";
const MAX_TAG_FN_CALLS = 25; const MAX_TAG_FN_CALLS = 25;

View file

@ -6,7 +6,7 @@ import { TemplateParseError } from "../../../templateFormatter";
import { StrictMessageContent, validateAndParseMessageContent } from "../../../utils"; import { StrictMessageContent, validateAndParseMessageContent } from "../../../utils";
import { memberToTemplateSafeMember, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { memberToTemplateSafeMember, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { TTag, TagsPluginType } from "../types"; import { TagsPluginType, TTag } from "../types";
import { renderTagBody } from "./renderTagBody"; import { renderTagBody } from "./renderTagBody";
export async function renderTagFromString( export async function renderTagFromString(

View file

@ -1,4 +1,4 @@
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildMemberTimezones } from "../../data/GuildMemberTimezones"; import { GuildMemberTimezones } from "../../data/GuildMemberTimezones";
import { makePublicFn } from "../../pluginUtils"; import { makePublicFn } from "../../pluginUtils";
import { ResetTimezoneCmd } from "./commands/ResetTimezoneCmd"; import { ResetTimezoneCmd } from "./commands/ResetTimezoneCmd";

View file

@ -1,5 +1,5 @@
import { Snowflake } from "discord.js"; import { Snowflake } from "discord.js";
import { PluginOptions, guildPlugin } from "knub"; import { guildPlugin, PluginOptions } from "knub";
import { GuildArchives } from "../../data/GuildArchives"; import { GuildArchives } from "../../data/GuildArchives";
import { GuildCases } from "../../data/GuildCases"; import { GuildCases } from "../../data/GuildCases";
import { GuildLogs } from "../../data/GuildLogs"; import { GuildLogs } from "../../data/GuildLogs";

View file

@ -1,7 +1,7 @@
import { APIEmbed, ImageFormat } from "discord.js"; import { APIEmbed, ImageFormat } from "discord.js";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage } from "../../../pluginUtils"; import { sendErrorMessage } from "../../../pluginUtils";
import { UnknownUser, renderUsername } from "../../../utils"; import { renderUsername, UnknownUser } from "../../../utils";
import { utilityCmd } from "../types"; import { utilityCmd } from "../types";
export const AvatarCmd = utilityCmd({ export const AvatarCmd = utilityCmd({

View file

@ -7,9 +7,9 @@ import { SavedMessage } from "../../../data/entities/SavedMessage";
import { humanizeDurationShort } from "../../../humanizeDurationShort"; import { humanizeDurationShort } from "../../../humanizeDurationShort";
import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { getBaseUrl, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin"; import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin";
import { DAYS, SECONDS, chunkArray, getInviteCodesInString, noop } from "../../../utils"; import { chunkArray, DAYS, getInviteCodesInString, noop, SECONDS } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { UtilityPluginType, utilityCmd } from "../types"; import { utilityCmd, UtilityPluginType } from "../types";
const MAX_CLEAN_COUNT = 300; const MAX_CLEAN_COUNT = 300;
const MAX_CLEAN_TIME = 1 * DAYS; const MAX_CLEAN_TIME = 1 * DAYS;

View file

@ -2,6 +2,7 @@ import { LoadedGuildPlugin, PluginCommandDefinition } from "knub";
import { commandTypeHelpers as ct } from "../../../commandTypes"; import { commandTypeHelpers as ct } from "../../../commandTypes";
import { createChunkedMessage } from "../../../utils"; import { createChunkedMessage } from "../../../utils";
import { utilityCmd } from "../types"; import { utilityCmd } from "../types";
import { TextChannel } from "discord.js";
export const HelpCmd = utilityCmd({ export const HelpCmd = utilityCmd({
trigger: "help", trigger: "help",
@ -78,6 +79,6 @@ export const HelpCmd = utilityCmd({
: ""; : "";
message += commandSnippets.join("\n\n"); message += commandSnippets.join("\n\n");
createChunkedMessage(msg.channel, message); createChunkedMessage(msg.channel as TextChannel, message);
}, },
}); });

View file

@ -1,7 +1,7 @@
import { APIEmbed, ChannelType, Snowflake, StageChannel, VoiceChannel } from "discord.js"; import { APIEmbed, ChannelType, Snowflake, StageChannel, VoiceChannel } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { EmbedWith, MINUTES, formatNumber, preEmbedPadding, trimLines, verboseUserMention } from "../../../utils"; import { EmbedWith, formatNumber, MINUTES, preEmbedPadding, trimLines, verboseUserMention } from "../../../utils";
import { UtilityPluginType } from "../types"; import { UtilityPluginType } from "../types";
const TEXT_CHANNEL_ICON = const TEXT_CHANNEL_ICON =

View file

@ -1,5 +1,5 @@
import { Client, GuildPreview, Snowflake } from "discord.js"; import { Client, GuildPreview, Snowflake } from "discord.js";
import { MINUTES, memoize } from "../../../utils"; import { memoize, MINUTES } from "../../../utils";
/** /**
* Memoized getGuildPreview * Memoized getGuildPreview

Some files were not shown because too many files have changed in this diff Show more