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

Implemented emoji endpoints #835

Merged
merged 3 commits into from
Nov 20, 2017
Merged

Implemented emoji endpoints #835

merged 3 commits into from
Nov 20, 2017

Conversation

Emzi0767
Copy link
Contributor

@Emzi0767 Emzi0767 commented Oct 1, 2017

This PR implements the emoji endpoints, as documented here. This enables bots to manipulate guild emoji.

in action

There is one caveat, however. Bots are only able to get, modify, and delete emoji they've created. They can, however, list all emoji, but it requires manage emoji permission.

Everything is tested, and it works.

@Emzi0767 Emzi0767 changed the title Implement emoji endpoits Implemented emoji endpoits Oct 1, 2017
/// <summary> Creates a new emote in this guild. </summary>
Task<GuildEmote> CreateEmoteAsync(string name, Image image, Optional<IEnumerable<IRole>> roles = default(Optional<IEnumerable<IRole>>), RequestOptions options = null);
/// <summary> Modifies an existing emote in this guild. </summary>
Task<GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action<EmoteProperties> func, RequestOptions options = null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason these methods were left on IGuild instead of GuildEmote?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GuildEmote does not hold the Guild object required for this to work. This would require some deeper changes, and I didn't feel confident enough to make them without some guidance.

@@ -117,5 +117,16 @@ public interface IGuild : IDeletable, ISnowflakeEntity
Task DownloadUsersAsync();
/// <summary> Removes all users from this guild if they have not logged on in a provided number of days or, if simulate is true, returns the number of users that would be removed. </summary>
Task<int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null);

/// <summary> Gets a collection of all emotes in this guild. </summary>
Task<IReadOnlyCollection<GuildEmote>> ListEmotesAsync(RequestOptions options = null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this already exist in the form of IGuild.Emotes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also exists in the API. See: linked Discord API documentation.

Copy link
Contributor

@ObsidianMinor ObsidianMinor Oct 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an advantage or reason to run ListEmotesAsync (which should probably be GetEmotesAsync) vs reading the cached collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, not really. But it exists, so I implemented it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to just leave this off - we can always readd it if there's any API changes that make it necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A'ight, is commenting out acceptable? Will make it easier to re-add later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's only 10 lines, just remove it

@Emzi0767 Emzi0767 changed the title Implemented emoji endpoits Implemented emoji endpoints Oct 7, 2017
@foxbot foxbot merged commit b4bf046 into discord-net:dev Nov 20, 2017
FiniteReality pushed a commit to FiniteReality/Discord.Net that referenced this pull request May 5, 2018
* Implemented emoji endpoints.

* Fixed: now using API entities for REST client.

* Removed emoji listing endpoint, as per @foxbot's request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants