Skip to content

Commit bccbeda

Browse files
authored
fix(experimental): race conditions in thread creation (#480)
1 parent 7ef5064 commit bccbeda

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

src/features/looking-for-group.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
} from "discord.js";
1111
import { CHANNELS } from "../constants/channels.js";
1212
import { EMBED_COLOR } from "./commands.js";
13+
import { retry } from "./retry.js";
14+
import { logger } from "./log.js";
1315

1416
const LOCK_POST = "lock-post";
1517

@@ -47,30 +49,37 @@ export const lookingForGroup = async (bot: Client) => {
4749
return;
4850
}
4951

50-
await thread.send({
51-
embeds: [
52-
{
53-
title: "Looking For Group",
54-
type: EmbedType.Rich,
55-
description: `Projects in this space must be open source licensed and may not be commercially monetized — this is a place for enthusiastic collaboration, and anyone found to be exploiting in any manner, especially for free labor, will be moderatated as a hostile actor.
52+
try {
53+
await retry(thread.fetchStarterMessage);
54+
await thread.send({
55+
embeds: [
56+
{
57+
title: "Looking For Group",
58+
type: EmbedType.Rich,
59+
description: `Projects in this space must be open source licensed and may not be commercially monetized — this is a place for enthusiastic collaboration, and anyone found to be exploiting in any manner, especially for free labor, will be moderatated as a hostile actor.
5660
5761
Please do not routinely re-post your own skills. This is a forum, not a chat channel, prefer to bump your old post by replying to it (maybe with an update about what you've been working on?)
5862
5963
Reactiflux moderators cannot moderate behavior outside of the public channels. If you suspect someone is taking advantage of your generosity, block and move on. Before you accuse someone of being a bot or scammer, though, consider if there might be a language and cultural barrier.
6064
6165
Post authors: Once you've found collaborators or a project to contribute to, please lock your post to indicate that you're no longer seeking responses 🙏`,
62-
color: EMBED_COLOR,
63-
},
64-
],
65-
components: [
66-
// @ts-expect-error Discord.js types appear to be wrong
67-
new ActionRowBuilder().addComponents(
68-
new ButtonBuilder()
69-
.setCustomId(LOCK_POST)
70-
.setLabel("Lock post")
71-
.setStyle(ButtonStyle.Danger),
72-
),
73-
],
74-
});
66+
color: EMBED_COLOR,
67+
},
68+
],
69+
components: [
70+
// @ts-expect-error Discord.js types appear to be wrong
71+
new ActionRowBuilder().addComponents(
72+
new ButtonBuilder()
73+
.setCustomId(LOCK_POST)
74+
.setLabel("Lock post")
75+
.setStyle(ButtonStyle.Danger),
76+
),
77+
],
78+
});
79+
} catch (e) {
80+
if (e instanceof Error) {
81+
logger.log("looking for group threadCreate: ", e);
82+
}
83+
}
7584
});
7685
};

0 commit comments

Comments
 (0)