Skip to content

Commit

Permalink
Fix: country can be undefined apparently
Browse files Browse the repository at this point in the history
  • Loading branch information
cbackas committed Apr 10, 2024
1 parent 8c59441 commit dbedad6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/commands/unlink.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ActionRowBuilder, type AnySelectMenuInteraction, ChannelType, type ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder, SlashCommandSubcommandBuilder, StringSelectMenuBuilder, type TextBasedChannel } from 'discord.js'
import client from '../lib/prisma'
import client from 'lib/prisma'
import { type CommandV2 } from '../interfaces/command'
import { type App } from '../app'
import { ProgressError } from '../interfaces/error'
import { ProgressMessageBuilder } from '../lib/progressMessages'
import { pruneUnsubscribedShows } from 'src/lib/shows'
import { ProgressMessageBuilder } from 'lib/progressMessages'
import { pruneUnsubscribedShows } from 'lib/shows'

export const command: CommandV2 = {
slashCommand: {
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/tvdb.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export interface Character {
}

/** A company record */
export type Company = Required<{
export type Company = {
activeDate?: string;
aliases?: Alias[];
country?: string;
Expand All @@ -214,7 +214,7 @@ export type Company = Required<{
/** A parent company record */
parentCompany?: ParentCompany;
tagOptions?: TagOption[];
}>
}

/** A parent company record */
export interface ParentCompany {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { type APIEmbed, type APIEmbedField } from 'discord.js'
import { type SeriesExtendedRecord } from '../interfaces/tvdb.generated'

export function buildShowEmbed (imdbId: string, tvdbSeries: SeriesExtendedRecord, destinations: Destination[] = []): APIEmbed {
const country = tvdbSeries.latestNetwork.country ?? 'usa'

// put together some basic data fields
const fields: APIEmbedField[] = [
{
name: 'Network',
value: `${tvdbSeries.latestNetwork.name} (${tvdbSeries.latestNetwork.country.toUpperCase()})`,
value: `${tvdbSeries.latestNetwork.name ?? 'unknown'} (${country.toUpperCase()})`,
inline: true
},
{
Expand Down
3 changes: 1 addition & 2 deletions src/lib/shows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export async function updateEpisodes (imdbId: string, tvdbId: number, providedSe
throw new Error(`Could not fetch series data for ${imdbId}`)
}

// const series = await getSeries(tvdbId)
const timezone = getTimezone(series.latestNetwork.country)
const timezone = getTimezone(series.latestNetwork.country ?? 'usa')
const airsTime = series.airsTime

// filter out episodes that have already aired
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
"*": [
"node_modules/*",
"src/types/*"
],
"lib/*": [
"src/lib/*"
]
}
},
"include": [
"src/**/*",
"index.ts"
]
}
}

0 comments on commit dbedad6

Please sign in to comment.