Open open-game-nexusmods in Script Kit

/*
# Open game page in nexusmods.com
Lets the user select and open the page of a game in [nexusmods.com](https://www.nexusmods.com/).
*/
// Name: Open game page in nexusmods.com
// Description: Lets the user select and open the page of a game in nexusmods.com.
// Author: Ricardo Gonçalves Bassete
import '@johnlindquist/kit'
interface Category {
category_id: number
name: string
parent_category: boolean | number
}
interface Game {
approved_date: number
authors: number
categories: Category[]
domain_name: string
downloads: number
file_count: number
file_endorsements: number
file_views: number
forum_url: string
genre: string
id: number
mods: number
name: string
nexusmods_url: string
}
const GAMES_API = 'https://api.nexusmods.com/v1/games.json'
const API_KEY = await env('NEXUSMODS_API_KEY', {
panel: md(`## Get a [Nexus Mods Personal API Key](https://next.nexusmods.com/settings/api-keys)`),
ignoreBlur: true,
secret: true,
})
const { data } = await get<Game[]>(GAMES_API, {
headers: {
accept: 'application/json',
apikey: API_KEY,
},
})
const target = await arg({
placeholder: 'Select Game',
choices: data.map(game => {
return {
name: game.name,
description: game.nexusmods_url,
value: game.nexusmods_url,
img: `https://staticdelivery.nexusmods.com/Images/games/4_3/tile_${game.id}.jpg`,
height: 250,
}
}),
})
open(target)