From 359ba92f636bae97393015050d216fea19c8bba8 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 22 Jul 2022 08:44:36 -0600 Subject: [PATCH] add botthread and thread botask too --- bot/src/reactions/reactions.ts | 39 ++++++++++++++++++++++++++++---- package.json | 4 ++-- scripts/bot-emoji/botask.png | Bin 3606 -> 3635 bytes scripts/bot-emoji/botthread.png | Bin 0 -> 3635 bytes 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 scripts/bot-emoji/botthread.png diff --git a/bot/src/reactions/reactions.ts b/bot/src/reactions/reactions.ts index 02a3a35..39af99a 100644 --- a/bot/src/reactions/reactions.ts +++ b/bot/src/reactions/reactions.ts @@ -19,6 +19,7 @@ const reactions: Record = { botremixmusic: remixMusic, botreportresume: reportResume, botask: ask, + botthread: thread, botdoublemsg: doubleMessage, } as const; @@ -169,11 +170,24 @@ reportResume.description = `Replies to the message explaining that this channel async function ask(messageReaction: TDiscord.MessageReaction) { void messageReaction.remove(); - await messageReaction.message.reply( - `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 (especially the part about making a ) and then we'll try to answer your question.` - ); + 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 (especially the part about making a ) and then we'll try to answer your question.`; + const { channel, author, guild, id } = messageReaction.message; + if (!guild || !channel || !author) return; + + if (channel.type === "GUILD_TEXT") { + const thread = await channel.threads.create({ + name: `๐Ÿงต Thread for ${author.username}`, + startMessage: id, + }); + await thread.send(reply); + await thread.send( + "Feel free to change the thread title to something more descriptive if you like." + ); + } else { + await messageReaction.message.reply(reply); + } } -ask.description = `Replies to the message asking for more details about a question.`; +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.`; async function doubleMessage(messageReaction: TDiscord.MessageReaction) { void messageReaction.remove(); @@ -183,4 +197,21 @@ async function doubleMessage(messageReaction: TDiscord.MessageReaction) { } doubleMessage.description = `Replies to the message telling the user to avoid posting the same question in multiple channels.`; +async function thread(messageReaction: TDiscord.MessageReaction) { + void messageReaction.remove(); + const { channel, author, guild, id } = messageReaction.message; + if (!guild || !channel || !author) return; + + if (channel.type === "GUILD_TEXT") { + const thread = await channel.threads.create({ + name: `๐Ÿงต Thread for ${author.username}`, + startMessage: id, + }); + await thread.send( + `Hi ${author} ๐Ÿ‘‹\nLet's discuss this further here. Feel free to change the thread title to something more descriptive if you like.` + ); + } +} +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.`; + export default reactions; diff --git a/package.json b/package.json index 8e9c2cf..c448cef 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "build": "run-s build:*", "build:css": "npm run generate:css -- --minify", "build:remix": "remix build", - "build:bot": "node ./other/build-bot.js", - "build:info": "node ./other/generate-build-info.js", + "build:bot": "node ./scripts/build-bot.js", + "build:info": "node ./scripts/generate-build-info.js", "dev": "run-p dev:*", "dev:css": "npm run generate:css -- --watch", "dev:remix": "cross-env NODE_ENV=development binode --require ./mocks --require ./bot -- @remix-run/dev:remix dev", diff --git a/scripts/bot-emoji/botask.png b/scripts/bot-emoji/botask.png index d7940557d47f2bff9cbc65e2fdd0454aa0e9c97f..caa35c95ea825c6eac5b83b92855c1a02b993ed7 100644 GIT binary patch literal 3635 zcmV-34$Se1P)C00093P)t-sM{rDL z&3A9dcNR*^$$(0yweF8+ zO{}cuag6ViW4qEl_{<%^(K@)%KTD*v-cq#UHe?#Q{`%vOsBH^!YAr9ee}XB;W($;IlU4{ zgKXDnbl79;%_QZ{C*x$E@}E*lrM245EZ;`0_O3whwmtNwN!mcn{mL8g%pbPWLG`Ud z;aRKy|Njya5>m6J={A2;wV~)Xgjlu%O{=d^ zu&CNR%-K880U&e&*k!G3IPw&nm^rcMTTB?WFSzyV5 zh=_=d*H-F)d)-OE+e63mo>ls}GTu(P-&C^VV59AdZj;ti=*}j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