adjust some files to new formatting
All checks were successful
Compile the repository / compile (pull_request) Successful in 1m28s

This commit is contained in:
mightypanders 2023-06-24 21:05:43 +02:00
parent 4084f675cd
commit 8a06a661fa
4 changed files with 104 additions and 104 deletions

View File

@ -13,13 +13,13 @@ export const client = new ExtendedClient(jellyfinHandler)
export const attachmentImages = attachedImages export const attachmentImages = attachedImages
async function init() { async function init() {
try { try {
const users = await jellyfinHandler.getCurrentUsers("", requestId) const users = await jellyfinHandler.getCurrentUsers("", requestId)
logger.info(`Fetched ${users.map(x => x.name).join(', ')} from JF`, { requestId }) logger.info(`Fetched ${users.map(x => x.name).join(', ')} from JF`, { requestId })
} catch (error) { } catch (error) {
logger.error(`Error fetching existing users from Jellyfin`, { requestId }) logger.error(`Error fetching existing users from Jellyfin`, { requestId })
} }
logger.info(`Starting client`, { requestId }) logger.info(`Starting client`, { requestId })
client.start() client.start()
} }
init() init()

View File

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

View File

@ -3,39 +3,39 @@ import { Role } from "discord.js"
export type Maybe<T> = T | undefined | null export type Maybe<T> = T | undefined | null
export interface Player { export interface Player {
name: string name: string
} }
export type supported_languages = "german" | "english" export type supported_languages = "german" | "english"
export interface localized_string { export interface localized_string {
[k: string]: { [k: string]: {
[k in supported_languages]: string [k in supported_languages]: string
} }
} }
export class CustomError extends Error { export class CustomError extends Error {
private code: string private code: string
public constructor(message: string, errorCode: string) { public constructor(message: string, errorCode: string) {
super(message) super(message)
this.code = errorCode this.code = errorCode
} }
public getCode() { return this.code } public getCode() { return this.code }
} }
export const errorCodes = { export const errorCodes = {
no_end_date: 'no_end_date', no_end_date: 'no_end_date',
no_string_present: 'no_string_present', no_string_present: 'no_string_present',
no_schedule: 'no_schedule', no_schedule: 'no_schedule',
schedule_not_supported: 'schedule_not_supported', schedule_not_supported: 'schedule_not_supported',
no_repetition_amount: 'no_repetition_amount', no_repetition_amount: 'no_repetition_amount',
invalid_repetition_string: 'invalid_repetition_string', invalid_repetition_string: 'invalid_repetition_string',
no_creator_id: "no_creator_id", no_creator_id: "no_creator_id",
} }
export interface ChangedRoles { export interface ChangedRoles {
addedRoles: Collection<string, Role> addedRoles: Collection<string, Role>
removedRoles: Collection<string, Role> removedRoles: Collection<string, Role>
} }
export interface JellyfinConfig { export interface JellyfinConfig {
jellyfinUrl: string, jellyfinUrl: string,
jellyfinToken: string, jellyfinToken: string,
movieCollectionId: string, movieCollectionId: string,
collectionUser: string collectionUser: string
} }
export type PermissionLevel = "VIEWER" | "ADMIN" | "TEMPORARY" export type PermissionLevel = "VIEWER" | "ADMIN" | "TEMPORARY"

View File

@ -3,22 +3,22 @@ import { config } from "./configuration"
const printFn = format.printf(({ guildId, level, message, errorCode, requestId, timestamp: logTimestamp }: { [k: string]: string }) => { const printFn = format.printf(({ guildId, level, message, errorCode, requestId, timestamp: logTimestamp }: { [k: string]: string }) => {
return `[${guildId ?? ''}][${level}][${logTimestamp}][${errorCode ?? ''}][${requestId ?? ''}]:${message}` return `[${guildId ?? ''}][${level}][${logTimestamp}][${errorCode ?? ''}][${requestId ?? ''}]:${message}`
}) })
const logFormat = format.combine( const logFormat = format.combine(
format.timestamp(), format.timestamp(),
printFn printFn
) )
const consoleTransports = [ const consoleTransports = [
new transports.Console({ new transports.Console({
format: logFormat format: logFormat
}) })
] ]
export const logger = createLogger({ export const logger = createLogger({
level: config.bot.debug ? 'debug' : 'info', level: config.bot.debug ? 'debug' : 'info',
format: logFormat, format: logFormat,
silent: config.bot.silent, silent: config.bot.silent,
transports: consoleTransports transports: consoleTransports
}) })