ping watch role when voting starts and closes
This commit is contained in:
parent
baefcf9bb9
commit
198a25d145
@ -61,15 +61,16 @@ export async function closePoll(guild: Guild, requestId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateMessage(movie: string, message: Message, guildId: string, requestId: string) {
|
async function updateMessage(movie: string, message: Message, guildId: string, requestId: string) {
|
||||||
|
const role = (await message.guild!.roles.fetch()).find(role => role.id === config.bot.announcement_role)
|
||||||
const body = `[Abstimmung beendet] Gewonnen hat: ${movie}`
|
const body = `[Abstimmung beendet] Gewonnen hat: ${movie}`
|
||||||
.concat(message.cleanContent.substring("[Abstimmung]".length))
|
.concat(message.content.substring("[Abstimmung]".length))
|
||||||
|
|
||||||
const options: MessageEditOptions = {
|
const options: MessageEditOptions = {
|
||||||
content: body,
|
content: body,
|
||||||
|
allowedMentions: { parse: ["roles"] }
|
||||||
}
|
}
|
||||||
logger.info("Updating message.", { guildId, requestId })
|
logger.info("Updating message.", { guildId, requestId })
|
||||||
message.edit(options)
|
message.edit(options)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateEvent(votes: Vote[], guild: Guild, guildId: string, requestId: string) {
|
async function updateEvent(votes: Vote[], guild: Guild, guildId: string, requestId: string) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { GuildScheduledEvent, Message, TextChannel } from "discord.js";
|
import { GuildScheduledEvent, Message, MessageCreateOptions, TextChannel } from "discord.js";
|
||||||
import { ScheduledTask, schedule } from "node-cron";
|
import { ScheduledTask, schedule } from "node-cron";
|
||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
import { client, jellyfinHandler } from "../..";
|
import { client, jellyfinHandler } from "../..";
|
||||||
@ -30,14 +30,20 @@ export async function execute(event: GuildScheduledEvent) {
|
|||||||
|
|
||||||
const announcementChannel: TextChannel = client.getAnnouncementChannelForGuild(event.guildId)
|
const announcementChannel: TextChannel = client.getAnnouncementChannelForGuild(event.guildId)
|
||||||
logger.debug(`Found channel ${JSON.stringify(announcementChannel, null, 2)}`, { guildId: event.guildId, requestId })
|
logger.debug(`Found channel ${JSON.stringify(announcementChannel, null, 2)}`, { guildId: event.guildId, requestId })
|
||||||
|
const role = (await event.guild!.roles.fetch()).find(role => role.id === config.bot.announcement_role)
|
||||||
|
|
||||||
let message = "[Abstimmung]\nEs gibt eine neue Abstimmung für die nächste Watchparty! Stimme hierunter für den nächsten Film ab!\n"
|
let message = `[Abstimmung]\n<@&${role ? role.id : "hab die Rolle nicht gefunden"}> Es 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++) {
|
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 announcementChannel.fetch()).send(message)
|
const options: MessageCreateOptions = {
|
||||||
|
allowedMentions: { parse: ["roles"]},
|
||||||
|
content: message
|
||||||
|
}
|
||||||
|
|
||||||
|
const sentMessage: Message<true> = await (await announcementChannel.fetch()).send(options)
|
||||||
|
|
||||||
for (let i = 0; i < movies.length; i++) {
|
for (let i = 0; i < movies.length; i++) {
|
||||||
sentMessage.react(Emotes[i])
|
sentMessage.react(Emotes[i])
|
||||||
|
Loading…
Reference in New Issue
Block a user