Skip to content

Commit 359ba92

Browse files
committed
add botthread and thread botask too
1 parent 6709cdf commit 359ba92

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

bot/src/reactions/reactions.ts

+35-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const reactions: Record<string, ReactionFn> = {
1919
botremixmusic: remixMusic,
2020
botreportresume: reportResume,
2121
botask: ask,
22+
botthread: thread,
2223
botdoublemsg: doubleMessage,
2324
} as const;
2425

@@ -169,11 +170,24 @@ reportResume.description = `Replies to the message explaining that this channel
169170

170171
async function ask(messageReaction: TDiscord.MessageReaction) {
171172
void messageReaction.remove();
172-
await messageReaction.message.reply(
173-
`We appreciate your question and we'll do our best to help you when we can. Could you please give us more details? Please follow the guidelines in <https://rmx.as/ask> (especially the part about making a <https://rmx.as/repro>) and then we'll try to answer your question.`
174-
);
173+
const reply = `Hi ${messageReaction.message.author} 👋\nWe appreciate your question and we'll do our best to help you when we can. Could you please give us more details? Please follow the guidelines in <https://rmx.as/ask> (especially the part about making a <https://rmx.as/repro>) and then we'll try to answer your question.`;
174+
const { channel, author, guild, id } = messageReaction.message;
175+
if (!guild || !channel || !author) return;
176+
177+
if (channel.type === "GUILD_TEXT") {
178+
const thread = await channel.threads.create({
179+
name: `🧵 Thread for ${author.username}`,
180+
startMessage: id,
181+
});
182+
await thread.send(reply);
183+
await thread.send(
184+
"Feel free to change the thread title to something more descriptive if you like."
185+
);
186+
} else {
187+
await messageReaction.message.reply(reply);
188+
}
175189
}
176-
ask.description = `Replies to the message asking for more details about a question.`;
190+
ask.description = `Creates a thread for the message and asks for more details about a question. Useful if you know the question needs more details, but you can't commit to replying when they come.`;
177191

178192
async function doubleMessage(messageReaction: TDiscord.MessageReaction) {
179193
void messageReaction.remove();
@@ -183,4 +197,21 @@ async function doubleMessage(messageReaction: TDiscord.MessageReaction) {
183197
}
184198
doubleMessage.description = `Replies to the message telling the user to avoid posting the same question in multiple channels.`;
185199

200+
async function thread(messageReaction: TDiscord.MessageReaction) {
201+
void messageReaction.remove();
202+
const { channel, author, guild, id } = messageReaction.message;
203+
if (!guild || !channel || !author) return;
204+
205+
if (channel.type === "GUILD_TEXT") {
206+
const thread = await channel.threads.create({
207+
name: `🧵 Thread for ${author.username}`,
208+
startMessage: id,
209+
});
210+
await thread.send(
211+
`Hi ${author} 👋\nLet's discuss this further here. Feel free to change the thread title to something more descriptive if you like.`
212+
);
213+
}
214+
}
215+
thread.description = `Creates a thread for the message. Handy if you know the message needs a thread, but you can't commit to participating in the conversation so you don't want to be the one to create it.`;
216+
186217
export default reactions;

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"build": "run-s build:*",
77
"build:css": "npm run generate:css -- --minify",
88
"build:remix": "remix build",
9-
"build:bot": "node ./other/build-bot.js",
10-
"build:info": "node ./other/generate-build-info.js",
9+
"build:bot": "node ./scripts/build-bot.js",
10+
"build:info": "node ./scripts/generate-build-info.js",
1111
"dev": "run-p dev:*",
1212
"dev:css": "npm run generate:css -- --watch",
1313
"dev:remix": "cross-env NODE_ENV=development binode --require ./mocks --require ./bot -- @remix-run/dev:remix dev",

scripts/bot-emoji/botask.png

29 Bytes
Loading

scripts/bot-emoji/botthread.png

3.55 KB
Loading

0 commit comments

Comments
 (0)