import { BushMessageResolvable, BushTextBasedChannel, type BushMessage } from '#lib'; import { CachedManager, type BaseFetchOptions, type ChannelLogsQueryOptions, type Collection, type EmojiIdentifierResolvable, type MessageEditOptions, type MessagePayload, type Snowflake } from 'discord.js'; import type { RawMessageData } from 'discord.js/typings/rawDataTypes'; /** * Manages API methods for Messages and holds their cache. */ export class BushMessageManager extends CachedManager { public constructor(channel: BushTextBasedChannel, iterable?: Iterable); /** * The channel that the messages belong to */ public channel: BushTextBasedChannel; /** * The cache of Messages */ public cache: Collection; /** * Publishes a message in an announcement channel to all channels following it, even if it's not cached. * @param message The message to publish */ public crosspost(message: BushMessageResolvable): Promise; /** * Deletes a message, even if it's not cached. * @param message The message to delete */ public delete(message: BushMessageResolvable): Promise; /** * Edits a message, even if it's not cached. * @param message The message to edit * @param options The options to edit the message */ public edit(message: BushMessageResolvable, options: MessagePayload | MessageEditOptions): Promise; /** * Gets a message, or messages, from this channel. * The returned Collection does not contain reaction users of the messages if they were not cached. * Those need to be fetched separately in such a case. * @param message The id of the message to fetch, or query parameters. * @param options Additional options for this fetch * @example * // Get message * channel.messages.fetch('99539446449315840') * .then(message => console.log(message.content)) * .catch(console.error); * @example * // Get messages * channel.messages.fetch({ limit: 10 }) * .then(messages => console.log(`Received ${messages.size} messages`)) * .catch(console.error); * @example * // Get messages and filter by user id * channel.messages.fetch() * .then(messages => console.log(`${messages.filter(m => m.author.id === '84484653687267328').size} messages`)) * .catch(console.error); */ public fetch(message: Snowflake, options?: BaseFetchOptions): Promise; public fetch(options?: ChannelLogsQueryOptions, cacheOptions?: BaseFetchOptions): Promise>; /** * Fetches the pinned messages of this channel and returns a collection of them. * The returned Collection does not contain any reaction data of the messages. * Those need to be fetched separately. * @param cache Whether to cache the message(s) * @example * // Get pinned messages * channel.messages.fetchPinned() * .then(messages => console.log(`Received ${messages.size} messages`)) * .catch(console.error); */ public fetchPinned(cache?: boolean): Promise>; /** * Adds a reaction to a message, even if it's not cached. * @param message The message to react to * @param emoji The emoji to react with */ public react(message: BushMessageResolvable, emoji: EmojiIdentifierResolvable): Promise; /** * Pins a message to the channel's pinned messages, even if it's not cached. * @param message The message to pin */ public pin(message: BushMessageResolvable): Promise; /** * Unpins a message from the channel's pinned messages, even if it's not cached. * @param message The message to unpin */ public unpin(message: BushMessageResolvable): Promise; }