3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Re-enable starboard + fixes (#262)

This commit is contained in:
metal 2021-09-04 17:20:50 +01:00 committed by GitHub
parent 6a45ce67fa
commit a19de26ff1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View file

@ -9,9 +9,6 @@ export const StarboardReactionAddEvt = starboardEvt({
event: "messageReactionAdd",
async listener(meta) {
// FIXME: Temporarily disabled
return;
const pluginData = meta.pluginData;
let msg = meta.args.reaction.message as Message;

View file

@ -5,9 +5,6 @@ export const StarboardReactionRemoveEvt = starboardEvt({
event: "messageReactionRemove",
async listener(meta) {
// FIXME: Temporarily disabled
return;
const boardLock = await meta.pluginData.locks.acquire(allStarboardsLock());
await meta.pluginData.state.starboardReactions.deleteStarboardReaction(
meta.args.reaction.message.id,
@ -21,9 +18,6 @@ export const StarboardReactionRemoveAllEvt = starboardEvt({
event: "messageReactionRemoveAll",
async listener(meta) {
// FIXME: Temporarily disabled
return;
const boardLock = await meta.pluginData.locks.acquire(allStarboardsLock());
await meta.pluginData.state.starboardReactions.deleteAllStarboardReactionsForMessageId(meta.args.message.id);
boardLock.unlock();

View file

@ -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);
}