Skip to content

Commit

Permalink
Ensure Bot is only imported as a type
Browse files Browse the repository at this point in the history
Just a quick safety check that we only actually use the `Bot` class
through `getBot` instead of instantiating it.
  • Loading branch information
scotttrinh committed Aug 1, 2024
1 parent 9f978f7 commit 72db027
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/lib/discord/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
InteractionType,
RESTPostAPIApplicationCommandsJSONBody,
} from "discord-api-types/v10";
import {Bot} from "./bot";
import type { Bot } from "./bot";
import commands from "./commands";

export interface Command<Interaction = APIApplicationCommandInteractionData> {
Expand Down
23 changes: 6 additions & 17 deletions app/lib/discord/commands/helpChannels.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
APIApplicationCommand,
APIBaseInteraction,
InteractionType,
APIApplicationCommandInteractionData,
RESTPostAPIApplicationCommandsJSONBody,
PermissionFlagsBits,
ApplicationCommandType,
Expand All @@ -16,11 +14,10 @@ import {
MessageFlags,
InteractionResponseType,
} from "discord-api-types/v10";
import {Bot} from "../bot";
import {Command} from "../command";
import {getHelpChannels} from "../queries/getHelpChannels.query";
import {addHelpChannel} from "../queries/addHelpChannel.query";
import {removeHelpChannel} from "../queries/removeHelpChannel.query";
import type { Bot } from "../bot";
import { Command } from "../command";
import { addHelpChannel } from "../queries/addHelpChannel.query";
import { removeHelpChannel } from "../queries/removeHelpChannel.query";

export default class HelpChannelCommands
implements Command<APIChatInputApplicationCommandInteractionData>
Expand Down Expand Up @@ -140,11 +137,7 @@ export default class HelpChannelCommands
});
break;
case "add": {
const channel = await this.resolveChannel(
bot,
interaction,
subCommand
);
const channel = await this.resolveChannel(bot, interaction, subCommand);

if (bot["help-channels"].has(channel.id)) {
respond({
Expand Down Expand Up @@ -172,11 +165,7 @@ export default class HelpChannelCommands
break;
}
case "remove": {
const channel = await this.resolveChannel(
bot,
interaction,
subCommand
);
const channel = await this.resolveChannel(bot, interaction, subCommand);

if (!bot["help-channels"].has(channel.id)) {
respond({
Expand Down
2 changes: 1 addition & 1 deletion app/lib/discord/commands/helpful.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
RESTPostAPIApplicationCommandsJSONBody,
} from "discord-api-types/v10";
import { Command } from "../command";
import { Bot } from "../bot";
import type { Bot } from "../bot";
import { isHelpfulThread } from "../queries/isHelpfulThread.query";
import downloadThreadMessages from "../utils/downloadThread";
import { suggestThread } from "../queries/suggestThread.query";
Expand Down
2 changes: 1 addition & 1 deletion app/lib/discord/utils/downloadThread.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { APIMessage, APIThreadChannel, Routes } from "discord-api-types/v10";
import { Bot } from "../bot";
import type { Bot } from "../bot";

const downloadingInProgress = new Set<string>();

Expand Down
2 changes: 1 addition & 1 deletion app/lib/discord/utils/reviewCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
APIThreadChannel,
Routes,
} from "discord-api-types/v10";
import { Bot } from "../bot";
import type { Bot } from "../bot";
import { SuggestThreadReturns } from "../queries/suggestThread.query";
import { getEnvironment } from "../../../../envs";

Expand Down

0 comments on commit 72db027

Please sign in to comment.