UNPKG

hennus-api

Version:

Esta es una libreria para el bot Hennus

58 lines (57 loc) 2.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BasedForumChannel = void 0; const channel_1 = require("../base/channel"); const utils_1 = require("../../utils"); const bitfield_1 = require("../bitfield"); const Error_1 = require("../../core/Error"); class BasedForumChannel extends channel_1.BaseChannel { constructor(data, client) { super(data, client); this.data = data; this.topic = ""; this.nsfw = false; this.permission = []; this.position = undefined; this.parent = undefined; this.guildId = ""; this.lastPin = undefined; this.lastMessage = undefined; Object.defineProperty(this, "data", { value: data }); this.topic = this.data?.topic ?? ""; this.nsfw = this.data.nsfw ?? false; this.permission = (this.data.permission_overwrites ?? []).map(({ id, type, deny, allow }) => ({ id, type, deny: new bitfield_1.OverwriteBitField(Number(deny)), allow: new bitfield_1.OverwriteBitField(Number(allow)), })); this.position = this.data.position; this.parent = this.data.parent_id ?? undefined; this.guildId = this.data.guild_id ?? ""; const guild = client.guilds.cache.get(this.guildId); if (guild) this.guild = guild; this.lastPin = this.data.last_pin_timestamp ?? undefined; this.lastMessage = this.data.last_message_id ?? undefined; this._cache_messages = new utils_1.MessagesManager(this.client); } toJson() { return this.data; } get messages() { this._cache_messages.fetchall(this.id); return this._cache_messages; } ; async edit(data) { if (data.name && (data.name.length >= 1 && data.name.length <= 100)) throw new Error_1.HennusError(Error_1.errorCodes.ChannelNameLength); if (data.topic && (data.topic.length < 0 || data.topic.length > 1024)) throw new Error_1.HennusError(Error_1.errorCodes.ChannelTopicLength); return await this.client.channels.edit(this.id, data); } ; } exports.BasedForumChannel = BasedForumChannel; ;