Skip to content

Commit

Permalink
Message#getOriginal & getLast
Browse files Browse the repository at this point in the history
- Add Message#getOriginal
- Message#getLast
  • Loading branch information
pakkographic committed Aug 4, 2024
1 parent 320b272 commit ac044e8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/structures/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ export class Message<T extends AnyTextableChannel> extends Base<string> {
return this.client.rest.channels.deleteMessage(this.channelID, this.id as string);
}

/**
* Get the latest message sent with this Message.
*/
async getLast(): Promise<Message<T>> {
if (!this._lastMessageID)
throw new TypeError("Cannot get last message if it does not exist.");
return this.client.rest.channels.getMessage<T>(
this.channelID,
this._lastMessageID
);
}

/** Edit the last message sent with the message itself.
* @param newMessage New message's options.
Expand All @@ -353,6 +364,19 @@ export class Message<T extends AnyTextableChannel> extends Base<string> {
return this.client.rest.channels.deleteMessage(this.channelID, this._lastMessageID);
}

/**
* Get original message response.
*/
async getOriginal(): Promise<Message<T>> {
if (!this.#originalMessageID)
throw new TypeError("Cannot get original message if it does not exist.");
return this.client.rest.channels.getMessage<T>(
this.channelID,
this.#originalMessageID,
{ originalMessageID: this.#originalMessageID }
);
}

/** Edit the message's original response message.
* @param newMessage New message's options.
*/
Expand Down

0 comments on commit ac044e8

Please sign in to comment.