Add automatic creation of vote message with random movies #16
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kenobi/jellyfin-discord-bot#16
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feat/voting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When a !nextwp event is created the bot will fetch random movies and create a message that people can vote on
WIP! Add automatic creation of vote message with random moviesto [WIP] Add automatic creation of vote message with random moviescloses #6
[WIP] Add automatic creation of vote message with random moviesto Add automatic creation of vote message with random moviesVery nice. Only minor suggestions :)
@ -0,0 +28,4 @@
export async function closePoll(guild: Guild, requestId: string) {
const guildId = guild.id
logger.info("stopping poll", { guildId: guildId, requestId })
As long as the name is identical you can just use
{guild,requestId}
This gets translated to
{guildId:guildId, requestId:requestId}
Fixed on all occasions I found
@ -0,0 +50,4 @@
return
}
const lastMessage: Message<true> = messages[0]
What does the
true
signify in this type?True means that it's a guild message afaik and understand the library
@ -0,0 +92,4 @@
}
const voteEvent: GuildScheduledEvent<GuildScheduledEventStatus> = voteEvents[0]
const options: GuildScheduledEventEditOptions<GuildScheduledEventStatus.Scheduled, GuildScheduledEventSetStatusArg<GuildScheduledEventStatus.Scheduled>> = {
My EYES!
Sorry :( That's what you get with typing I guess?
All good :)
@ -0,0 +26,4 @@
logger.info(`Got ${movies.length} random movies. Creating voting`, { guildId: event.guildId, requestId })
logger.debug(`Movies: ${JSON.stringify(movies.map(movie => movie.name))}`, { guildId: event.guildId, requestId })
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
Might present a good reason to fetch this channel during boot and keep it in a constant, so these kinds of searches don't have to be performed more than once.
fixed
@ -0,0 +73,4 @@
logger.error("Event does not have a scheduled start time. Cancelling", { guildId: event.guildId, requestId })
return
}
if ((updatedEvent.scheduledStartTimestamp - Date.now()) <= (1000 * 60 * 60 * 24 * 2)) {
The npm library date-fns has some very nice functions for date manipulation.
It has superseded Moment.js in almost all cases
fixed
@ -226,0 +236,4 @@
const searchParams: GetItemsRequest = {
userId: liloJfUser?.id,
parentId: "f137a2dd21bbc1b99aa5c0f6bf02a805" // collection ID for all movies
Might be best served as an env var.
fixed