import dotenv from "dotenv"
dotenv.config()

interface options {
	[k: string]: boolean | number | string | undefined
}
interface bodyParserOptions {
	urlEncodedOptions: options,
	jsonOptions: options
}
export interface Config {
	server: { bodyParser: bodyParserOptions },
	bot: {
		debug: boolean
		silent: boolean
		token: string
		guild_id: string
		client_id: string
		jellfin_token: string
		jellyfin_url: string
		port: number
		workaround_token: string
		watcher_role: string
		jf_admin_role: string
		announcement_role: string
		announcement_channel_id: string
		jf_collection_id: string
		jf_user: string
		yavin_collection_id: string
		yavin_jellyfin_url: string
		yavin_jellyfin_token: string
		yavin_jellyfin_collection_user: string
		random_movie_count: number
		reroll_retains_top_picks: boolean
	}
}
export const config: Config = {
	server: {
		bodyParser: {
			urlEncodedOptions: {
				inflate: true,
				limit: '5mb',
				type: 'application/x-www-form-urlencoded',
				extended: true,
				parameterLimit: 1000
			},
			jsonOptions: {
				inflate: true,
				limit: '5mb',
				type: 'application/json',
				strict: true
			}
		}
	},
	bot: {
		debug: true,
		silent: false,
		port: 1234,
		token: process.env.BOT_TOKEN ?? "",
		guild_id: process.env.GUILD_ID ?? "",
		client_id: process.env.CLIENT_ID ?? "",
		jellfin_token: process.env.JELLYFIN_TOKEN ?? "",
		jellyfin_url: process.env.JELLYFIN_URL ?? "",
		workaround_token: process.env.TOKEN ?? "TOKEN",
		watcher_role: process.env.WATCHER_ROLE ?? "WATCHER_ROLE",
		jf_admin_role: process.env.ADMIN_ROLE ?? "ADMIN_ROLE",
		announcement_role: process.env.WATCHPARTY_ANNOUNCEMENT_ROLE ?? "ANNOUNCE_ROLE",
		announcement_channel_id: process.env.CHANNEL_ID ?? "ANNOUNCE_CHANNEL",
		jf_collection_id: process.env.JELLYFIN_COLLECTION_ID ?? "",
		yavin_collection_id: process.env.YAVIN_COLLECTION_ID ?? "",
		yavin_jellyfin_url: process.env.YAVIN_JELLYFIN_URL ?? "",
		yavin_jellyfin_token: process.env.YAVIN_TOKEN ?? "",
		yavin_jellyfin_collection_user: process.env.YAVIN_COLLECTION_USER ?? "",
		jf_user: process.env.JELLYFIN_USER ?? "",
		random_movie_count: parseInt(process.env.RANDOM_MOVIE_COUNT ?? "5") ?? 5,
		reroll_retains_top_picks: process.env.REROLL_RETAIN === "true"
	}
}
