import type { Channel, Message, MessageAttachment, User } from "discord-types/general"; import type { APIEmbed } from "src/types"; export declare enum ActivityActionTypes { JOIN = 1, LISTEN = 3, WATCH = 4, JOIN_REQUEST = 5 } type Properties = Record; interface MessageReference { guild_id?: string; channel_id?: string; message_id?: string; } interface AllowedMentions { parse?: Array<"users" | "roles" | "everyone">; replied_user?: boolean; } interface InviteSuggestion { isAffinitySuggestion: boolean; rowNum: number; numTotal: number; numAffinityConnections: number; isFiltered: boolean; } interface FetchMessagesOptions { channelId: string; /** Snowflake */ before?: string; /** Snowflake */ after?: string; limit?: number; jump?: { highlight?: boolean; flash?: boolean; jumpType?: string; messageId?: string; offset?: number; returnMessageId?: boolean; }; focus?: { messageId: string; }; isPreload?: boolean; skipLocalFetch?: boolean; truncate?: boolean; } type FetchMessagesCachedOptions = Omit; interface FocusMessageOptions { channelId: string; messageId: string; } export interface SendMessageForReplyOptions { channel: Channel; message: Message; shouldMention: boolean; showMentionToggle: boolean; } export interface SendMessageOptionsForReply { messageReference?: MessageReference; allowedMentions?: AllowedMentions; } interface MessageJumpOptions { channelId: string; messageId: string; flash?: boolean; offset?: number; context?: string; extraProperties?: Properties; isPreload?: boolean; returnMessageId?: string; skipLocalFetch?: boolean; jumpType?: string; } interface Emoji { allNamesString: string; animated?: boolean; available?: boolean; guildId: string; id: string; managed?: boolean; name: string; require_colons?: boolean; roles?: string[]; url: string; } interface OutgoingMessage { content: string; invalidEmojis?: Emoji[]; validNonShortcutEmojis: Emoji[]; tts?: boolean; } interface OutgoingMessageOptions { activityAction?: ActivityActionTypes; location?: string; suggestedInvite?: InviteSuggestion; stickerIds?: string[]; messageReference?: MessageReference; allowedMentions?: AllowedMentions; } interface TrackInviteOptions { inviteKey: string; channelId: string; messageId: string; location: string; suggested?: InviteSuggestion; overrideProperties?: Properties; } interface MessageGreetOptions { messageReference?: MessageReference; allowedMentions?: AllowedMentions; } interface Poll { question: { text: string; }; answers: Array<{ poll_media: { text: string; }; answer_id: number; }>; expiry: string; allow_multiselect: boolean; duration: number; layout_type: number; } declare class RemoteFetch { completed: boolean; markComplete: () => void; } declare class MessageCache { constructor(isCacheBefore: boolean); _isCacheBefore: boolean; _map: Record; _messages: Message[]; _wasAtEdge: boolean; get length(): number; get wasAtEdge(): boolean; set wasAtEdge(value: boolean); cache: (messages: Message[], isAtEdge?: boolean) => void; clear: () => void; clone: () => MessageCache; extract: (amount: number) => Message[]; extractAll: () => Message[]; forEach: Message[]["forEach"]; get: (messageId: string) => Message | undefined; has: (messageId: string) => boolean; remove: (messageId: string) => void; removeMany: (messageIds: string[]) => void; replace: (messageId: string, message: Message) => void; update: (messageId: string, callback: (message: Message) => Message) => void; } interface MutatedChannelMessages { _after: MessageCache; _array: Message[]; _before: MessageCache; _map: Record; cached?: boolean; error?: boolean; focusTargetId?: string | undefined; hasFetched?: boolean; hasMoreAfter?: boolean; hasMoreBefore?: boolean; jumped?: boolean; jumpedToPresent?: boolean; jumpFlash?: boolean; jumpReturnTargetId?: string | null; jumpSequenceId?: number; jumpTargetId?: string | null; jumpTargetOffset?: number; jumpType?: "ANIMATED" | "INSTANT"; loadingMore?: boolean; ready?: boolean; revealedMessageId?: string | null; } export declare class ChannelMessages { constructor(channelId: string); private static _channelMessages; static clear: (channelId: string) => void; static clearCache: (channelId: string) => void; static commit: (channelMessages: ChannelMessages) => void; static forEach: (callback: (messages: ChannelMessages, index: number, channelMessages: Record) => void) => void; static get: (channelId: string) => ChannelMessages; static getOrCreate: (channelId: string) => ChannelMessages; static hasPresent: (channelId: string) => boolean; private _after; private _array; private _before; private _map; cached: boolean; channelId: string; error: boolean; focusTargetId?: string | undefined; hasFetched: boolean; hasMoreAfter: boolean; hasMoreBefore: boolean; jumped: boolean; jumpedToPresent: boolean; jumpFlash: boolean; jumpReturnTargetId: string | null; jumpSequenceId: number; jumpTargetId: string | null; jumpTargetOffset: number; jumpType: "ANIMATED" | "INSTANT"; loadingMore: boolean; ready: boolean; revealedMessageId: string | null; get length(): number; _clearMessages: () => void; _merge: (messages: Message[], prepend?: boolean, clearCache?: boolean) => void; addCachedMessages: (messages: Message[], cache?: boolean) => ChannelMessages; filter: Message[]["filter"]; findNewest: (callback: (message: Message, index: number, messages: Message) => unknown) => Message | undefined; findOldest: (callback: (message: Message, index: number, messages: Message) => unknown) => Message | undefined; first: () => Message | undefined; focusOnMessage: (focusTargetId: string) => ChannelMessages; forAll: Array["forEach"]; forEach: (callback: (message: Message, index: number, messages: Message[]) => void, thisArg?: unknown, reverse?: boolean) => void; get: (messageId: string, cache?: boolean) => Message | undefined; getAfter: (messageId: string) => Message | null; getByIndex: (index: number) => Message | undefined; getManyAfter: (messageId: string, count: number, callback: (message: Message) => unknown) => Message[] | null; getManyBefore: (messageId: string, count: number, callback: (message: Message) => unknown) => Message[] | null; has: (messageId: string, cache?: boolean) => boolean; hasAfterCached: (afterId: string) => boolean; hasBeforeCached: (beforeId: string) => boolean; hasPresent: () => boolean; indexOf: (messageId: string) => number; jumpToMessage: (jumpTargetId: string | null, jumpFlash: boolean, jumpTargetOffset: number, jumpReturnTargetId: string | null, jumpType?: "ANIMATED" | "INSTANT") => ChannelMessages; jumpToPresent: (limit: number) => ChannelMessages; last: () => Message | undefined; loadComplete: (messages: ChannelMessages) => ChannelMessages; loadFromCache: (before: boolean, limit: number) => ChannelMessages; loadStart: (jumpData: { present: boolean; messageId: string | null; offset: number; returnMessageId: string; }) => ChannelMessages; map: Message[]["map"]; merge: (messages: Message[], prepend?: boolean, clearCache?: boolean) => ChannelMessages; mergeDelta: (newMessages?: Message[], modifiedMessages?: Message[], deletedMessages?: Message[]) => ChannelMessages; mutate: (callback: ((messages: ChannelMessages) => void) | MutatedChannelMessages, deep?: boolean) => ChannelMessages; receiveMessage: (message: Message, truncateFromTop?: boolean) => ChannelMessages; receivePushNotification: (message: Message) => ChannelMessages; reduce: Message[]["reduce"]; some: Message[]["some"]; remove: (messageId: string) => ChannelMessages; removeMany: (messageIds: string[]) => ChannelMessages; replace: (prevMessageId: string, newMessage: Message) => ChannelMessages; reset: (messages: Message[]) => ChannelMessages; toArray: () => Message[]; truncate: (bottom?: boolean, top?: boolean) => ChannelMessages; truncateBottom: (count: number, deep?: boolean) => ChannelMessages; truncateTop: (count: number, deep?: boolean) => ChannelMessages; update: (messageId: string, callback: (message: Message) => Message) => ChannelMessages; } export interface MessageStore { focusedMessageId: (channelId: string) => string | null | undefined; getLastCommandMessage: (channelId: string) => Message | undefined; getLastEditableMessage: (channelId: string) => Message | undefined; getLastMessage: (channelId: string) => Message | undefined; getLastNonCurrentUserMessage: (channelId: string) => Message | undefined; getMessage: (channelId: string, messageId: string) => Message | undefined; getMessages: (channelId: string) => ChannelMessages; hasCurrentUserSentMessage: (channelId: string) => boolean; hasCurrentUserSentMessageSinceAppStart: () => boolean; hasPresent: (channelId: string) => boolean; isLoadingMessages: (channelId: string) => boolean; isReady: (channelId: string) => boolean; jumpedMessageId: (channelId: string) => string | null | undefined; whenReady: (channelId: string, callback: () => void) => void; } export interface MessageActions { clearChannel: (channelId: string) => void; crosspostMessage: (channelId: string, messageId: string) => Promise; deleteMessage: (channelId: string, messageId: string, keepThreadArchived?: boolean) => Promise; dismissAutomatedMessage: (message: Message) => void; editMessage: (channelId: string, messageId: string, message: { content: string; }) => Promise; endEditMessage: (channelId: string, response?: unknown) => void; fetchLocalMessages: (channelId: string, before: string, after: string, limit: number, remoteFetch: RemoteFetch) => Promise; fetchMessages: (options: FetchMessagesOptions) => Promise; fetchNewLocalMessages: (channelId: string, limit: number) => Promise; focusMessage: (options: FocusMessageOptions) => void; getSendMessageOptionsForReply: (options: SendMessageForReplyOptions) => SendMessageOptionsForReply | Record; jumpToMessage: (options: MessageJumpOptions) => Promise; jumpToPresent: (channelId: string, limit: number) => void; patchMessageAttachments: (channelId: string, messageId: string, attachments: MessageAttachment[]) => Promise; receiveMessage: (channelId: string, message: Message, optimistic?: boolean, options?: OutgoingMessageOptions) => void; revealMessage: (channelId: string, messageId: string) => void; sendActivityBookmark: (channelId: string, activityDetails: string, analyticsTriggeredFrom?: string, suggestedInvite?: InviteSuggestion) => Promise; sendBotMessage: (channelId: string, content: string, messageName?: string, messageId?: string) => void; sendClydeError: (channelId: string, code?: number) => void; sendExplicitMediaClydeError: (channelId: string, attachments: MessageAttachment[] | undefined, context: string) => void; sendGreetMessage: (channelId: string, stickerId: string, options?: MessageGreetOptions) => Promise; sendInvite: (channelId: string, inviteCode: string, analyticsTriggeredFrom?: string, suggestedInvite?: InviteSuggestion) => Promise; sendMessage: (channelId: string, message: OutgoingMessage, promise?: boolean, options?: OutgoingMessageOptions) => Promise; sendStickers: (channelId: string, stickerIds: string[], content?: string, options?: SendMessageOptionsForReply | Record, tts?: boolean) => Promise; sendPollMessage: (channelId: string, poll: Poll, options?: SendMessageOptionsForReply | Record) => Promise; startEditMessage: (channelId: string, messageId: string, content: string, source?: string) => void; suppressEmbeds: (channelId: string, messageId: string) => Promise; trackInvite: (options: TrackInviteOptions) => void; trackJump(channelId: string, messageId: string, context: string, extraProperties?: Properties): void; truncateMessages: (channelId: string, truncateBottom: boolean, truncateTop: boolean) => void; updateEditMessage: (channelId: string, textValue: string, richValue: unknown) => void; _sendMessage: (channelId: string, message: OutgoingMessage, options: OutgoingMessageOptions) => Promise; _tryFetchMessagesCached: (options: FetchMessagesCachedOptions) => boolean; } interface CreateBotMessageOptions { channelId: string; content: string; embeds?: APIEmbed[]; loggingName?: string; messageId?: string; } interface CreateMessageOptions { channelId: string; content: string; tts?: boolean; type?: number; messageReference?: MessageReference; allowedMentions?: AllowedMentions; author: User; flags?: number; nonce?: string; poll?: Poll; changelogId?: string; } interface UserServer { id: string; username: string; avatar: string | null; discriminator: string; bot: boolean | undefined; global_name: string | null; } interface MessageUtils { createBotMessage: (options: CreateBotMessageOptions) => Message; createMessage: (options: CreateMessageOptions) => Message; userRecordToServer: (user: User) => UserServer; } declare const MessageUtils: MessageUtils; export type Messages = MessageActions & MessageStore & MessageUtils; declare const _default: Messages; export default _default;