From 6756dadcf42bcb31685b0fbb8f92e25bf08bcde3 Mon Sep 17 00:00:00 2001 From: Skillz Date: Sun, 9 Aug 2020 14:52:39 -0400 Subject: [PATCH] addReactions function to add multiple reactions --- src/handlers/message.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/handlers/message.ts b/src/handlers/message.ts index a4bbc734e..bf01b2f9f 100644 --- a/src/handlers/message.ts +++ b/src/handlers/message.ts @@ -67,7 +67,7 @@ export function addReaction( messageID: string, reaction: string, ) { - RequestManager.put( + return RequestManager.put( endpoints.CHANNEL_MESSAGE_REACTION_ME( channelID, messageID, @@ -76,6 +76,24 @@ export function addReaction( ); } +/** Adds multiple reactions to a message. If `ordered` is true(default is false), it will add the reactions one at a time in the order provided. Note: Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */ +export async function addReactions( + channelID: string, + messageID: string, + reactions: string[], + ordered = false, +) { + if (!ordered) { + reactions.forEach((reaction) => + addReaction(channelID, messageID, reaction) + ); + } else { + for (const reaction of reactions) { + await addReaction(channelID, messageID, reaction) + } + } +} + /** Removes a reaction from the bot on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */ export function removeReaction( channelID: string,