Re-enable starboard + fixes (#262)
This commit is contained in:
parent
6a45ce67fa
commit
a19de26ff1
3 changed files with 15 additions and 11 deletions
|
@ -1,6 +1,19 @@
|
|||
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) {
|
||||
await pluginData.client.deleteMessage(msg.starboard_channel_id, msg.starboard_message_id).catch(noop);
|
||||
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);
|
||||
|
||||
// this code is now Almeida-certified and no longer ugly :ok_hand: :cake:
|
||||
const channel = pluginData.client.channels.cache.find(c => c.id === msg.starboard_channel_id);
|
||||
if (!channel?.isText()) return;
|
||||
const message = await channel.messages.fetch(msg.starboard_message_id).catch(noop);
|
||||
if (!message?.deletable) return;
|
||||
await message.delete().catch(noop);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue