From 23e228cdff10430a65eebee04d860f1b25da440e Mon Sep 17 00:00:00 2001 From: pakkographic <41129374+pakkographic@users.noreply.github.com> Date: Tue, 13 Aug 2024 21:04:13 +0200 Subject: [PATCH] Add Message#editFollowup, deleteFollowup --- lib/structures/Message.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/structures/Message.ts b/lib/structures/Message.ts index 6b36f0c..506079e 100644 --- a/lib/structures/Message.ts +++ b/lib/structures/Message.ts @@ -313,6 +313,7 @@ export class Message extends Base { if (this.isOriginal && !(this.originals.responseID)) this.originals.responseID = response.id; return response; } + /** This method is used to create a message following this message * (use Message#createFollowup on already acknowledged messages). * @@ -368,6 +369,19 @@ export class Message extends Base { async delete(): Promise { return this.client.rest.channels.deleteMessage(this.channelID, this.id as string); } + + /** + * Delete followup message. + */ + async deleteFollowup(): Promise { + if (!this._lastMessageID || !this.acknowledged) + throw new Error("Cannot delete followup message if it does not exist."); + return this.client.rest.channels.deleteMessage( + this.channelID, + this._lastMessageID + ); + } + /** Delete the last message sent with the message itself. */ async deleteLast(): Promise{ if (!this._lastMessageID) throw new TypeError("Cannot delete last message if it does not exist."); @@ -427,6 +441,27 @@ export class Message extends Base { } ); } + + /** + * Edit followup message. + * @param newMessage Edit options. + */ + async editFollowup(newMessage: EditMessageOptions): Promise> { + if (!this._lastMessageID || !this.acknowledged) + throw new Error("Cannot edit followup message if it does not exist."); + return this.client.rest.channels.editMessage( + this.channelID, + this._lastMessageID, + newMessage, + { + originals: { + triggerID: this.originals.triggerID, + responseID: this.originals.responseID + } + } + ); + } + /** Edit the last message sent with the message itself. * @param newMessage New message's options. */