hennus-api
Version:
Esta es una libreria para el bot Hennus
58 lines (57 loc) • 2.14 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasedThreadChannel = 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 BasedThreadChannel extends channel_1.BaseChannel {
constructor(data, client) {
super(data, client);
this.data = data;
this.nsfw = false;
this.permission = [];
this.position = undefined;
this.parent = undefined;
this.lastPin = "";
this.lastMessage = "";
this.guildId = "";
Object.defineProperty(this, "data", { value: data });
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.lastPin = this.data.last_pin_timestamp ?? "";
this.lastMessage = this.data.last_message_id ?? "";
this.guildId = this.data.guild_id ?? "";
const guild = client.guilds.cache.get(this.guildId);
if (guild)
this.guild = guild;
this._cache_messages = new utils_1.MessagesManager(this.client);
}
;
get messages() {
this._cache_messages.fetchall(this.id);
return this._cache_messages;
}
;
toJson() {
return this.data;
}
;
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.BasedThreadChannel = BasedThreadChannel;
;