scaffold adduser function
This commit is contained in:
parent
ddefd2ef2a
commit
75aae28cbb
@ -1,13 +1,15 @@
|
|||||||
import { User as DiscordUser } from "discord.js";
|
import { User as DiscordUser } from "discord.js";
|
||||||
import { AuthenticateUserByNameRequest, JellyfinAPI } from "../../jellyfin/api";
|
import { JellyfinHandler } from "../../jellyfin/handler";
|
||||||
import { UserApi } from "../../jellyfin/api/userApi";
|
import { logger } from "../logger";
|
||||||
import { config } from "../configuration";
|
|
||||||
|
|
||||||
export async function add(discordUser: DiscordUser): Promise<any> {
|
|
||||||
const jfUserAPI: UserApi = new UserApi(config.jellyfin_url)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export async function addUser(discordUser: DiscordUser, jf: JellyfinHandler, guildId: string, requestId: string): Promise<any> {
|
||||||
|
if (!jf.isUserAlreadyPresent(discordUser, guildId, requestId)) {
|
||||||
|
logger.info(`User ${discordUser.username} is already registered on ${jf.ServerName}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const jfUserAccount = await jf.createUserAccountForDiscordUser(discordUser, guildId, requestId)
|
||||||
|
if (jfUserAccount) {
|
||||||
|
await jf.addPermissionsToUserAccount(jfUserAccount,guildId,requestId)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user