Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit 023359e

Browse files
kdevjxn-30
andcommitted
🐛fix bug with recreating threads
Co-Authored-By: Jan <[email protected]>
1 parent 4cc8950 commit 023359e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/bot.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ WebhookEvent.on('post', async (post) => {
2525

2626
const channel = await client.channels.fetch(process.env.CHANNEL_ID);
2727

28-
let thread = (
29-
await channel.threads.fetch(null, { force: true })
30-
).threads.find((th) => th.name === matches[0]);
31-
32-
if (!thread) {
33-
thread = await channel.threads.create({
34-
name: matches[0],
35-
});
36-
}
28+
const allThreads = (
29+
await channel.threads.fetchActive(false)
30+
).threads.concat((await channel.threads.fetchArchived(false)).threads);
31+
32+
let thread = allThreads.find((th) => th.name === matches[0]);
33+
34+
thread ??= await channel.threads.create({
35+
name: matches[0],
36+
});
3737

3838
thread.send({ embeds: post.embeds });
3939
});

0 commit comments

Comments
 (0)