UNPKG

selfbot-discord

Version:
100 lines (88 loc) • 2.51 kB
const Channel = require('./Channel'); const TextBasedChannel = require('./interfaces/TextBasedChannel'); const Collection = require('../util/Collection'); /** * Represents a direct message channel between two users. * @extends {Channel} * @implements {TextBasedChannel} */ class DMChannel extends Channel { constructor(client, data) { super(client, data); this.type = 'dm'; this.messages = new Collection(); this._typing = new Map(); } setup(data) { super.setup(data); /** * The recipient on the other end of the DM * @type {User} */ this.recipient = this.client.dataManager.newUser(data.recipients[0]); /** * The ID of the last message in the channel, if one was sent * @type {?Snowflake} */ this.lastMessageID = data.last_message_id; /** * The timestamp when the last pinned message was pinned, if there was one * @type {?number} */ this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null; /** * update 07/2023 * <warn>This is only available when using a user account.</warn> * @type {boolean} * @readonly */ // this.muted = this.client._muted.has(data.id); } /** * When concatenated with a string, this automatically concatenates the recipient's mention instead of the * DM channel object. * @returns {string} */ toString() { return this.recipient.toString(); } /** * Whether the channel is muted * <warn>This is only available when using a user account.</warn> * @type {?boolean} * @readonly */ get muted() { if (this.client.user.bot) return null; try { return this.client.user.guildSettings.get(null).channelOverrides.get(this.id).muted; } catch (err) { return false; } } // These are here only for documentation purposes - they are implemented by TextBasedChannel /* eslint-disable no-empty-function */ get lastPinAt() {} send() {} sendMessage() {} sendEmbed() {} sendFile() {} sendFiles() {} sendCode() {} fetchMessage() {} fetchMessages() {} fetchPinnedMessages() {} search() {} startTyping() {} stopTyping() {} get typing() {} get typingCount() {} createCollector() {} createMessageCollector() {} awaitMessages() {} // Doesn't work on DM channels; bulkDelete() {} acknowledge() {} _cacheMessage() {} } TextBasedChannel.applyToClass(DMChannel, true, ['bulkDelete']); module.exports = DMChannel;