hennus-api
Version:
Esta es una libreria para el bot Hennus
57 lines (56 loc) • 1.83 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseData = void 0;
const axios_1 = __importDefault(require("axios"));
const utils_1 = require("../../utils");
class BaseData {
constructor(client) {
this.client = client;
this.colorResolved = utils_1.resolvedColor;
Object.defineProperty(this, "client", { value: client });
}
;
get cdn() {
return this.client.rest.cdn;
}
;
get rest() {
return this.client.rest;
}
;
async imagen(_url) {
if (!_url)
return undefined;
try {
const header = ['image/jpeg', 'image/gif', 'image/png', 'image/x-icon', "imagen/webp", "image/webp"];
const url = await (0, axios_1.default)(_url, { responseType: "arraybuffer" });
let type = url.headers["content-type"] || url.headers["Content-Type"];
if (url.status == 200 && header.includes(type)) {
let _type;
if (type === "image/jpeg")
_type = "jpeg";
else if (type === "image/gif")
_type = "gif";
else if (type === "image/png")
_type = "png";
else if (type === "image/x-icon")
_type = "ico";
else if (type === "image/webp" || type === "imagen/webp")
_type = "webp";
return { data: url.data, url: _url, type: _type, content_type: type };
}
;
return undefined;
}
catch {
return undefined;
}
;
}
;
}
exports.BaseData = BaseData;
;