From 705c5a1c17bc3ba31f03f7bd6831e4c50dcbddd0 Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Tue, 24 Aug 2021 21:22:11 +0100 Subject: [PATCH] feat(ThreadChannel): add fetchStarterMessage (#6488) Co-authored-by: Vlad Frangu --- src/structures/ThreadChannel.js | 11 +++++++++++ typings/index.d.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/src/structures/ThreadChannel.js b/src/structures/ThreadChannel.js index b098c15322de..4d09d46094b6 100644 --- a/src/structures/ThreadChannel.js +++ b/src/structures/ThreadChannel.js @@ -253,6 +253,17 @@ class ThreadChannel extends Channel { return members.get(this.ownerId) ?? null; } + /** + * Fetches the message that started this thread, if any. + * This only works when the thread started from a message in the parent channel, otherwise the promise will + * reject. If you just need the id of that message, use {@link ThreadChannel#id} instead. + * @param {BaseFetchOptions} [options] Additional options for this fetch + * @returns {Promise} + */ + fetchStarterMessage(options) { + return this.channel.messages.fetch(this.id, options); + } + /** * The options used to edit a thread channel * @typedef {Object} ThreadEditData diff --git a/typings/index.d.ts b/typings/index.d.ts index d258ca75c661..10580b0775fc 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1818,6 +1818,7 @@ export class ThreadChannel extends TextBasedChannel(Channel) { public permissionsFor(memberOrRole: GuildMember | Role): Readonly; public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly | null; public fetchOwner(options?: FetchOwnerOptions): Promise; + public fetchStarterMessage(options?: BaseFetchOptions): Promise; public setArchived(archived?: boolean, reason?: string): Promise; public setAutoArchiveDuration( autoArchiveDuration: ThreadAutoArchiveDuration,