improve movie name resolving
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 1m55s
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 1m55s
When creating the poll the bot will now only request movie names instead of movies This improves the errorhandling because the movie names cannot be null Also the movieName function filters empty movienames and will guarantee the requested number of names
This commit is contained in:
@ -242,10 +242,21 @@ export class JellyfinHandler {
|
||||
const index = Math.floor(Math.random() * allMovies.length)
|
||||
movies.push(...allMovies.splice(index, 1)) // maybe out of bounds? ?
|
||||
}
|
||||
|
||||
return movies
|
||||
}
|
||||
|
||||
public async getRandomMovieNames(count: number, guildId: string, requestId: string): Promise<string[]> {
|
||||
logger.info(`${count} random movie names requested`, { guildId, requestId })
|
||||
|
||||
let movieCount = 0
|
||||
let movieNames: string[]
|
||||
do {
|
||||
movieNames = (await this.getRandomMovies(count, guildId, requestId)).filter(movie => movie.name && movie.name.length > 0).map(movie => <string> movie.name)
|
||||
movieCount = movieNames.length
|
||||
} while (movieCount < count)
|
||||
return movieNames
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
export enum UserUpsertResult { enabled, created }
|
||||
|
Reference in New Issue
Block a user