Skip to content

Commit

Permalink
Remove duplicate IDs inside replyMessageIDs array
Browse files Browse the repository at this point in the history
Message
  • Loading branch information
pakkographic committed Aug 13, 2024
1 parent bcb3c6e commit b386559
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/routes/Channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export class Channels {
params?: MessageConstructorParams
): Promise<Message<T>> {
if (typeof options !== "object") throw new Error("message options should be an object.");
options.replyMessageIDs = [...new Set(options.replyMessageIDs)]; // Remove duplicates.
return this.#manager.authRequest<POSTChannelMessageResponse>({
method: "POST",
path: endpoints.CHANNEL_MESSAGES(channelID),
Expand Down Expand Up @@ -1025,6 +1026,7 @@ export class Channels {
params?: MessageConstructorParams
): Promise<Message<T>> {
if (typeof newMessage !== "object") throw new Error("newMessage should be an object.");
newMessage.replyMessageIDs = [...new Set(newMessage.replyMessageIDs)]; // Remove duplicates.
return this.#manager.authRequest<PUTChannelMessageResponse>({
method: "PUT",
path: endpoints.CHANNEL_MESSAGE(channelID, messageID),
Expand Down
1 change: 1 addition & 0 deletions lib/structures/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export class Message<T extends AnyTextableChannel> extends Base<string> {
if (options.replyMessageIDs?.includes(this.originals.triggerID ?? " ")) {
options.replyMessageIDs[options.replyMessageIDs.length - 1] = this.originals.responseID;
}

const response =
await this.client.rest.channels.createMessage<T>(
this.channelID,
Expand Down

0 comments on commit b386559

Please sign in to comment.