UNPKG

@bitzonegaming/roleplay-engine-sdk

Version:
64 lines (63 loc) 3.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DiscordApi = void 0; class DiscordApi { constructor(client) { this.client = client; } /** * Retrieves a Discord user with the guild membership information by their unique identifier. This endpoint is used to fetch Discord user details for a specific player.<br/>This endpoint performs server-level operations. The token does not need to be associated with any account or character.<br/><br/> This endpoint requires authorization, and supports following token types:<br/>🔓 [API Key] <b>Required Scopes</b>: read:account * @summary Get Discord user by id * @param {string} discordUserId * @param {*} [options] Override http request option. * @throws {EngineError} */ getDiscordUserById(discordUserId, options) { return this.client.get({ url: `discord/users/${discordUserId}`, options, }); } /** * This endpoint allows players to authenticate with Discord using the implicit flow. It returns a grant access result containing the player\'s account information and access token.<br/>This endpoint performs server-level operations. The token does not need to be associated with any account or character.<br/><br/> This endpoint requires authorization, and supports following token types:<br/>🔓 [API Key] <b>Required Scopes</b>: write:player_auth * @summary Authorize with implicit Discord flow * @param {ImplicitDiscordAuthRequest} request * @param {*} [options] Override http request option. * @throws {EngineError} */ authImplicitFlow(request, options) { return this.client.post({ url: `discord/auth`, data: request, options, }); } /** * This endpoint allows players to authenticate with Discord using OAuth tokens. It returns a grant access result containing the player\'s account information and access token.<br/>This endpoint performs server-level operations. The token does not need to be associated with any account or character.<br/><br/> This endpoint requires authorization, and supports following token types:<br/>🔓 [API Key] <b>Required Scopes</b>: write:player_auth * @summary Authorize with Discord OAuth token * @param {DiscordOAuthTokenRequest} request * @param {*} [options] Override http request option. * @throws {EngineError} */ authOAuthFlow(request, options) { return this.client.post({ url: `discord/oauth/token`, data: request, options, }); } /** * This endpoint retrieves the OAuth authorization URL for Discord. It is used to initiate the OAuth flow for players to grant access to their Discord account. <br/><br/> This endpoint requires authorization, and supports following token types:<br/>🔓 [API Key] <b>Required Scopes</b>: write:player_auth * @summary Authorize with Discord OAuth token * @param {DiscordOAuthRedirectType} redirectType * @param {*} [options] Override http request option. * @throws {EngineError} */ getDiscordOAuthAuthorizeUrl(redirectType, options) { return this.client.get({ url: `discord/oauth/authorize?redirectType=${redirectType}`, options, }); } } exports.DiscordApi = DiscordApi;