@songsid/agend-plugin-discord 0.0.17-beta.3 → 0.0.17-beta.5

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.
@@ -369,27 +369,9 @@ export class DiscordAdapter extends EventEmitter {
369
369
  }
370
370
  async react(chatId, messageId, emoji) {
371
371
  try {
372
- // Try chatId as channel ID first (Discord classic bot passes channelId as chatId)
373
- try {
374
- const ch = await this._fetchTextChannel(chatId);
375
- const msg = await ch.messages.fetch(messageId);
376
- await msg.react(emoji);
377
- return;
378
- }
379
- catch { /* not found in this channel, search guild */ }
380
- const guild = await this.client.guilds.fetch(this.guildId);
381
- const channels = guild.channels.cache.filter((c) => c.type === ChannelType.GuildText);
382
- for (const [, ch] of channels) {
383
- try {
384
- const textCh = ch;
385
- const msg = await textCh.messages.fetch(messageId);
386
- await msg.react(emoji);
387
- return;
388
- }
389
- catch {
390
- continue;
391
- }
392
- }
372
+ // Direct REST call single API request instead of 3 (fetchChannel fetchMessage → react)
373
+ const encoded = encodeURIComponent(emoji);
374
+ await this.client.rest.put(`/channels/${chatId}/messages/${messageId}/reactions/${encoded}/@me`);
393
375
  }
394
376
  catch {
395
377
  // No-op per degradation strategy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songsid/agend-plugin-discord",
3
- "version": "0.0.17-beta.3",
3
+ "version": "0.0.17-beta.5",
4
4
  "description": "Discord channel adapter plugin for AgEnD",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,7 +9,7 @@
9
9
  "build": "tsc"
10
10
  },
11
11
  "peerDependencies": {
12
- "@songsid/agend": ">=0.0.17-beta.3"
12
+ "@songsid/agend": ">=0.0.17-beta.5"
13
13
  },
14
14
  "dependencies": {
15
15
  "discord.js": "^14.25.1"
@@ -408,28 +408,11 @@ export class DiscordAdapter extends EventEmitter implements ChannelAdapter {
408
408
 
409
409
  async react(chatId: string, messageId: string, emoji: string): Promise<void> {
410
410
  try {
411
- // Try chatId as channel ID first (Discord classic bot passes channelId as chatId)
412
- try {
413
- const ch = await this._fetchTextChannel(chatId);
414
- const msg = await ch.messages.fetch(messageId);
415
- await msg.react(emoji);
416
- return;
417
- } catch { /* not found in this channel, search guild */ }
418
-
419
- const guild = await this.client.guilds.fetch(this.guildId);
420
- const channels = guild.channels.cache.filter(
421
- (c: { type: ChannelType }) => c.type === ChannelType.GuildText,
411
+ // Direct REST call single API request instead of 3 (fetchChannel fetchMessage → react)
412
+ const encoded = encodeURIComponent(emoji);
413
+ await (this.client as any).rest.put(
414
+ `/channels/${chatId}/messages/${messageId}/reactions/${encoded}/@me`
422
415
  );
423
- for (const [, ch] of channels) {
424
- try {
425
- const textCh = ch as TextChannel;
426
- const msg = await textCh.messages.fetch(messageId);
427
- await msg.react(emoji);
428
- return;
429
- } catch {
430
- continue;
431
- }
432
- }
433
416
  } catch {
434
417
  // No-op per degradation strategy
435
418
  }