Add command to close the poll and update the event

This commit is contained in:
2023-06-10 17:27:32 +02:00
parent 2707f7d73b
commit c8fa89ae63
2 changed files with 120 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import { config } from "../configuration";
export const name = 'guildScheduledEventCreate'
const emotes = ["1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟"]
export enum Emotes {"1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟"}
export async function execute(event: GuildScheduledEvent) {
const requestId = uuid()
@ -28,17 +28,18 @@ export async function execute(event: GuildScheduledEvent) {
const channel: TextChannel = <TextChannel>(await event.guild?.channels.fetch())?.filter(channel => channel!.id === config.bot.announcement_channel_id).map((value, _) => value)[0] //todo: needs to be done less sketchy
logger.debug(`Found channel ${JSON.stringify(channel, null, 2)}`)
let message = "Es gibt eine neue Abstimmung für die nächste Watchparty! Stimme hierunter für den nächsten Film ab!\n"
let message = "[Abstimmung]\nEs gibt eine neue Abstimmung für die nächste Watchparty! Stimme hierunter für den nächsten Film ab!\n"
for (let i = 0; i < movies.length; i++) {
message = message.concat(emotes[i]).concat(": ").concat(movies[i].name!).concat("\n")
message = message.concat(Emotes[i]).concat(": ").concat(movies[i].name!).concat("\n")
}
const sentMessage: Message<true> = await (await channel.fetch()).send(message)
for (let i = 0; i < movies.length; i++) {
sentMessage.react(emotes[i])
sentMessage.react(Emotes[i])
}
// sentMessage.pin() //todo: uncomment when bot has permission to pin messages. Also update closepoll.ts to only fetch pinned messages
}
}