@stonyx/discord 0.1.1-alpha.17 → 0.1.1-alpha.18

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.
Files changed (2) hide show
  1. package/README.md +13 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -180,6 +180,15 @@ All methods are on the `DiscordBot` instance (accessible via `this._bot` in comm
180
180
 
181
181
  Send a text message to a channel. Optionally attach an image file.
182
182
 
183
+ Messages are delivered reliably across connection state transitions:
184
+ - If the bot is **ready**, the message is sent immediately.
185
+ - If the bot is **connecting or disconnected**, the message is queued and auto-delivered when the connection resumes.
186
+ - **Transient failures** (5xx, network errors) are retried up to 3 times with exponential backoff.
187
+ - Queued messages expire after **5 minutes** (TTL) — stale messages are rejected rather than sent late.
188
+ - The queue holds up to **1000** messages; excess messages are rejected with a "queue full" error.
189
+
190
+ The returned promise resolves when the message is actually delivered or rejects on permanent failure.
191
+
183
192
  ```javascript
184
193
  await bot.sendMessage('Hello world', '123456789');
185
194
  await bot.sendMessage('Check this out', '123456789', './screenshot.png');
@@ -289,8 +298,8 @@ Configuration is read from `stonyx/config` under `discord`:
289
298
  | `commands` | `Object` — registered command instances keyed by name |
290
299
  | `eventHandlers` | `Array` — registered event handler instances |
291
300
  | `client` | Discord.js `Client` instance (after init) |
292
- | `ready` | `Promise` — resolves when the bot is connected and ready |
293
- | `sendMessage(content, channelId, imagePath?)` | Send a message to a channel |
301
+ | `ready` | `Promise` — resolves when the bot is connected and ready; re-pends on gateway disconnects |
302
+ | `sendMessage(content, channelId, imagePath?)` | Send a message to a channel (queues during disconnections, retries transient failures) |
294
303
  | `sendFile(file, messageObject)` | Replace a message with a file attachment |
295
304
  | `reply(interaction, content)` | Reply with auto-chunking |
296
305
  | `updateStatus(name, type?)` | Set bot presence |
@@ -299,8 +308,8 @@ Configuration is read from `stonyx/config` under `discord`:
299
308
  | `getGuild(guildId?)` | Fetch a guild |
300
309
  | `clearChannelMessages(channelId)` | Delete messages in a channel; returns `{ deleted, failed, errors }` and never throws on partial failure |
301
310
  | `giveRole(memberId, roleId)` | Add a role to a member |
302
- | `close()` | Destroy the Discord client and clear singleton |
303
- | `reset()` | Close + clear all commands and handlers |
311
+ | `close()` | Destroy the Discord client, reject pending queue, clear singleton |
312
+ | `reset()` | Close + clear all commands, handlers, and connection state |
304
313
 
305
314
  ### Command
306
315
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "stonyx-async",
5
5
  "stonyx-module"
6
6
  ],
7
- "version": "0.1.1-alpha.17",
7
+ "version": "0.1.1-alpha.18",
8
8
  "description": "Discord bot module for the Stonyx framework",
9
9
  "main": "dist/main.js",
10
10
  "types": "dist/main.d.ts",