feat/40-reroll-on-disinterest #54
@ -6,6 +6,7 @@ import { Maybe } from '../interfaces'
|
||||
import { logger } from '../logger'
|
||||
import { Command } from '../structures/command'
|
||||
import { RunOptions } from '../types/commandTypes'
|
||||
import { messageIsInitialAnnouncement } from '../helper/messageIdentifiers'
|
||||
|
||||
export default new Command({
|
||||
name: 'announce',
|
||||
@ -61,7 +62,7 @@ async function sendInitialAnnouncement(guildId: string, requestId: string): Prom
|
||||
return
|
||||
}
|
||||
|
||||
const currentPinnedAnnouncementMessages = (await announcementChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[initial]"))
|
||||
const currentPinnedAnnouncementMessages = (await announcementChannel.messages.fetchPinned()).filter(message => messageIsInitialAnnouncement(message))
|
||||
currentPinnedAnnouncementMessages.forEach(async (message) => await message.unpin())
|
||||
currentPinnedAnnouncementMessages.forEach(message => message.delete())
|
||||
|
||||
|
@ -8,6 +8,7 @@ import { Maybe } from '../interfaces'
|
||||
import { logger } from '../logger'
|
||||
import { Command } from '../structures/command'
|
||||
import { RunOptions } from '../types/commandTypes'
|
||||
import { messageIsVoteEndedMessage, messageIsVoteMessage } from '../helper/messageIdentifiers'
|
||||
|
||||
export default new Command({
|
||||
name: 'closepoll',
|
||||
@ -41,7 +42,7 @@ export async function closePoll(guild: Guild, requestId: string) {
|
||||
|
||||
const messages: Message<true>[] = (await announcementChannel.messages.fetch()) //todo: fetch only pinned messages
|
||||
.map((value) => value)
|
||||
.filter(message => !message.cleanContent.includes("[Abstimmung beendet]") && message.cleanContent.includes("[Abstimmung]"))
|
||||
.filter(message => !messageIsVoteEndedMessage(message) && messageIsVoteMessage(message))
|
||||
.sort((a, b) => b.createdTimestamp - a.createdTimestamp)
|
||||
|
||||
if (!messages || messages.length <= 0) {
|
||||
|
@ -2,6 +2,7 @@ import { Collection, GuildScheduledEvent, GuildScheduledEventStatus, Message } f
|
||||
import { v4 as uuid } from "uuid";
|
||||
import { client } from "../..";
|
||||
import { logger } from "../logger";
|
||||
import { messageIsInitialAnnouncement } from "../helper/messageIdentifiers";
|
||||
|
||||
|
||||
export const name = 'guildScheduledEventUpdate'
|
||||
@ -25,7 +26,7 @@ export async function execute(oldEvent: GuildScheduledEvent, newEvent: GuildSche
|
||||
|
||||
const events = await newEvent.guild.scheduledEvents.fetch()
|
||||
|
||||
const wpAnnouncements = (await announcementChannel.messages.fetch()).filter(message => !message.cleanContent.includes("[initial]"))
|
||||
const wpAnnouncements = (await announcementChannel.messages.fetch()).filter(message => !messageIsInitialAnnouncement(message))
|
||||
const announcementsWithoutEvent = filterAnnouncementsByPendingWPs(wpAnnouncements, events)
|
||||
logger.info(`Deleting ${announcementsWithoutEvent.length} announcements.`, { guildId, requestId })
|
||||
announcementsWithoutEvent.forEach(message => message.delete())
|
||||
|
@ -9,6 +9,7 @@ import { JellyfinHandler } from "../jellyfin/handler";
|
||||
import { logger } from "../logger";
|
||||
import { CommandType } from "../types/commandTypes";
|
||||
import { checkForPollsToClose } from "../commands/closepoll";
|
||||
import { messageIsInitialAnnouncement } from "../helper/messageIdentifiers";
|
||||
|
||||
|
||||
|
||||
@ -136,7 +137,7 @@ export class ExtendedClient extends Client {
|
||||
}
|
||||
this.announcementRoleHandlerTask.set(guild.id, schedule("*/10 * * * * *", async () => {
|
||||
const requestId = uuid()
|
||||
const messages = (await textChannel.messages.fetchPinned()).filter(message => message.cleanContent.includes("[initial]"))
|
||||
const messages = (await textChannel.messages.fetchPinned()).filter(message => messageIsInitialAnnouncement(message))
|
||||
|
||||
if (messages.size > 1) {
|
||||
logger.error("More than one pinned announcement Messages found. Unable to know which one people react to. Please fix!", { guildId: guild.id, requestId })
|
||||
|
Loading…
Reference in New Issue
Block a user