UNPKG

guilded.ts

Version:

A powerful NPM module that allows you to easily interact with the Guilded API.

52 lines 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChatChannel = void 0; const Channel_1 = require("./Channel"); const MessageManager_1 = require("../../managers/message/MessageManager"); const MessageCollector_1 = require("../../collectors/MessageCollector"); /** * Represents a chat channel on Guilded. * @example new ChatChannel(client, rawChannel); */ class ChatChannel extends Channel_1.Channel { /** The manager of messages that belong to the chat channel. */ messages; /** * @param client The client the chat channel belongs to. * @param raw The raw data of the chat channel. * @param cache Whether to cache the chat channel. */ constructor(client, raw, cache) { super(client, raw, cache); this.messages = new MessageManager_1.MessageManager(this); } /** * Create a message in the chat channel. * @param payload The payload of the message. * @returns The created message. * @example channel.send('Hello world!'); */ send(payload) { return this.messages.create(payload); } /** * Create a message collector for the chat channel. * @param options The options of the message collector. * @returns The created message collector. * @example channel.createMessageCollector(); */ createMessageCollector(options) { return new MessageCollector_1.MessageCollector(this, options); } /** * Similar to createMessageCollector but in promise form. * @param options The options of the message collector. * @returns The collected messages. * @example channel.awaitMessages(); */ awaitMessages(options) { return new Promise((resolve) => this.createMessageCollector(options).once('end', resolve)); } } exports.ChatChannel = ChatChannel; //# sourceMappingURL=ChatChannel.js.map