import { GuildScheduledEvent, TextChannel } from "discord.js"; import { v4 as uuid } from "uuid"; import { client } from "../.."; import { config } from "../configuration"; import { createDateStringFromEvent } from "../helper/dateHelper"; import { Maybe } from "../interfaces"; import { logger } from "../logger"; export const name = 'guildScheduledEventCreate' export async function execute(event: GuildScheduledEvent) { const guildId = event.guildId const requestId = uuid() try { if (!event.description) { logger.debug("Got GuildScheduledEventCreate event. But has no description. Aborting.") return } if (event.description.includes("!wp")) { logger.info("Got manual create event of watchparty event!", { guildId, requestId }) const channel: Maybe = client.getAnnouncementChannelForGuild(guildId) if (!channel) { logger.error("Could not obtain announcement channel. Aborting announcement.", { guildId, requestId }) return } const message = `[Watchparty] https://discord.com/events/${event.guildId}/${event.id} \nHey <@&${config.bot.announcement_role}>, wir gucken ${event.name} ${createDateStringFromEvent(event, guildId, requestId)}` channel.send(message) } else { logger.debug("Got GuildScheduledEventCreate event but no !wp in description. Not creating manual wp announcement.") } } catch (error) { // sendFailureDM(error) logger.error(error, { guildId, requestId }) } }