mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 17:45:03 +00:00
fix typings lole
This commit is contained in:
parent
bf086f8a91
commit
7855c49cd4
1 changed files with 9 additions and 4 deletions
|
@ -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<StarboardPluginType>,
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue