hennus-api
Version:
Esta es una libreria para el bot Hennus
48 lines (47 loc) • 1.73 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasedDmChannel = void 0;
const v10_1 = require("discord-api-types/v10");
const channel_1 = require("../base/channel");
const user_1 = require("../user");
const utils_1 = require("../../utils");
const Error_1 = require("../../core/Error");
class BasedDmChannel extends channel_1.BaseChannel {
constructor(data, client) {
super(data, client);
this.data = data;
this._cache_messages = new utils_1.MessagesManager(this.client);
Object.defineProperty(this, "data", { value: data });
if (this.data.type == v10_1.ChannelType.DM)
this.dm = this.data;
else if (this.data.type === v10_1.ChannelType.GroupDM)
this.dmGroup = this.data;
this.lastMessage = this.data.last_message_id ?? undefined;
this.lastPin = this.data.last_pin_timestamp ?? undefined;
this.users = this.data.recipients ? this.data.recipients.map((x) => new user_1.User(x, this.client)) : undefined;
}
;
get messages() {
this._cache_messages.fetchall(this.id);
return this._cache_messages;
}
;
iconURL(options) {
if (!this.dmGroup || !this.dmGroup?.icon)
return undefined;
else
return this.cdn.channelIcon(this.id, this.dmGroup.icon, options);
}
;
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);
return await this.client.channels.edit(this.id, data);
}
}
exports.BasedDmChannel = BasedDmChannel;
;