Skip to content

Add overloads of reaction methods accepting a string parameter for the emoji

Mateusz Brawański requested to merge github/fork/orchidalloy/patch-1 into master

Created by: orchidalloy

Summary

Implements overloads for CreateReactionAsync, DeleteOwnReactionAsync, DeleteReactionAsync and DeleteReactionsEmojiAsync accepting a string parameter.

Reasoning

You only need to know the unicode representation (or the name and ID) of an emoji/guild emoji to be able to use it in reactions. Giving the user the option to use a string instead of the more complex DiscordEmoji object increases flexibility, versatility and elegance. I believe this feature was clearly missing from the library, as it appears it was even intended for these overloads to exist.

Details

Adds a private static regex member and a private static method to convert a guild emoji string from <a:name:id> (standard mention) into name:id (valid for internal reaction requests). Does nothing if it was already name:id or if it was a unicode emoji.

This method is then used in all the new method overloads.

Notes

I tested the regex here: https://regexr.com/5d2gs

Merge request reports

Loading