Skip to content

Commit 87e3828

Browse files
committed
support reacting to a post to add tags
1 parent 6538143 commit 87e3828

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/modules/helpForum.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ const howToGiveHelp = listify(`
5555
**How To Give *Better* Help**
5656
- Get yourself the <@&${trustedRoleId}> role at <#${rolesChannelId}>
5757
- (If you don't like the pings, you can disable role mentions for the server.)
58-
- As a <@&${trustedRoleId}>, if a thread appears to be resolved, run \`!resolved\` to mark it as such.
59-
- *Only do this if the asker has indicated that their question has been resolved.*
58+
- As a <@&${trustedRoleId}>, you can:
59+
- React to a help post to add tags.
60+
- If a post appears to be resolved, run \`!resolved\` to mark it as such.
61+
- *Only do this if the asker has indicated that their question has been resolved.*
6062
- Conversely, you can run \`!reopen\` if the asker has follow-up questions.
6163
6264
**Useful Snippets**
@@ -202,6 +204,28 @@ export async function helpForumModule(bot: Bot) {
202204
},
203205
});
204206

207+
bot.client.on('messageReactionAdd', async reaction => {
208+
const message = reaction.message;
209+
const thread = await message.channel.fetch();
210+
if (!isHelpThread(thread)) {
211+
return;
212+
}
213+
const initial = await thread.fetchStarterMessage();
214+
if (initial?.id !== message.id) return;
215+
const tag = forumChannel.availableTags.find(
216+
t =>
217+
t.emoji &&
218+
!t.moderated &&
219+
t.emoji.id === reaction.emoji.id &&
220+
t.emoji.name === reaction.emoji.name,
221+
);
222+
if (!tag) return;
223+
if (thread.appliedTags.length < MAX_TAG_COUNT) {
224+
await thread.setAppliedTags([...thread.appliedTags, tag.id]);
225+
}
226+
await reaction.remove();
227+
});
228+
205229
async function changeStatus(msg: Message, resolved: boolean) {
206230
const thread = msg.channel;
207231
if (thread?.type !== ChannelType.PublicThread) {

0 commit comments

Comments
 (0)