From 7855c49cd44dfbcdbf0a3728fc7413ee1bbc6839 Mon Sep 17 00:00:00 2001 From: metal Date: Fri, 27 Aug 2021 10:31:39 +0000 Subject: [PATCH] fix typings lole --- .../Starboard/util/removeMessageFromStarboard.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/plugins/Starboard/util/removeMessageFromStarboard.ts b/backend/src/plugins/Starboard/util/removeMessageFromStarboard.ts index 7659f393..4f525ec2 100644 --- a/backend/src/plugins/Starboard/util/removeMessageFromStarboard.ts +++ b/backend/src/plugins/Starboard/util/removeMessageFromStarboard.ts @@ -1,16 +1,21 @@ -import { BaseGuildTextChannel } from "discord.js"; +import { BaseGuildTextChannel, Channel, GuildChannel, NewsChannel, TextChannel } from "discord.js"; +import { GuildPluginData } from "knub"; import { StarboardMessage } from "../../../data/entities/StarboardMessage"; import { noop } from "../../../utils"; +import { StarboardPluginType } from "../types"; -export async function removeMessageFromStarboard(pluginData, msg: StarboardMessage) { +export async function removeMessageFromStarboard( + pluginData: GuildPluginData, + msg: StarboardMessage, +) { // fixes stuck entries on starboard_reactions table after messages being deleted, probably should add a cleanup script for this as well, i.e. DELETE FROM starboard_reactions WHERE message_id NOT IN (SELECT id FROM starboard_messages) await pluginData.state.starboardReactions.deleteAllStarboardReactionsForMessageId(msg.message_id).catch(noop); // just re-do the deletion, i know this isnt clean but i dont care - const channel: BaseGuildTextChannel = await pluginData.client.channels.cache.find( + const channel: Channel | undefined = pluginData.client.channels.cache.find( chan => chan.id === msg.starboard_channel_id, ); - if (!channel || (channel.type !== "GUILD_TEXT" && channel.type !== "GUILD_NEWS")) return; + if (!channel || (!(channel instanceof TextChannel) && !(channel instanceof NewsChannel))) return; const message = await channel.messages.fetch(msg.starboard_message_id); if (!message || !message.deletable) return; await message.delete().catch(noop);