From 5b98c9bf2fe955d09ef8d7be50d24988ec5b09a1 Mon Sep 17 00:00:00 2001 From: Sammy Date: Fri, 23 Jun 2023 14:37:29 +0200 Subject: [PATCH] Rename event files to specific case We can add multiple eventhandlers per eventname. To avoid confusion and large files and to improve concise file names the event files were renamed --- server/commands/closepoll.ts | 2 +- server/events/announceManualWatchparty.ts | 26 +++++++++++++++++++ ...ntCreate.ts => autoCreateVoteByWPEvent.ts} | 3 +-- ...Update.ts => handlePermJFAccountByRole.ts} | 0 ...ate.ts => handleTempJFUserByVoiceEvent.ts} | 0 ...date.ts => handleTempJFUsersByWPEvents.ts} | 0 6 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 server/events/announceManualWatchparty.ts rename server/events/{guildScheduledEventCreate.ts => autoCreateVoteByWPEvent.ts} (96%) rename server/events/{guildMemberUpdate.ts => handlePermJFAccountByRole.ts} (100%) rename server/events/{voiceStateUpdate.ts => handleTempJFUserByVoiceEvent.ts} (100%) rename server/events/{guildScheduledEventUpdate.ts => handleTempJFUsersByWPEvents.ts} (100%) diff --git a/server/commands/closepoll.ts b/server/commands/closepoll.ts index ff3dfd8..8d0a3ba 100644 --- a/server/commands/closepoll.ts +++ b/server/commands/closepoll.ts @@ -3,7 +3,7 @@ import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildSchedu import { v4 as uuid } from 'uuid' import { client } from '../..' import { config } from '../configuration' -import { Emotes } from '../events/guildScheduledEventCreate' +import { Emotes } from '../events/autoCreateVoteByWPEvent' import { Maybe } from '../interfaces' import { logger } from '../logger' import { Command } from '../structures/command' diff --git a/server/events/announceManualWatchparty.ts b/server/events/announceManualWatchparty.ts new file mode 100644 index 0000000..e5b0e8f --- /dev/null +++ b/server/events/announceManualWatchparty.ts @@ -0,0 +1,26 @@ +import { format } from "date-fns"; +import { GuildScheduledEvent, Message, MessageCreateOptions, TextChannel } from "discord.js"; +import { ScheduledTask } from "node-cron"; +import { v4 as uuid } from "uuid"; +import { client, yavinJellyfinHandler } from "../.."; +import { config } from "../configuration"; +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() + + if(event.description?.includes("!wp")) { + logger.info("Got manual create event of watchparty event!") + + + + + + } + +} \ No newline at end of file diff --git a/server/events/guildScheduledEventCreate.ts b/server/events/autoCreateVoteByWPEvent.ts similarity index 96% rename from server/events/guildScheduledEventCreate.ts rename to server/events/autoCreateVoteByWPEvent.ts index 74071b2..5ea0e5f 100644 --- a/server/events/guildScheduledEventCreate.ts +++ b/server/events/autoCreateVoteByWPEvent.ts @@ -17,8 +17,7 @@ export let task: ScheduledTask | undefined export async function execute(event: GuildScheduledEvent) { const requestId = uuid() - logger.debug(`New event created: ${JSON.stringify(event, null, 2)}`, { guildId: event.guildId, requestId }) - + if (event.name.toLowerCase().includes("!nextwp")) { logger.info("Event was a placeholder event to start a new watchparty and voting. Creating vote!", { guildId: event.guildId, requestId }) logger.debug("Renaming event", { guildId: event.guildId, requestId }) diff --git a/server/events/guildMemberUpdate.ts b/server/events/handlePermJFAccountByRole.ts similarity index 100% rename from server/events/guildMemberUpdate.ts rename to server/events/handlePermJFAccountByRole.ts diff --git a/server/events/voiceStateUpdate.ts b/server/events/handleTempJFUserByVoiceEvent.ts similarity index 100% rename from server/events/voiceStateUpdate.ts rename to server/events/handleTempJFUserByVoiceEvent.ts diff --git a/server/events/guildScheduledEventUpdate.ts b/server/events/handleTempJFUsersByWPEvents.ts similarity index 100% rename from server/events/guildScheduledEventUpdate.ts rename to server/events/handleTempJFUsersByWPEvents.ts