UNPKG

night-api

Version:

Ce paquet Npm fourni une interface pour intéragir avec [Night-API](https://night-api.com)

34 lines 1.45 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const functions_1 = __importDefault(require("../../functions")); const constants_1 = require("../constants"); class NSFW { token; constructor(token) { this.token = token; this.functions = new functions_1.default(this.token); } ; async getImage(idOrType) { return new Promise(async (resolve, reject) => { if (!idOrType) return this.functions.get(`${constants_1.Endpoints.Images._}${constants_1.Endpoints.Images.NSFW._}/`).then(resolve).catch(reject); if (typeof idOrType !== "string" && typeof idOrType !== "number") throw new Error("Invalid type or ID"); if (typeof idOrType === "string" && !constants_1.Lists.NSFWcategory.includes(idOrType.toLowerCase())) throw new Error("Invalid type"); return this.functions.get(`${constants_1.Endpoints.Images._}${constants_1.Endpoints.Images.NSFW._}/${idOrType}`).then(resolve).catch(reject); }); } ; fetchImage(idOrType) { return new Promise(async (resolve, reject) => this.getImage(idOrType).then(resolve).catch(reject)); } } ; ; exports.default = NSFW; //# sourceMappingURL=NSFW.js.map