Compare commits

..

No commits in common. "working-commit" and "list" have entirely different histories.

187 changed files with 25958 additions and 18648 deletions

84
.env.example Normal file
View file

@ -0,0 +1,84 @@
# ==========================
# GENERAL OPTIONS
# ==========================
# 32 character encryption key
KEY=
# Values from the Discord developer portal
CLIENT_ID=
CLIENT_SECRET=
BOT_TOKEN=
# The defaults here automatically work for the development environment.
# For production, change localhost:3300 to your domain.
DASHBOARD_URL=https://localhost:3300
API_URL=https://localhost:3300/api
# Comma-separated list of user IDs who should have access to the bot's global commands
STAFF=
# A comma-separated list of server IDs that should be allowed by default
DEFAULT_ALLOWED_SERVERS=
# Only required if relevant feature is used
#PHISHERMAN_API_KEY=
# ==========================
# DEVELOPMENT
# NOTE: You only need to fill in these values for running the development environment
# ==========================
DEVELOPMENT_WEB_PORT=3300
# The MySQL database running in the container is exposed to the host on this port,
# allowing access with database tools such as DBeaver
DEVELOPMENT_MYSQL_PORT=3356
# Password for the Zeppelin database user
DEVELOPMENT_MYSQL_PASSWORD=password
# Password for the MySQL root user
DEVELOPMENT_MYSQL_ROOT_PASSWORD=password
# The development environment container has an SSH server that you can connect to.
# This is the port that server is exposed to the host on.
DEVELOPMENT_SSH_PORT=3022
DEVELOPMENT_SSH_PASSWORD=password
# If your user has a different UID than 1000, you might have to fill that in here to avoid permission issues
#DEVELOPMENT_UID=1000
# ==========================
# PRODUCTION - STANDALONE
# NOTE: You only need to fill in these values for running the standalone production environment
# ==========================
STANDALONE_WEB_PORT=80
# The MySQL database running in the container is exposed to the host on this port,
# allowing access with database tools such as DBeaver
STANDALONE_MYSQL_PORT=3356
# Password for the Zeppelin database user
STANDALONE_MYSQL_PASSWORD=
# Password for the MySQL root user
STANDALONE_MYSQL_ROOT_PASSWORD=
# ==========================
# PRODUCTION - LIGHTWEIGHT
# NOTE: You only need to fill in these values for running the lightweight production environment
# ==========================
# Ports where the API/dashboard are exposed on the host
LIGHTWEIGHT_API_PORT=3001
LIGHTWEIGHT_DASHBOARD_PORT=3002
LIGHTWEIGHT_DB_HOST=
LIGHTWEIGHT_DB_PORT=
LIGHTWEIGHT_DB_USER=
LIGHTWEIGHT_DB_PASSWORD=
LIGHTWEIGHT_DB_DATABASE=
# If you want to add a prefix to API paths, such as /api, you can set that here
LIGHTWEIGHT_API_PATH_PREFIX=

28
.eslintrc.js Normal file
View file

@ -0,0 +1,28 @@
module.exports = {
root: true,
env: {
node: true,
browser: true,
es6: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"no-async-promise-executor": 0,
"@typescript-eslint/no-empty-interface": 0,
"no-constant-condition": ["error", {
checkLoops: false,
}],
"prefer-const": ["error", {
destructuring: "all",
ignoreReadBeforeAssign: true,
}],
"@typescript-eslint/no-namespace": ["error", {
allowDeclarations: true,
}],
},
};

View file

@ -8,20 +8,16 @@ jobs:
strategy: strategy:
matrix: matrix:
node-version: [23] node-version: [18.16]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Setup pnpm - name: npm install, lint, code style check
uses: pnpm/action-setup@v4
with:
version: latest
- name: pnpm install, lint, code style check
run: | run: |
pnpm i npm ci
pnpm run lint npm run lint
pnpm run codestyle-check npm run codestyle-check

View file

@ -1,21 +0,0 @@
name: Push code
on:
push:
branches:
- working-commit
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: install ssh keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_ed25519
echo "${{ secrets.ZAPPYZEP_KEY }}" > ~/.ssh/id_ed25519
ssh-keyscan -H zappyzep.xyz > ~/.ssh/known_hosts
- name: connect and pull
run: ssh zappyzep@zappyzep.xyz "cd Zeppelin && git checkout working-commit && git pull && docker compose -f docker-compose.standalone.yml down && docker image rm zeppelin-prod-{api,dashboard,bot,migrate,nginx,revampdashboard} && docker compose -f docker-compose.standalone.yml up -d && exit"
- name: cleanup
run: rm -rf ~/.ssh

View file

@ -1,7 +1,6 @@
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
@ -9,34 +8,27 @@ USER node
ARG API_URL ARG API_URL
# Install dependencies before copying over any other files # Install dependencies before copying over any other files
RUN corepack prepare --activate pnpm@latest COPY --chown=node:node package.json package-lock.json /zeppelin
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
COPY --chown=node:node shared/package.json /zeppelin/shared/ COPY --chown=node:node shared/package.json /zeppelin/shared
RUN mkdir /zeppelin/dashboard RUN mkdir /zeppelin/dashboard
COPY --chown=node:node dashboard/package.json /zeppelin/dashboard/ COPY --chown=node:node dashboard/package.json /zeppelin/dashboard
RUN mkdir /zeppelin/revampdashboard
COPY --chown=node:node revampdashboard/package.json /zeppelin/revampdashboard/
WORKDIR /zeppelin WORKDIR /zeppelin
RUN pnpm i RUN npm ci
COPY --chown=node:node . /zeppelin COPY --chown=node:node . /zeppelin
# Build backend # Build backend
WORKDIR /zeppelin/backend WORKDIR /zeppelin/backend
RUN pnpm run build RUN npm run build
# Build dashboard # Build dashboard
WORKDIR /zeppelin/dashboard WORKDIR /zeppelin/dashboard
RUN pnpm run build RUN npm run build
WORKDIR /zeppelin/revampdashboard/
RUN pnpm run check
RUN pnpm run build
# Prune dev dependencies # Prune dev dependencies
WORKDIR /zeppelin WORKDIR /zeppelin
RUN pnpm prune --prod RUN npm prune --omit=dev

View file

@ -18,28 +18,26 @@
"start-api-prod-debug": "clinic heapprofiler --collect-only --dest .clinic-api -- node --enable-source-maps --stack-trace-limit=30 dist/api/index.js", "start-api-prod-debug": "clinic heapprofiler --collect-only --dest .clinic-api -- node --enable-source-maps --stack-trace-limit=30 dist/api/index.js",
"watch-api": "tsc-watch --build --onSuccess \"npm run start-api-dev\"", "watch-api": "tsc-watch --build --onSuccess \"npm run start-api-dev\"",
"typeorm": "node ../node_modules/typeorm/cli.js", "typeorm": "node ../node_modules/typeorm/cli.js",
"migrate": "pnpm run typeorm -- migration:run -d dist/data/dataSource.js", "migrate": "npm run typeorm -- migration:run -d dist/data/dataSource.js",
"migrate-prod": "pnpm run migrate", "migrate-prod": "npm run migrate",
"migrate-dev": "pnpm run build && npm run migrate", "migrate-dev": "npm run build && npm run migrate",
"migrate-rollback": "pnpm run typeorm -- migration:revert -d dist/data/dataSource.js", "migrate-rollback": "npm run typeorm -- migration:revert -d dist/data/dataSource.js",
"migrate-rollback-prod": "pnpm run migrate-rollback", "migrate-rollback-prod": "npm run migrate-rollback",
"migrate-rollback-dev": "pnpm run build && npm run migrate-rollback", "migrate-rollback-dev": "npm run build && npm run migrate-rollback",
"validate-active-configs": "node --enable-source-maps dist/validateActiveConfigs.js > ../config-errors.txt", "validate-active-configs": "node --enable-source-maps dist/validateActiveConfigs.js > ../config-errors.txt",
"export-config-json-schema": "node --enable-source-maps dist/exportSchemas.js > ../config-schema.json", "export-config-json-schema": "node --enable-source-maps dist/exportSchemas.js > ../config-schema.json",
"test": "pnpm run build && pnpm run run-tests", "test": "npm run build && npm run run-tests",
"run-tests": "ava", "run-tests": "ava",
"test-watch": "tsc-watch --build --onSuccess \"npx ava\"" "test-watch": "tsc-watch --build --onSuccess \"npx ava\""
}, },
"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",
"cookie-parser": "^1.4.7",
"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.16.3", "discord.js": "^14.14.1",
"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",
@ -50,14 +48,12 @@
"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,20 +72,18 @@
"tmp": "0.0.33", "tmp": "0.0.33",
"tsconfig-paths": "^3.9.0", "tsconfig-paths": "^3.9.0",
"twemoji": "^12.1.4", "twemoji": "^12.1.4",
"typeorm": "^0.3.20", "typeorm": "^0.3.17",
"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.9", "zlib-sync": "^0.1.7",
"zod": "^3.7.2" "zod": "^3.7.2"
}, },
"devDependencies": { "devDependencies": {
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.5", "@types/cors": "^2.8.5",
"@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",
@ -102,7 +96,7 @@
"@types/twemoji": "^12.1.0", "@types/twemoji": "^12.1.0",
"@types/uuid": "^9.0.2", "@types/uuid": "^9.0.2",
"ava": "^5.3.1", "ava": "^5.3.1",
"rimraf": "^6.0.1", "rimraf": "^2.6.2",
"source-map-support": "^0.5.16", "source-map-support": "^0.5.16",
"zod-to-json-schema": "^3.22.3" "zod-to-json-schema": "^3.22.3"
}, },

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

@ -1,4 +1,4 @@
import express, { NextFunction, Request, Response } from "express"; import express, { Request, Response } from "express";
import https from "https"; import https from "https";
import pick from "lodash.pick"; import pick from "lodash.pick";
import passport from "passport"; import passport from "passport";
@ -111,32 +111,14 @@ export function initAuth(router: express.Router) {
); );
router.get("/auth/login", passport.authenticate("oauth2")); router.get("/auth/login", passport.authenticate("oauth2"));
router.get(
"/auth/new-login",
(req: Request, res: Response, next: NextFunction) => {
res.cookie("redir", `/new/auth/login-callback/`, { httpOnly: true });
next();
},
passport.authenticate("oauth2"),
);
router.get( router.get(
"/auth/oauth-callback", "/auth/oauth-callback",
passport.authenticate("oauth2", { failureRedirect: "/", session: false }), passport.authenticate("oauth2", { failureRedirect: "/", session: false }),
(req: Request, res: Response) => { (req: Request, res: Response) => {
res.clearCookie("redir");
if (req.user && req.user.apiKey) { if (req.user && req.user.apiKey) {
res.redirect( res.redirect(`${env.DASHBOARD_URL}/login-callback/?apiKey=${req.user.apiKey}`);
req.cookies.redir
? `${env.DASHBOARD_URL}${req.cookies.redir.toString()}?apiKey=${req.user.apiKey}`
: `${env.DASHBOARD_URL}/login-callback/?apiKey=${req.user.apiKey}`,
);
} else { } else {
res.redirect( res.redirect(`${env.DASHBOARD_URL}/login-callback/?error=noAccess`);
req.cookies.redir
? `${env.DASHBOARD_URL}${req.cookies.redir.toString()}?error=noAccess`
: `${env.DASHBOARD_URL}/login-callback/?error=noAccess`,
);
} }
}, },
); );
@ -168,6 +150,7 @@ export function initAuth(router: express.Router) {
export function apiTokenAuthHandlers() { export function apiTokenAuthHandlers() {
return [ return [
passport.authenticate("api-token", { failWithError: true, session: false }), passport.authenticate("api-token", { failWithError: true, session: false }),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(err, req: Request, res: Response, next) => { (err, req: Request, res: Response, next) => {
return res.status(401).json({ error: err.message }); return res.status(401).json({ error: err.message });
}, },

View file

@ -1,7 +1,6 @@
import cors from "cors"; import cors from "cors";
import express from "express"; import express from "express";
import multer from "multer"; import multer from "multer";
import cookieParser from "cookie-parser";
import { TokenError } from "passport-oauth2"; import { TokenError } from "passport-oauth2";
import { env } from "../env"; import { env } from "../env";
import { initArchives } from "./archives"; import { initArchives } from "./archives";
@ -26,14 +25,13 @@ app.use(
}), }),
); );
app.use(multer().none()); app.use(multer().none());
app.use(cookieParser());
const rootRouter = express.Router(); const rootRouter = express.Router();
initAuth(rootRouter); initAuth(app);
initGuildsAPI(rootRouter); initGuildsAPI(app);
initArchives(rootRouter); initArchives(app);
initDocs(rootRouter); initDocs(app);
// Default route // Default route
rootRouter.get("/", (req, res) => { rootRouter.get("/", (req, res) => {

View file

@ -7,7 +7,6 @@ import { DAYS, DBDateFormat } from "../utils";
import { BaseRepository } from "./BaseRepository"; import { BaseRepository } from "./BaseRepository";
import { dataSource } from "./dataSource"; import { dataSource } from "./dataSource";
import { ApiLogin } from "./entities/ApiLogin"; import { ApiLogin } from "./entities/ApiLogin";
import { randomBytes } from "node:crypto";
const LOGIN_EXPIRY_TIME = 1 * DAYS; const LOGIN_EXPIRY_TIME = 1 * DAYS;
@ -49,7 +48,7 @@ export class ApiLogins extends BaseRepository {
// Generate random login id // Generate random login id
let loginId; let loginId;
while (true) { while (true) {
loginId = randomBytes(16).toString("hex"); loginId = uuidv4();
const existing = await this.apiLogins.findOne({ const existing = await this.apiLogins.findOne({
where: { where: {
id: loginId, id: loginId,
@ -59,7 +58,7 @@ export class ApiLogins extends BaseRepository {
} }
// Generate token // Generate token
const token = randomBytes(32).toString("hex"); const token = uuidv4();
const hash = crypto.createHash("sha256"); const hash = crypto.createHash("sha256");
hash.update(loginId + token); // Use loginId as a salt hash.update(loginId + token); // Use loginId as a salt
const hashedToken = hash.digest("hex"); const hashedToken = hash.digest("hex");

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 { ApiUserInfo as ApiUserInfoEntity, ApiUserInfoData } from "./entities/ApiUserInfo"; import { ApiUserInfoData, ApiUserInfo as ApiUserInfoEntity } 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 { renderTemplate, TemplateSafeValueContainer } from "../templateFormatter"; import { TemplateSafeValueContainer, renderTemplate } 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, isValidCounterComparisonOp, TriggerComparisonOp } from "./entities/CounterTrigger"; import { CounterTrigger, TriggerComparisonOp, isValidCounterComparisonOp } 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 { errorMessage, isDiscordAPIError, isDiscordHTTPError, MINUTES, SECONDS, sleep, successMessage } from "./utils"; import { MINUTES, SECONDS, errorMessage, isDiscordAPIError, isDiscordHTTPError, 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,24 +3,18 @@ import { MigrationInterface, QueryRunner, Table, TableColumn } from "typeorm";
export class MoveStarboardsToConfig1573248462469 implements MigrationInterface { export class MoveStarboardsToConfig1573248462469 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> { public async up(queryRunner: QueryRunner): Promise<any> {
// Create a new column for the channel's id // Create a new column for the channel's id
await queryRunner.addColumn( await queryRunner.addColumn("starboard_messages", new TableColumn({
"starboard_messages", name: "starboard_channel_id",
new TableColumn({ type: "bigint",
name: "starboard_channel_id", unsigned: true,
type: "bigint", }));
unsigned: true,
}),
);
// Since we are removing the guild_id with the starboards table, we might want it here // Since we are removing the guild_id with the starboards table, we might want it here
await queryRunner.addColumn( await queryRunner.addColumn("starboard_messages", new TableColumn({
"starboard_messages", name: "guild_id",
new TableColumn({ type: "bigint",
name: "guild_id", unsigned: true,
type: "bigint", }));
unsigned: true,
}),
);
// Migrate the old starboard_id to the new starboard_channel_id // Migrate the old starboard_id to the new starboard_channel_id
await queryRunner.query(` await queryRunner.query(`
@ -49,14 +43,11 @@ export class MoveStarboardsToConfig1573248462469 implements MigrationInterface {
await queryRunner.dropColumn("starboard_messages", "starboard_channel_id"); await queryRunner.dropColumn("starboard_messages", "starboard_channel_id");
await queryRunner.dropColumn("starboard_messages", "guild_id"); await queryRunner.dropColumn("starboard_messages", "guild_id");
await queryRunner.addColumn( await queryRunner.addColumn("starboard_messages", new TableColumn({
"starboard_messages", name: "starboard_id",
new TableColumn({ type: "int",
name: "starboard_id", unsigned: true,
type: "int", }));
unsigned: true,
}),
);
await queryRunner.query(` await queryRunner.query(`
ALTER TABLE starboard_messages ALTER TABLE starboard_messages

View file

@ -3,14 +3,12 @@
*/ */
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";
@ -63,7 +61,7 @@ export async function sendSuccessMessage(
? { content: formattedBody, allowedMentions } ? { content: formattedBody, allowedMentions }
: { content: formattedBody }; : { content: formattedBody };
return ((channel as TextChannel) || DMChannel) return channel
.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;
@ -84,7 +82,7 @@ export async function sendErrorMessage(
? { content: formattedBody, allowedMentions } ? { content: formattedBody, allowedMentions }
: { content: formattedBody }; : { content: formattedBody };
return ((channel as TextChannel) || DMChannel) return channel
.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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } 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 { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } 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 { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter";
import { convertDelayStringToMS, MINUTES, noop, zBoundedCharacters, zDelayString } from "../../../utils"; import { MINUTES, convertDelayStringToMS, 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 { disableUserNotificationStrings, UserNotificationMethod } from "../../../utils"; import { UserNotificationMethod, disableUserNotificationStrings } 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(await zSnowflake.parseAsync(invite.guild.id))) { if (trigger.include_guilds && trigger.include_guilds.includes(invite.guild.id)) {
return { extra: { type, code, invite } }; return { extra: { type, code, invite } };
} }
if (trigger.exclude_guilds && !trigger.exclude_guilds.includes(await zSnowflake.parseAsync(invite.guild.id))) { if (trigger.exclude_guilds && !trigger.exclude_guilds.includes(invite.guild.id)) {
return { extra: { type, code, invite } }; return { extra: { type, code, invite } };
} }
} }

View file

@ -1,4 +1,4 @@
import { escapeBold, type Snowflake, User } from "discord.js"; import { User, escapeBold, type Snowflake } 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 { escapeBold, type Snowflake, User } from "discord.js"; import { User, escapeBold, type Snowflake } 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 { escapeBold, type Snowflake, User } from "discord.js"; import { User, escapeBold, type Snowflake } 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 { escapeBold, type Snowflake, User } from "discord.js"; import { User, escapeBold, type Snowflake } 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,11 +10,12 @@ 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 { ModActionsEvents, ModActionType } from "../ModActions/types"; import { ModActionType, ModActionsEvents } 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,7 +1,6 @@
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"],
@ -17,7 +16,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) {
await sendErrorMessage(pluginData, msg.channel, "Channel not found in cache!"); sendErrorMessage(pluginData, msg.channel, "Channel not found in cache!");
return; return;
} }
@ -26,8 +25,6 @@ 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";
await (msg.channel as TextBasedChannelFields).send( msg.channel.send(`**Channel:** ${channelName} (\`${channel.type}\`) (<#${channel.id}>)\n**Server:** ${guildInfo}`);
`**Channel:** ${channelName} (\`${channel.type}\`) (<#${channel.id}>)\n**Server:** ${guildInfo}`,
);
}, },
}); });

View file

@ -4,7 +4,6 @@ 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",
@ -52,6 +51,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);
await (msg.channel as TextBasedChannelFields).send(`Link: ${archiveUrl}`); msg.channel.send(`Link: ${archiveUrl}`);
}, },
}); });

View file

@ -3,7 +3,6 @@ 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"],
@ -35,6 +34,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);
await (msg.channel as TextBasedChannelFields).send(`Link: ${archiveUrl}`); msg.channel.send(`Link: ${archiveUrl}`);
}, },
}); });

View file

@ -1,7 +1,6 @@
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",
@ -15,13 +14,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) {
await sendErrorMessage(pluginData, message.channel, "This command can only be used in a server"); 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 as TextBasedChannelFields).send("Reloading global plugins..."); await message.channel.send("Reloading global plugins...");
await pluginData.getKnubInstance().reloadGlobalContext(); pluginData.getKnubInstance().reloadGlobalContext();
}, },
}); });

View file

@ -2,7 +2,6 @@ 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;
@ -21,6 +20,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}`;
}); });
await createChunkedMessage(msg.channel as TextChannel, `Top rest calls:\n\n${formatted.join("\n")}`); createChunkedMessage(msg.channel, `Top rest calls:\n\n${formatted.join("\n")}`);
}, },
}); });

View file

@ -3,7 +3,6 @@ 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"],
@ -53,16 +52,16 @@ export const ServersCmd = botControlCmd({
owner.id owner.id
}\`)`; }\`)`;
}); });
await createChunkedMessage(msg.channel as TextChannel, lines.join("\n")); createChunkedMessage(msg.channel, lines.join("\n"));
} else { } else {
await (msg.channel as TextBasedChannelFields).send("No servers matched the filters"); msg.channel.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;
await (msg.channel as TextBasedChannelFields).send( msg.channel.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 { renderUsername, resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, renderUsername, resolveUser } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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,14 +5,7 @@ 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 { import { getInviteCodesInString, getUrlsInString, isGuildInvite, resolveInvite, resolveMember } from "../../../utils";
getInviteCodesInString,
getUrlsInString,
isGuildInvite,
resolveInvite,
resolveMember,
zSnowflake,
} from "../../../utils";
import { CensorPluginType } from "../types"; import { CensorPluginType } from "../types";
import { censorMessage } from "./censorMessage"; import { censorMessage } from "./censorMessage";
@ -65,18 +58,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) {
await censorMessage(pluginData, savedMessage, `unknown invite not found in whitelist`); censorMessage(pluginData, savedMessage, `unknown invite not found in whitelist`);
return true; return true;
} }
if (!isGuildInvite(invite) && !allowGroupDMInvites) { if (!isGuildInvite(invite) && !allowGroupDMInvites) {
await censorMessage(pluginData, savedMessage, `group dm invites are not allowed`); censorMessage(pluginData, savedMessage, `group dm invites are not allowed`);
return true; return true;
} }
if (isGuildInvite(invite)) { if (isGuildInvite(invite)) {
if (inviteGuildWhitelist && !inviteGuildWhitelist.includes(await zSnowflake.parseAsync(invite.guild!.id))) { if (inviteGuildWhitelist && !inviteGuildWhitelist.includes(invite.guild!.id)) {
await censorMessage( 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`,
@ -84,8 +77,8 @@ export async function applyFiltersToMsg(
return true; return true;
} }
if (inviteGuildBlacklist && inviteGuildBlacklist.includes(await zSnowflake.parseAsync(invite.guild!.id))) { if (inviteGuildBlacklist && inviteGuildBlacklist.includes(invite.guild!.id)) {
await censorMessage( 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 { confirm, noop, renderUsername, SECONDS } from "../../../utils"; import { SECONDS, confirm, noop, renderUsername } 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,7 +1,6 @@
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,7 +1,6 @@
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,
@ -16,8 +15,8 @@ export async function getCompanionChannelOptsForVoiceChannelId(
return Object.values(config.entries) return Object.values(config.entries)
.filter( .filter(
(opts) => (opts) =>
opts.voice_channel_ids.includes(zSnowflake.parse(voiceChannel.id)) || opts.voice_channel_ids.includes(voiceChannel.id) ||
(voiceChannel.parentId && opts.voice_channel_ids.includes(zSnowflake.parse(voiceChannel.parentId))), (voiceChannel.parentId && opts.voice_channel_ids.includes(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 { isDiscordAPIError, MINUTES } from "../../../utils"; import { MINUTES, isDiscordAPIError } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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,8 +1,9 @@
import { guildPlugin, PluginOptions } from "knub"; import { EventEmitter } from "events";
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 { convertDelayStringToMS, MINUTES, values } from "../../utils"; import { MINUTES, convertDelayStringToMS, 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";
@ -18,7 +19,6 @@ 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 { resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, resolveUser } 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 { resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, resolveUser } 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 { resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, resolveUser } 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 {
buildCounterConditionString,
CounterTrigger, CounterTrigger,
buildCounterConditionString,
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 { createTypedTemplateSafeValueContainer, TemplateSafeValueContainer } from "../../templateFormatter"; import { TemplateSafeValueContainer, createTypedTemplateSafeValueContainer } 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 { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateSafeValueContainer, renderTemplate } 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 { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateSafeValueContainer, renderTemplate } 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, globalPlugin, GlobalPluginData, globalPluginEventListener } from "knub"; import { BasePluginType, GlobalPluginData, globalPlugin, 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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,7 +3,6 @@ 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"],
@ -14,7 +13,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) {
await sendErrorMessage(pluginData, msg.channel, "You have no active alerts!"); sendErrorMessage(pluginData, msg.channel, "You have no active alerts!");
return; return;
} }
@ -27,7 +26,7 @@ export const ListFollowCmd = locateUserCmd({
alert.body alert.body
}\` **Active:** ${alert.active.valueOf()}`; }\` **Active:** ${alert.active.valueOf()}`;
}); });
await createChunkedMessage(msg.channel as TextChannel, lines.join("\n")); await createChunkedMessage(msg.channel, lines.join("\n"));
}, },
}); });

View file

@ -1,4 +1,4 @@
import { CooldownManager, guildPlugin, PluginOptions } from "knub"; import { CooldownManager, PluginOptions, guildPlugin } 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 { isDiscordAPIError, MINUTES, zSnowflake } from "../../../utils"; import { MINUTES, isDiscordAPIError } 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,11 +28,7 @@ async function shouldExclude(
opts: TLogChannel, opts: TLogChannel,
exclusionData: ExclusionData, exclusionData: ExclusionData,
): Promise<boolean> { ): Promise<boolean> {
if ( if (opts.excluded_users && exclusionData.userId && opts.excluded_users.includes(exclusionData.userId)) {
opts.excluded_users &&
exclusionData.userId &&
opts.excluded_users.includes(zSnowflake.parse(exclusionData.userId))
) {
return true; return true;
} }
@ -42,33 +38,21 @@ 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(await zSnowflake.parseAsync(role))) { if (opts.excluded_roles.includes(role)) {
return true; return true;
} }
} }
} }
if ( if (opts.excluded_channels && exclusionData.channel && opts.excluded_channels.includes(exclusionData.channel)) {
opts.excluded_channels &&
exclusionData.channel &&
opts.excluded_channels.includes(await zSnowflake.parseAsync(exclusionData.channel))
) {
return true; return true;
} }
if ( if (opts.excluded_categories && exclusionData.category && opts.excluded_categories.includes(exclusionData.category)) {
opts.excluded_categories &&
exclusionData.category &&
opts.excluded_categories.includes(await zSnowflake.parseAsync(exclusionData.category))
) {
return true; return true;
} }
if ( if (opts.excluded_threads && exclusionData.thread && opts.excluded_threads.includes(exclusionData.thread)) {
opts.excluded_threads &&
exclusionData.thread &&
opts.excluded_threads.includes(await zSnowflake.parseAsync(exclusionData.thread))
) {
return true; return true;
} }
@ -99,20 +83,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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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,4 +1,5 @@
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";
@ -47,7 +48,6 @@ 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 { emptyEmbedValue, renderUsername, resolveMember, resolveUser, trimLines, UnknownUser } from "../../../utils"; import { UnknownUser, emptyEmbedValue, renderUsername, resolveMember, resolveUser, trimLines } 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 { chunkArray, emptyEmbedValue, renderUsername, resolveMember, resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, chunkArray, emptyEmbedValue, renderUsername, resolveMember, resolveUser } 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 { renderUsername, SECONDS, trimLines } from "../../../utils"; import { SECONDS, renderUsername, 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, noop, SECONDS } from "../../../utils"; import { DAYS, MINUTES, SECONDS, noop } 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 { resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, resolveUser } 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 { resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, resolveUser } 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 { resolveUser, UnknownUser } from "../../../utils"; import { UnknownUser, resolveUser } 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, errorMessage, renderUsername, resolveMember, resolveUser, SECONDS } from "../../../utils"; import { DAYS, SECONDS, errorMessage, renderUsername, resolveMember, resolveUser } 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 { asSingleLine, isDiscordAPIError, renderUsername, UnknownUser } from "../../../utils"; import { UnknownUser, asSingleLine, isDiscordAPIError, renderUsername } 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 { asSingleLine, renderUsername, UnknownUser } from "../../../utils"; import { UnknownUser, asSingleLine, renderUsername } 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 { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter";
import { import {
createUserNotificationError,
DAYS, DAYS,
SECONDS,
UserNotificationResult,
createUserNotificationError,
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 { isDiscordAPIError, isDiscordHTTPError, SECONDS, sleep } from "../../../utils"; import { SECONDS, isDiscordAPIError, isDiscordHTTPError, 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 { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter";
import { createUserNotificationError, notifyUser, resolveUser, ucfirst, UserNotificationResult } from "../../../utils"; import { UserNotificationResult, createUserNotificationError, notifyUser, resolveUser, ucfirst } 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,4 +1,5 @@
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";
@ -23,7 +24,6 @@ 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 { renderTemplate, TemplateParseError, TemplateSafeValueContainer } from "../../../templateFormatter"; import { TemplateParseError, TemplateSafeValueContainer, renderTemplate } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { persistEvt, PersistPluginType } from "../types"; import { PersistPluginType, persistEvt } from "../types";
const p = PermissionFlagsBits; const p = PermissionFlagsBits;

View file

@ -1,4 +1,4 @@
import { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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, TextChannel } from "discord.js"; import { escapeCodeBlock } 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 as TextChannel, finalMessage); createChunkedMessage(msg.channel, finalMessage);
}, },
}); });

View file

@ -1,10 +1,10 @@
import { GuildTextBasedChannel, Message, TextBasedChannelFields } from "discord.js"; import { GuildTextBasedChannel, Message } 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, errorMessage, MINUTES, renderUsername, StrictMessageContent } from "../../../utils"; import { DBDateFormat, MINUTES, StrictMessageContent, errorMessage, renderUsername } 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()) {
await (msg.channel as TextBasedChannelFields).send(errorMessage("Specified channel is not a text-based channel")); msg.channel.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) {
await (msg.channel as TextBasedChannelFields).send(errorMessage("Message content or attachment required")); msg.channel.send(errorMessage("Message content or attachment required"));
return; return;
} }

View file

@ -1,4 +1,4 @@
import { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { reactionRolesCmd, TReactionRolePair } from "../types"; import { TReactionRolePair, reactionRolesCmd } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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,7 +4,6 @@ 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",
@ -33,6 +32,6 @@ export const RemindersCmd = remindersCmd({
return `\`${paddedNum}.\` \`${prettyRemindAt} (${result})\` ${reminder.body}`; return `\`${paddedNum}.\` \`${prettyRemindAt} (${result})\` ${reminder.body}`;
}); });
await createChunkedMessage(msg.channel as TextChannel, lines.join("\n")); createChunkedMessage(msg.channel, lines.join("\n"));
}, },
}); });

View file

@ -1,4 +1,4 @@
import { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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, guildPlugin, PluginOptions } from "knub"; import { CooldownManager, PluginOptions, guildPlugin } 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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, TextBasedChannelFields } from "discord.js"; import { Message } 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 as TextBasedChannelFields).send("Disabling slowmode..."); const initMsg = await msg.channel.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 { isDiscordAPIError, UnknownUser, verboseChannelMention, verboseUserMention } from "../../../utils"; import { UnknownUser, isDiscordAPIError, 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { convertDelayStringToMS, DBDateFormat, noop, resolveMember, trimLines } from "../../../utils"; import { DBDateFormat, convertDelayStringToMS, 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { EmbedWith, EMPTY_CHAR, renderUsername } from "../../../utils"; import { EMPTY_CHAR, EmbedWith, 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 { guildPlugin, PluginOptions } from "knub"; import { PluginOptions, guildPlugin } 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 { parseTemplate, TemplateParseError } from "../../../templateFormatter"; import { TemplateParseError, parseTemplate } from "../../../templateFormatter";
import { tagsCmd } from "../types"; import { tagsCmd } from "../types";
export const TagCreateCmd = tagsCmd({ export const TagCreateCmd = tagsCmd({

View file

@ -2,7 +2,6 @@ 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"],
@ -47,6 +46,6 @@ export const TagListCmd = tagsCmd({
.map((key) => `[${key}] ${tagGroups[key].join(", ")}`) .map((key) => `[${key}] ${tagGroups[key].join(", ")}`)
.join("\n"); .join("\n");
createChunkedMessage(msg.channel as TextChannel, `Available tags (use with ${prefix}tag): \`\`\`${tagList}\`\`\``); createChunkedMessage(msg.channel, `Available tags (use with ${prefix}tag): \`\`\`${tagList}\`\`\``);
}, },
}); });

View file

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

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