Add automatic creation of vote message with random movies #16

Merged
kenobi merged 11 commits from feat/voting into master 2023-06-12 21:00:17 +02:00
Collaborator

When a !nextwp event is created the bot will fetch random movies and create a message that people can vote on

When a !nextwp event is created the bot will fetch random movies and create a message that people can vote on
magnetotail added 1 commit 2023-06-10 14:24:35 +02:00
When a !nextwp event is created the bot will fetch random movies and create a message that people can vote on
magnetotail changed title from WIP! Add automatic creation of vote message with random movies to [WIP] Add automatic creation of vote message with random movies 2023-06-10 14:24:54 +02:00
magnetotail added 1 commit 2023-06-10 17:29:28 +02:00
Author
Collaborator

closes #6

closes #6
magnetotail changed title from [WIP] Add automatic creation of vote message with random movies to Add automatic creation of vote message with random movies 2023-06-10 17:31:01 +02:00
magnetotail requested review from kenobi 2023-06-10 17:31:14 +02:00
magnetotail added 2 commits 2023-06-10 22:58:25 +02:00
magnetotail added 1 commit 2023-06-11 09:02:01 +02:00
in closepoll.ts was an unsafe arrays usage without checking the bounds
magnetotail added 1 commit 2023-06-11 09:12:38 +02:00
magnetotail added 1 commit 2023-06-11 15:44:20 +02:00
Somehow I thought it was necessary because the compiler said it at some point
kenobi approved these changes 2023-06-12 19:02:26 +02:00
kenobi left a comment
Owner

Very nice. Only minor suggestions :)

Very 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 })
Owner

As long as the name is identical you can just use
{guild,requestId}
This gets translated to {guildId:guildId, requestId:requestId}

As long as the name is identical you can just use `{guild,requestId}` This gets translated to `{guildId:guildId, requestId:requestId}`
Author
Collaborator

Fixed on all occasions I found

Fixed on all occasions I found
kenobi marked this conversation as resolved
@ -0,0 +50,4 @@
return
}
const lastMessage: Message<true> = messages[0]
Owner

What does the true signify in this type?

What does the `true` signify in this type?
Author
Collaborator

True means that it's a guild message afaik and understand the library

True means that it's a guild message afaik and understand the library
kenobi marked this conversation as resolved
@ -0,0 +92,4 @@
}
const voteEvent: GuildScheduledEvent<GuildScheduledEventStatus> = voteEvents[0]
const options: GuildScheduledEventEditOptions<GuildScheduledEventStatus.Scheduled, GuildScheduledEventSetStatusArg<GuildScheduledEventStatus.Scheduled>> = {
Owner

My EYES!

My EYES!
Author
Collaborator

Sorry :( That's what you get with typing I guess?

Sorry :( That's what you get with typing I guess?
Owner

All good :)

All good :)
kenobi marked this conversation as resolved
@ -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
Owner

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.

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.
Author
Collaborator

fixed

fixed
kenobi marked this conversation as resolved
@ -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)) {
Owner

The npm library date-fns has some very nice functions for date manipulation.
It has superseded Moment.js in almost all cases

The npm library date-fns has some very nice functions for date manipulation. It has superseded Moment.js in almost all cases
Author
Collaborator

fixed

fixed
kenobi marked this conversation as resolved
@ -226,0 +236,4 @@
const searchParams: GetItemsRequest = {
userId: liloJfUser?.id,
parentId: "f137a2dd21bbc1b99aa5c0f6bf02a805" // collection ID for all movies
Owner

Might be best served as an env var.

Might be best served as an env var.
Author
Collaborator

fixed

fixed
kenobi marked this conversation as resolved
magnetotail added 1 commit 2023-06-12 19:44:30 +02:00
magnetotail added 3 commits 2023-06-12 20:36:24 +02:00
magnetotail requested review from kenobi 2023-06-12 20:37:56 +02:00
kenobi approved these changes 2023-06-12 20:57:29 +02:00
kenobi merged commit acc38fdcb0 into master 2023-06-12 21:00:17 +02:00
kenobi deleted branch feat/voting 2023-06-12 21:00:17 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kenobi/jellyfin-discord-bot#16
No description provided.