@tusile/bot 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -90,10 +90,14 @@ await i.acknowledge(); // a press that needs no visible change
90
90
  A private answer is not channel history: nobody else ever sees it, it is not searchable or
91
91
  exportable, and it is gone within a day.
92
92
 
93
- If a handler takes longer than eight seconds, the SDK defers on its behalf rather than let
94
- the window run out. If a handler throws, or returns without answering, the person is told
95
- something went wrong instead of being left watching a spinner, and the error reaches
96
- `bot.on('error')`.
93
+ If a command or form handler takes longer than eight seconds, the SDK defers on its behalf
94
+ rather than let the window run out. A button handler is left alone: a press is answered by
95
+ rewriting the message it sits on, and that is only available before the interaction has
96
+ been answered at all, so deferring for you would trade a late answer for one that cannot be
97
+ given. A slow press should defer and `followUp`.
98
+
99
+ If a handler throws, or returns without answering, the person is told something went wrong
100
+ instead of being left watching a spinner, and the error reaches `bot.on('error')`.
97
101
 
98
102
  ## Embeds and controls
99
103
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tusile/bot",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Write a Tusile bot: slash commands, buttons, forms and voice, over an outbound WebSocket.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/dispatch.js CHANGED
@@ -120,9 +120,14 @@ export class Dispatcher {
120
120
  *
121
121
  * Cancelled the moment the handler returns, and it checks again before sending: an
122
122
  * unasked-for defer arriving after a normal answer would be refused every time.
123
+ *
124
+ * Not for a press. A press is answered by rewriting the message it sits on, and that is
125
+ * only available before the interaction has been answered at all; after a bare defer the
126
+ * server has no message to edit and refuses. Deferring on the handler's behalf would
127
+ * trade a late answer for one that cannot be given, and leave the buttons live.
123
128
  */
124
129
  #deferAfterAWhile(interaction) {
125
- if (!(this.#autoDeferMs > 0)) return { cancel() {} };
130
+ if (!(this.#autoDeferMs > 0) || interaction.isComponent) return { cancel() {} };
126
131
  const timer = setTimeout(() => {
127
132
  if (interaction.answered) return;
128
133
  interaction.defer().catch((err) => this.#onError(err, interaction));