Compare commits

..

No commits in common. "8a06a661fa93d1e2c1fd006e11239d1e2e1f50e5" and "e7b21fa658c5320974e1099127cc760716c05378" have entirely different histories.

5 changed files with 106 additions and 106 deletions

View File

@ -3,5 +3,5 @@ root = true
indent_size = 2
indent_style = space
[*.ts]
indent_style = tab
tab_width = 4
indent_size = 2
indent_style = space

View File

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

View File

@ -2,73 +2,73 @@ import dotenv from "dotenv"
dotenv.config()
interface options {
[k: string]: boolean | number | string | undefined
[k: string]: boolean | number | string | undefined
}
interface bodyParserOptions {
urlEncodedOptions: options,
jsonOptions: options
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
}
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
}
}
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 ?? "",
watcher_role: process.env.WATCHER_ROLE ?? "",
jf_admin_role: process.env.ADMIN_ROLE ?? "",
announcement_role: process.env.WATCHPARTY_ANNOUNCEMENT_ROLE ?? "",
announcement_channel_id: process.env.CHANNEL_ID ?? "",
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 ?? ""
}
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 ?? "",
watcher_role: process.env.WATCHER_ROLE ?? "",
jf_admin_role: process.env.ADMIN_ROLE ?? "",
announcement_role: process.env.WATCHPARTY_ANNOUNCEMENT_ROLE ?? "",
announcement_channel_id: process.env.CHANNEL_ID ?? "",
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 ?? ""
}
}

View File

@ -3,39 +3,39 @@ import { Role } from "discord.js"
export type Maybe<T> = T | undefined | null
export interface Player {
name: string
name: string
}
export type supported_languages = "german" | "english"
export interface localized_string {
[k: string]: {
[k in supported_languages]: string
}
[k: string]: {
[k in supported_languages]: string
}
}
export class CustomError extends Error {
private code: string
public constructor(message: string, errorCode: string) {
super(message)
this.code = errorCode
}
public getCode() { return this.code }
private code: string
public constructor(message: string, errorCode: string) {
super(message)
this.code = errorCode
}
public getCode() { return this.code }
}
export const errorCodes = {
no_end_date: 'no_end_date',
no_string_present: 'no_string_present',
no_schedule: 'no_schedule',
schedule_not_supported: 'schedule_not_supported',
no_repetition_amount: 'no_repetition_amount',
invalid_repetition_string: 'invalid_repetition_string',
no_creator_id: "no_creator_id",
no_end_date: 'no_end_date',
no_string_present: 'no_string_present',
no_schedule: 'no_schedule',
schedule_not_supported: 'schedule_not_supported',
no_repetition_amount: 'no_repetition_amount',
invalid_repetition_string: 'invalid_repetition_string',
no_creator_id: "no_creator_id",
}
export interface ChangedRoles {
addedRoles: Collection<string, Role>
removedRoles: Collection<string, Role>
addedRoles: Collection<string, Role>
removedRoles: Collection<string, Role>
}
export interface JellyfinConfig {
jellyfinUrl: string,
jellyfinToken: string,
movieCollectionId: string,
collectionUser: string
jellyfinUrl: string,
jellyfinToken: string,
movieCollectionId: string,
collectionUser: string
}
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 }) => {
return `[${guildId ?? ''}][${level}][${logTimestamp}][${errorCode ?? ''}][${requestId ?? ''}]:${message}`
return `[${guildId ?? ''}][${level}][${logTimestamp}][${errorCode ?? ''}][${requestId ?? ''}]:${message}`
})
const logFormat = format.combine(
format.timestamp(),
printFn
format.timestamp(),
printFn
)
const consoleTransports = [
new transports.Console({
format: logFormat
})
new transports.Console({
format: logFormat
})
]
export const logger = createLogger({
level: config.bot.debug ? 'debug' : 'info',
format: logFormat,
silent: config.bot.silent,
transports: consoleTransports
level: config.bot.debug ? 'debug' : 'info',
format: logFormat,
silent: config.bot.silent,
transports: consoleTransports
})