1 | import type { OptionalArgument } from '../helpers';
|
2 | import type { Block, // TODO: these will be combined into one in a new types release
|
3 | KnownBlock, LinkUnfurls, MessageAttachment, MessageMetadata } from '@slack/types';
|
4 | import type { CursorPaginationEnabled, OptionalTeamAssignable, TimelinePaginationEnabled, TokenOverridable } from './common';
|
5 | export interface Channel {
|
6 | /** @description Channel ID for the message. */
|
7 | channel: string;
|
8 | }
|
9 | export interface ChannelAndTS extends Channel {
|
10 | /** @description Timestamp of the message. */
|
11 | ts: string;
|
12 | }
|
13 | interface ChannelAndMessageTS extends Channel {
|
14 | /** @description Timestamp of the message. */
|
15 | message_ts: string;
|
16 | }
|
17 | export interface AsUser {
|
18 | /**
|
19 | * @description Pass `true` to act as the authed user with {@link https://api.slack.com/scopes/chat:write:user `chat:write:user` scope}.
|
20 | * Bot users in this context are considered authed users. If unused or `false`, the message will be acted upon with
|
21 | * {@link https://api.slack.com/scopes/chat:write:bot `chat:write:bot` scope}.
|
22 | */
|
23 | as_user?: boolean;
|
24 | }
|
25 | export interface LinkNames {
|
26 | /** @description Find and link channel names and usernames. */
|
27 | link_names?: boolean;
|
28 | }
|
29 | export interface Parse {
|
30 | /**
|
31 | * @description Change how messages are treated. Defaults to `none`.
|
32 | * @see {@link https://api.slack.com/reference/surfaces/formatting#automatic-parsing Formatting: Automatic parsing}.
|
33 | */
|
34 | parse?: 'full' | 'none';
|
35 | }
|
36 | interface Text {
|
37 | /**
|
38 | * @description Text of the message. If used in conjunction with `blocks` or `attachments`, `text` will be used
|
39 | * as fallback text for notifications only.
|
40 | */
|
41 | text: string;
|
42 | }
|
43 | export interface ChannelAndText extends Channel, Text {
|
44 | }
|
45 | export interface ChannelAndBlocks extends Channel, Partial<Text> {
|
46 | /**
|
47 | * @description An array of structured Blocks.
|
48 | * @see {@link https://api.slack.com/reference/block-kit/blocks Blocks reference}.
|
49 | */
|
50 | blocks: (KnownBlock | Block)[];
|
51 | }
|
52 | export interface ChannelAndAttachments extends Channel, Partial<Text> {
|
53 | /**
|
54 | * @description An array of structured attachments.
|
55 | * @see {@link https://api.slack.com/messaging/composing/layouts#attachments Adding secondary attachments}.
|
56 | */
|
57 | attachments: MessageAttachment[];
|
58 | }
|
59 | type MessageContents = ChannelAndText | ChannelAndBlocks | ChannelAndAttachments;
|
60 | export interface ThreadTS {
|
61 | /**
|
62 | * @description Provide another message's `ts` value to post this message in a thread. Avoid using a reply's `ts`
|
63 | * value; use its parent's value instead.
|
64 | */
|
65 | thread_ts: string;
|
66 | }
|
67 | export interface WithinThreadReply extends Partial<ThreadTS> {
|
68 | /**
|
69 | * @description Used in conjunction with `thread_ts`, when set to `false` will make the reply only visibile within
|
70 | * a thread.
|
71 | */
|
72 | reply_broadcast?: false;
|
73 | }
|
74 | export interface BroadcastedThreadReply extends ThreadTS {
|
75 | /** @description Used in conjunction with `thread_ts`, when set to `true` will broadcast the reply to the channel. */
|
76 | reply_broadcast: boolean;
|
77 | }
|
78 | type ReplyInThread = WithinThreadReply | BroadcastedThreadReply;
|
79 | export interface Metadata {
|
80 | /** @description Object representing message metadata, which will be made accessible to any user or app. */
|
81 | metadata?: MessageMetadata;
|
82 | }
|
83 | export interface IconEmoji {
|
84 | as_user?: false;
|
85 | icon_url?: never;
|
86 | /**
|
87 | * @description Emoji to use as the icon for this message. Overrides `icon_url`.
|
88 | * Can only be used with `as_user` set to `false`.
|
89 | */
|
90 | icon_emoji?: string;
|
91 | }
|
92 | export interface IconURL {
|
93 | as_user?: false;
|
94 | icon_emoji?: never;
|
95 | /**
|
96 | * @description URL to an image to use as the icon for this message. `icon_emoji` takes precendence over this field.
|
97 | * Can only be used with `as_user` set to `false`.
|
98 | */
|
99 | icon_url?: string;
|
100 | }
|
101 | type Icon = IconEmoji | IconURL;
|
102 | export interface Username {
|
103 | as_user?: false;
|
104 | /** @description Set your bot's username. Can only be used with `as_user` set to `false`. */
|
105 | username?: string;
|
106 | }
|
107 | type Authorship = (Icon & Username) | {
|
108 | /**
|
109 | * @description Pass `true` to act as the authed user with {@link https://api.slack.com/scopes/chat:write:user `chat:write:user` scope}.
|
110 | * Bot users in this context are considered authed users. If unused or `false`, the message will be acted upon with
|
111 | * {@link https://api.slack.com/scopes/chat:write:bot `chat:write:bot` scope}.
|
112 | */
|
113 | as_user: true;
|
114 | icon_emoji?: never;
|
115 | icon_url?: never;
|
116 | };
|
117 | export interface Unfurls {
|
118 | /** @description Pass `true` to enable unfurling of primarily text-based content. */
|
119 | unfurl_links?: boolean;
|
120 | /** @description Pass `false` to disable unfurling of media content. */
|
121 | unfurl_media?: boolean;
|
122 | }
|
123 | export interface ChatDeleteArguments extends ChannelAndTS, AsUser, TokenOverridable {
|
124 | }
|
125 | export interface ChatDeleteScheduledMessageArguments extends Channel, AsUser, TokenOverridable {
|
126 | /** @description The `scheduled_message_id` returned from call to {@link https://api.slack.com/methods/chat.scheduleMessage `chat.scheduleMessage`}. */
|
127 | scheduled_message_id: string;
|
128 | }
|
129 | export interface ChatGetPermalinkArguments extends ChannelAndMessageTS, TokenOverridable {
|
130 | }
|
131 | export interface ChatMeMessageArguments extends ChannelAndText, TokenOverridable {
|
132 | }
|
133 | export type ChatPostEphemeralArguments = TokenOverridable & MessageContents & {
|
134 | /**
|
135 | * @description `id` of the user who will receive the ephemeral message.
|
136 | * The user should be in the channel specified by the `channel` argument.
|
137 | */
|
138 | user: string;
|
139 | } & Authorship & Parse & LinkNames & Partial<ThreadTS>;
|
140 | export type ChatPostMessageArguments = TokenOverridable & MessageContents & ReplyInThread & Authorship & Parse & LinkNames & Metadata & Unfurls & {
|
141 | /** @description Disable Slack markup parsing by setting to `false`. Enabled by default. */
|
142 | mrkdwn?: boolean;
|
143 | };
|
144 | export type ChatScheduleMessageArguments = TokenOverridable & MessageContents & {
|
145 | /** @description Unix EPOCH timestamp of time in future to send the message. */
|
146 | post_at: string | number;
|
147 | } & ReplyInThread & Parse & LinkNames & AsUser & Metadata & Unfurls;
|
148 | export type ChatScheduledMessagesListArguments = OptionalArgument<TokenOverridable & CursorPaginationEnabled & OptionalTeamAssignable & Pick<TimelinePaginationEnabled, 'latest' | 'oldest'> & Partial<Channel>>;
|
149 | export interface SourceAndUnfurlID {
|
150 | /**
|
151 | * @description The source of the link to unfurl. The source may either be `composer`, when the link is inside the
|
152 | * message composer, or `conversations_history`, when the link has been posted to a conversation.
|
153 | */
|
154 | source: 'composer' | 'conversations_history';
|
155 | /**
|
156 | * @description The ID of the link to unfurl. Both `unfurl_id` and `source` must be provided together, or `channel`
|
157 | * and `ts` must be provided together.
|
158 | */
|
159 | unfurl_id: string;
|
160 | }
|
161 | type UnfurlTarget = ChannelAndTS | SourceAndUnfurlID;
|
162 | export type ChatUnfurlArguments = {
|
163 | /**
|
164 | * @description URL-encoded JSON map with keys set to URLs featured in the the message, pointing to their unfurl
|
165 | * blocks or message attachments.
|
166 | */
|
167 | unfurls: LinkUnfurls;
|
168 | } & UnfurlTarget & TokenOverridable & {
|
169 | /**
|
170 | * @description Provide a simply-formatted string to send as an ephemeral message to the user as invitation to
|
171 | * authenticate further and enable full unfurling behavior. Provides two buttons, Not now or Never ask me again.
|
172 | */
|
173 | user_auth_message?: string;
|
174 | /**
|
175 | * @description Set to `true` to indicate the user must install your Slack app to trigger unfurls for this domain.
|
176 | * Defaults to `false`.
|
177 | */
|
178 | user_auth_required?: boolean;
|
179 | /**
|
180 | * @description Send users to this custom URL where they will complete authentication in your app to fully trigger
|
181 | * unfurling. Value should be properly URL-encoded.
|
182 | */
|
183 | user_auth_url?: string;
|
184 | /**
|
185 | * @description Provide a JSON based array of structured blocks presented as URL-encoded string to send as an
|
186 | * ephemeral message to the user as invitation to authenticate further and enable full unfurling behavior.
|
187 | */
|
188 | user_auth_blocks?: (KnownBlock | Block)[];
|
189 | };
|
190 | export type ChatUpdateArguments = MessageContents & {
|
191 | /** @description Timestamp of the message to be updated. */
|
192 | ts: string;
|
193 | } & TokenOverridable & AsUser & LinkNames & Metadata & Parse & {
|
194 | /** @description Array of new file ids that will be sent with this message. */
|
195 | file_ids?: string[];
|
196 | /** @description Broadcast an existing thread reply to make it visible to everyone in the channel or conversation. */
|
197 | reply_broadcast?: boolean;
|
198 | };
|
199 | export {};
|
200 | //# sourceMappingURL=chat.d.ts.map |
\ | No newline at end of file |