From df1b9275ef7007e7e3b16bef403aaa8a181d64cb Mon Sep 17 00:00:00 2001 From: Declan Chidlow Date: Fri, 9 Aug 2024 13:51:43 +0800 Subject: [PATCH] Consistent type imports and exports for bot --- bot/src/bot/commands/configuration/login.ts | 2 +- bot/src/bot/commands/moderation/ban.ts | 2 +- bot/src/bot/commands/moderation/kick.ts | 2 +- bot/src/bot/commands/moderation/votekick.ts | 2 +- bot/src/bot/commands/moderation/warn.ts | 2 +- bot/src/bot/modules/api/server_details.ts | 5 +++-- bot/src/bot/modules/api/servers.ts | 3 ++- bot/src/bot/modules/api/users.ts | 5 +++-- bot/src/bot/modules/api_communication.ts | 3 ++- bot/src/bot/modules/event_handler.ts | 2 +- bot/src/bot/util.ts | 2 +- bot/src/index.ts | 2 +- bot/src/struct/AutomodClient.ts | 2 +- bot/src/struct/MessageCommandContext.ts | 6 ++++++ 14 files changed, 25 insertions(+), 15 deletions(-) diff --git a/bot/src/bot/commands/configuration/login.ts b/bot/src/bot/commands/configuration/login.ts index 3b9f977..70d91ee 100644 --- a/bot/src/bot/commands/configuration/login.ts +++ b/bot/src/bot/commands/configuration/login.ts @@ -1,4 +1,4 @@ -import { FindOneResult } from "monk"; +import type { FindOneResult } from "monk"; import { dbs } from "../../.."; import CommandCategory from "../../../struct/commands/CommandCategory"; import SimpleCommand from "../../../struct/commands/SimpleCommand"; diff --git a/bot/src/bot/commands/moderation/ban.ts b/bot/src/bot/commands/moderation/ban.ts index 0c4e11b..5ec7c18 100644 --- a/bot/src/bot/commands/moderation/ban.ts +++ b/bot/src/bot/commands/moderation/ban.ts @@ -23,7 +23,7 @@ import { import Day from "dayjs"; import RelativeTime from "dayjs/plugin/relativeTime"; import CommandCategory from "../../../struct/commands/CommandCategory"; -import { SendableEmbed } from "revolt-api"; +import type { SendableEmbed } from "revolt-api"; import { User } from "revolt.js"; import logger from "../../logger"; diff --git a/bot/src/bot/commands/moderation/kick.ts b/bot/src/bot/commands/moderation/kick.ts index dd1e439..6922fdf 100644 --- a/bot/src/bot/commands/moderation/kick.ts +++ b/bot/src/bot/commands/moderation/kick.ts @@ -1,5 +1,5 @@ import { User } from "revolt.js"; -import { SendableEmbed } from "revolt-api"; +import type { SendableEmbed } from "revolt-api"; import { ulid } from "ulid"; import { client } from "../../../"; import Infraction from "automod/dist/types/antispam/Infraction"; diff --git a/bot/src/bot/commands/moderation/votekick.ts b/bot/src/bot/commands/moderation/votekick.ts index 06304bb..a20c65b 100644 --- a/bot/src/bot/commands/moderation/votekick.ts +++ b/bot/src/bot/commands/moderation/votekick.ts @@ -114,4 +114,4 @@ export default { } } as SimpleCommand; -export { VoteEntry } +export type { VoteEntry } diff --git a/bot/src/bot/commands/moderation/warn.ts b/bot/src/bot/commands/moderation/warn.ts index 001cbe2..8f92e1e 100644 --- a/bot/src/bot/commands/moderation/warn.ts +++ b/bot/src/bot/commands/moderation/warn.ts @@ -5,7 +5,7 @@ import { ulid } from "ulid"; import InfractionType from "automod/dist/types/antispam/InfractionType"; import { fetchUsername, logModAction } from "../../modules/mod_logs"; import CommandCategory from "../../../struct/commands/CommandCategory"; -import { SendableEmbed } from "revolt-api"; +import type { SendableEmbed } from "revolt-api"; import { User } from "revolt.js"; import logger from "../../logger"; diff --git a/bot/src/bot/modules/api/server_details.ts b/bot/src/bot/modules/api/server_details.ts index 564cb8c..e12e950 100644 --- a/bot/src/bot/modules/api/server_details.ts +++ b/bot/src/bot/modules/api/server_details.ts @@ -3,7 +3,8 @@ import { User } from "revolt.js"; import { client, dbs } from "../../.."; import ServerConfig from "automod/dist/types/ServerConfig"; import { getPermissionLevel } from "../../util"; -import { wsEvents, WSResponse } from "../api_communication"; +import type { WSResponse } from "../api_communication"; +import { wsEvents } from "../api_communication"; type ReqData = { user: string, server: string } type APIUser = { id: string, username?: string, avatarURL?: string } @@ -95,4 +96,4 @@ wsEvents.on('req:getUserServerDetails', async (data: ReqData, cb: (data: WSRespo } }); -export { APIUser } +export type { APIUser } diff --git a/bot/src/bot/modules/api/servers.ts b/bot/src/bot/modules/api/servers.ts index 07fbd9e..48b67cd 100644 --- a/bot/src/bot/modules/api/servers.ts +++ b/bot/src/bot/modules/api/servers.ts @@ -1,7 +1,8 @@ import { User } from 'revolt.js'; import { client } from '../../..'; import { getMutualServers, getPermissionLevel } from '../../util'; -import { wsEvents, WSResponse } from '../api_communication'; +import type { WSResponse } from "../api_communication"; +import { wsEvents } from "../api_communication"; type ReqData = { user: string } diff --git a/bot/src/bot/modules/api/users.ts b/bot/src/bot/modules/api/users.ts index ff96228..a2b1781 100644 --- a/bot/src/bot/modules/api/users.ts +++ b/bot/src/bot/modules/api/users.ts @@ -1,8 +1,9 @@ import { User } from "revolt.js"; import { client } from "../../.."; import { getPermissionLevel, parseUser } from "../../util"; -import { wsEvents, WSResponse } from "../api_communication"; -import { APIUser } from "./server_details"; +import type { WSResponse } from "../api_communication"; +import { wsEvents } from "../api_communication"; +import type { APIUser } from "./server_details"; wsEvents.on('req:getPermissionLevel', async (data: { user: string, server: string }, cb: (data: WSResponse) => void) => { try { diff --git a/bot/src/bot/modules/api_communication.ts b/bot/src/bot/modules/api_communication.ts index 1efcd0b..54d78f2 100644 --- a/bot/src/bot/modules/api_communication.ts +++ b/bot/src/bot/modules/api_communication.ts @@ -158,7 +158,8 @@ wsEvents.on("req:stats", async (_data: any, cb: (data: { servers: number }) => v cb({ servers }); }); -export { wsEvents, wsSend, WSResponse }; +export { wsEvents, wsSend }; +export type { WSResponse }; import("./api/servers"); import("./api/server_details"); diff --git a/bot/src/bot/modules/event_handler.ts b/bot/src/bot/modules/event_handler.ts index 42062e0..b5e6f28 100644 --- a/bot/src/bot/modules/event_handler.ts +++ b/bot/src/bot/modules/event_handler.ts @@ -7,7 +7,7 @@ import { BLACKLIST_BAN_REASON, BLACKLIST_MESSAGE } from "../commands/admin/botad import logger from "../logger"; import { storeInfraction } from "../util"; import { DEFAULT_PREFIX } from "./command_handler"; -import { SendableEmbed } from "revolt-api"; +import type { SendableEmbed } from "revolt-api"; import { UserSystemMessage } from "revolt.js"; const DM_SESSION_LIFETIME = 1000 * 60 * 60 * 24 * 30; diff --git a/bot/src/bot/util.ts b/bot/src/bot/util.ts index d12d58e..7772b46 100644 --- a/bot/src/bot/util.ts +++ b/bot/src/bot/util.ts @@ -11,7 +11,7 @@ import logger from "./logger"; import { Channel } from "revolt.js"; import { Message } from "revolt.js"; import { isSudo } from "./commands/admin/botadm"; -import { SendableEmbed } from "revolt-api"; +import type { SendableEmbed } from "revolt-api"; import ServerConfig from "automod/dist/types/ServerConfig"; const NO_MANAGER_MSG = "🔒 Missing permission"; diff --git a/bot/src/index.ts b/bot/src/index.ts index 527d3db..8c15845 100644 --- a/bot/src/index.ts +++ b/bot/src/index.ts @@ -9,7 +9,7 @@ import ServerConfig from 'automod/dist/types/ServerConfig'; import Infraction from 'automod/dist/types/antispam/Infraction'; import PendingLogin from 'automod/dist/types/PendingLogin'; import TempBan from 'automod/dist/types/TempBan'; -import { VoteEntry } from './bot/commands/moderation/votekick'; +import type { VoteEntry } from './bot/commands/moderation/votekick'; logger.info('Initializing client'); diff --git a/bot/src/struct/AutomodClient.ts b/bot/src/struct/AutomodClient.ts index 3e3849f..d023d86 100644 --- a/bot/src/struct/AutomodClient.ts +++ b/bot/src/struct/AutomodClient.ts @@ -1,7 +1,7 @@ import * as Revolt from "revolt.js"; import { IMonkManager } from 'monk'; import logger from '../bot/logger'; -import { ClientOptions } from "revolt.js"; +import type { ClientOptions } from "revolt.js"; class AutomodClient extends Revolt.Client { db: IMonkManager; diff --git a/bot/src/struct/MessageCommandContext.ts b/bot/src/struct/MessageCommandContext.ts index 7a548b2..5fdee1a 100644 --- a/bot/src/struct/MessageCommandContext.ts +++ b/bot/src/struct/MessageCommandContext.ts @@ -4,6 +4,12 @@ import { Server } from "revolt.js"; class MessageCommandContext extends Message { // The server to which the command should be applied. serverContext: Server; + + constructor(messageData: any, channelData: any, serverContext: Server) { + // Assuming `Message` expects `messageData` and `channelData` as its arguments. + super(messageData, channelData); + this.serverContext = serverContext; + } } export default MessageCommandContext;