call deferUpdate on interactions

This commit is contained in:
MapleLeaf
2021-12-22 13:52:55 -06:00
parent e2c45c2f8e
commit 7431ec7f9a
2 changed files with 82 additions and 20 deletions

View File

@@ -11,6 +11,10 @@ import { collectInteractionHandlers, getMessageOptions } from "./node-tree.js"
type Action =
| { type: "updateMessage"; tree: MessageNode }
| { type: "deleteMessage" }
| {
type: "interaction.deferUpdate"
interaction: MessageComponentInteraction
}
export class MessageRenderer {
private channel: TextBasedChannels
@@ -42,6 +46,7 @@ export class MessageRenderer {
collector.on("collect", (interaction) => {
const handler = this.getInteractionHandler(interaction.customId)
if (handler?.type === "button" && interaction.isButton()) {
this.actions.unshift({ type: "interaction.deferUpdate", interaction })
handler.onClick(interaction)
}
})
@@ -119,5 +124,9 @@ export class MessageRenderer {
await this.message?.delete()
this.message = undefined
}
if (action.type === "interaction.deferUpdate") {
await action.interaction.deferUpdate()
}
}
}