diff --git a/src/channel.ts b/src/channel.ts index 66e72d75e..2a03b478d 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -35,16 +35,17 @@ import { QueryMembersOptions, Reaction, ReactionAPIResponse, + SearchAPIResponse, + SearchMessageSortBase, SearchOptions, SearchPayload, - SearchAPIResponse, SendMessageAPIResponse, TruncateChannelAPIResponse, + TruncateOptions, UnknownType, UpdateChannelAPIResponse, UserFilters, UserResponse, - SearchMessageSortBase, } from './types'; import { Role } from './permissions'; @@ -608,12 +609,18 @@ export class Channel< /** * truncate - Removes all messages from the channel - * @param {boolean} [options.hard_delete] Defines if messages of the channel must be hard deleted - * @return {Promise>} The server response + * @param {TruncateOptions} [options] Defines truncation options + * @return {Promise>} The server response */ - async truncate(options: { hard_delete?: boolean } = {}) { + async truncate(options: TruncateOptions = {}) { return await this.getClient().post< - TruncateChannelAPIResponse + TruncateChannelAPIResponse< + ChannelType, + CommandType, + UserType, + MessageType, + ReactionType + > >(this._channelURL() + '/truncate', options); } diff --git a/src/types.ts b/src/types.ts index cc96cdad0..22fdf8c46 100644 --- a/src/types.ts +++ b/src/types.ts @@ -205,6 +205,7 @@ export type ChannelResponse< name?: string; own_capabilities?: string[]; team?: string; + truncated_at?: string; updated_at?: string; }; @@ -699,9 +700,20 @@ export type SendMessageAPIResponse< export type TruncateChannelAPIResponse< ChannelType = UnknownType, CommandType extends string = LiteralStringForUnion, - UserType = UnknownType + UserType = UnknownType, + AttachmentType = UnknownType, + MessageType = UnknownType, + ReactionType = UnknownType > = APIResponse & { channel: ChannelResponse; + message?: MessageResponse< + AttachmentType, + ChannelType, + CommandType, + MessageType, + ReactionType, + UserType + >; }; export type UpdateChannelAPIResponse< @@ -2238,3 +2250,10 @@ export type TaskStatus = { }; result?: UnknownType; }; + +export type TruncateOptions = { + hard_delete?: boolean; + message?: Message; + skip_push?: boolean; + truncated_at?: Date; +};