From 8142605fe63ecbcf63b8b36c8cead0fd4c2c9003 Mon Sep 17 00:00:00 2001 From: pakkographic Date: Mon, 2 Sep 2024 12:20:11 +0200 Subject: [PATCH] fix: message component edit order including InteractionComponent editParent --- lib/structures/ComponentInteraction.ts | 1 + lib/structures/Message.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/structures/ComponentInteraction.ts b/lib/structures/ComponentInteraction.ts index 91481d7..8ea04d3 100644 --- a/lib/structures/ComponentInteraction.ts +++ b/lib/structures/ComponentInteraction.ts @@ -203,6 +203,7 @@ export class ComponentInteraction> { if (this.acknowledged) throw new Error("Cannot edit parent interaction that has already been acknowledged."); this.acknowledged = true; + // TODO: Add alternative REST execution if not cached. return this.message!.edit(newMessage); } diff --git a/lib/structures/Message.ts b/lib/structures/Message.ts index 2d4537b..eb45e0e 100644 --- a/lib/structures/Message.ts +++ b/lib/structures/Message.ts @@ -421,12 +421,7 @@ export class Message extends Base { * @param newMessage New message's options */ async edit(newMessage: EditMessageOptions): Promise> { - if (newMessage["components" as keyof object]) this.components = newMessage["components" as keyof object]; - if (this.components) { - await this.client.rest.channels.bulkDeleteReactions(this.channelID, "ChannelMessage", this.id); - await this.client.util.bulkAddComponents(this.channelID, this.components, this, false); - } - return this.client.rest.channels.editMessage( + const editedMessage = this.client.rest.channels.editMessage( this.channelID, this.id as string, newMessage, @@ -437,6 +432,12 @@ export class Message extends Base { } } ); + if (newMessage["components" as keyof object]) this.components = newMessage["components" as keyof object]; + if (this.components) { + await this.client.rest.channels.bulkDeleteReactions(this.channelID, "ChannelMessage", this.id); + await this.client.util.bulkAddComponents(this.channelID, this.components, this, false); + } + return editedMessage; } /**