Skip to content

Commit bb2a2e2

Browse files
committed
fix: update batch keys for threads
1 parent 2570db4 commit bb2a2e2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/util/webhookData.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ export default class WebhookData {
303303
// Update card-list pairing cache
304304
if (this.card && (this.list || this.listAfter)) cardListMapCache.set(this.card.id, [Date.now(), this.list ? this.list.id : this.listAfter.id]);
305305

306+
const webhookBatchKey = `${this.webhook.webhookID}${this.webhook.threadID ? `:${this.webhook.threadID}` : ''}`;
307+
306308
const EMBED_DEFAULTS = {
307309
default: {
308310
color: this.isChildAction() ? DEFAULT_COLORS.CHILD : DEFAULT_COLORS[this.filterFlag.split('_')[0]],
@@ -367,12 +369,12 @@ export default class WebhookData {
367369
maxTime: 2000,
368370
maxSize: 10,
369371
onBatch: (lines) => {
370-
createTemporaryBatcher(this.webhook.webhookID, lodash.defaultsDeep({ description: lines.join('\n') }, EMBED_DEFAULTS.compact), {
372+
createTemporaryBatcher(webhookBatchKey, lodash.defaultsDeep({ description: lines.join('\n') }, EMBED_DEFAULTS.compact), {
371373
maxTime: 1000,
372374
maxSize: 10,
373375
onBatch: (embeds) => {
374-
onWebhookSend(this.webhook.webhookID);
375-
logger.info('Posting webhook %s (guild=%s, time=%d)', this.webhook.webhookID, this.webhook.guildID, Date.now());
376+
onWebhookSend(webhookBatchKey);
377+
logger.info('Posting webhook %s (guild=%s, time=%d, thread=%s)', this.webhook.webhookID, this.webhook.guildID, Date.now(), this.webhook.threadID ?? 'none');
376378
return this._send(embeds);
377379
}
378380
});
@@ -381,12 +383,12 @@ export default class WebhookData {
381383
return;
382384
}
383385

384-
return createTemporaryBatcher(this.webhook.webhookID, lodash.defaultsDeep(embedStyles[this.webhook.style], EMBED_DEFAULTS[this.webhook.style]), {
386+
return createTemporaryBatcher(webhookBatchKey, lodash.defaultsDeep(embedStyles[this.webhook.style], EMBED_DEFAULTS[this.webhook.style]), {
385387
maxTime: 1000,
386388
maxSize: 10,
387389
onBatch: (embeds) => {
388-
onWebhookSend(this.webhook.webhookID);
389-
logger.info('Posting webhook %s (guild=%s, time=%d)', this.webhook.webhookID, this.webhook.guildID, Date.now());
390+
onWebhookSend(webhookBatchKey);
391+
logger.info('Posting webhook %s (guild=%s, time=%d, thread=%s)', this.webhook.webhookID, this.webhook.guildID, Date.now(), this.webhook.threadID ?? 'none');
390392
return this._send(embeds);
391393
}
392394
});

0 commit comments

Comments
 (0)