Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Deprecate FormatEmojiAPI in favor of a simpler function #42

Closed
mavolin opened this issue May 11, 2020 · 4 comments · Fixed by #50
Closed

API: Deprecate FormatEmojiAPI in favor of a simpler function #42

mavolin opened this issue May 11, 2020 · 4 comments · Fixed by #50

Comments

@mavolin
Copy link
Contributor

mavolin commented May 11, 2020

FormatEmojiAPI takes two parameters, the first one being optional, which is not very idiomatic.
Also FormatEmojiAPI doesn't even return a EmojiAPI type, but a string.
Also, if we're doing this APIEmoji might be a better name, since this is an emoji used by the API and not an API for emojis.
Therefore, I propose to either deprecate or delete FormatEmojiAPI in favor of two new functions:

func NewAPIEmojiFromGuildEmoji(id discord.Snowflake, name string) APIEmoji {
    return name+":"+id.String()
}

func NewAPIEmojiFromUnicode(emoji string) APIEmoji {
    return name
}

Additionally, APIEmoji should get a URLEncode() string method, that URL encodes the emoji for safe API usage.

Can hand in a PR for this

@diamondburned
Copy link
Owner

You're only supposed to use NewAPIEmoji for custom emojis anyway, there's no point in using it for normal emojis. This could be documented instead of having a dummy function return the same string.

@mavolin
Copy link
Contributor Author

mavolin commented May 11, 2020

But it's used by React which allows reactions with custom and with built in/unicode emojis.

@diamondburned
Copy link
Owner

Well, yes, but APIEmoji is just a type alias to string; it's only meant to add extra connotation on the differences of syntax for custom emojis between contexts (messages, in code, in API).

@mavolin
Copy link
Contributor Author

mavolin commented May 11, 2020

K, I'll replace it with a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants