diff --git a/src/Discord.Net/Entities/Emotes/IEmote.cs b/src/Discord.Net/Entities/Emotes/IEmote.cs index 4c90610a3..12b7e283c 100644 --- a/src/Discord.Net/Entities/Emotes/IEmote.cs +++ b/src/Discord.Net/Entities/Emotes/IEmote.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace Discord { - public interface IEmote + public interface IEmote : IMentionable // TODO: Is `Mention` the correct verbage here? { string Name { get; } } diff --git a/src/Discord.Net/Entities/Emotes/IGuildEmote.cs b/src/Discord.Net/Entities/Emotes/IGuildEmote.cs index 92d0de045..11dc9eec3 100644 --- a/src/Discord.Net/Entities/Emotes/IGuildEmote.cs +++ b/src/Discord.Net/Entities/Emotes/IGuildEmote.cs @@ -1,7 +1,44 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + namespace Discord { - public interface IGuildEmote : IEmote + public interface IGuildEmote : IEmote, ISnowflakeEntity, IDeletable { - // TODO + /// + /// Gets whether this emoji is managed by an integration. + /// + /// + /// A boolean that determines whether or not this emote is managed by a Twitch integration. + /// + bool IsManaged { get; } + /// + /// Gets whether this emoji must be wrapped in colons. + /// + /// + /// A boolean that determines whether or not this emote requires the use of colons in chat to be used. + /// + bool RequireColons { get; } + /// + /// Gets the roles that are allowed to use this emoji. + /// + /// + /// A read-only list containing snowflake identifiers for roles that are allowed to use this emoji. + /// + IReadOnlyList Roles { get; } + /// + /// Gets the user ID associated with the creation of this emoji. + /// + /// + /// An snowflake identifier representing the user who created this emoji; + /// null if unknown. + /// + ulong? CreatorId { get; } + /// + /// Gets the guild this emote sourced from. + /// + IGuild Guild { get; } + + Task ModifyAsync(); // TODO } } diff --git a/src/Discord.Net/Entities/Guilds/IGuild.cs b/src/Discord.Net/Entities/Guilds/IGuild.cs index 8375ccae3..6690d79e4 100644 --- a/src/Discord.Net/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net/Entities/Guilds/IGuild.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Generic; -using System.Text; namespace Discord { diff --git a/src/Discord.Net/Models/Emotes/AttachedGuildEmote.cs b/src/Discord.Net/Models/Emotes/AttachedGuildEmote.cs new file mode 100644 index 000000000..c2da51b8b --- /dev/null +++ b/src/Discord.Net/Models/Emotes/AttachedGuildEmote.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Model = Wumpus.Entities.Emoji; + +namespace Discord +{ + internal class AttachedGuildEmote : SnowflakeEntity, IGuildEmote + { + public AttachedGuildEmote(Model model, IGuild guild, IDiscordClient discord) : base(discord) + { + IsManaged = model.Managed.GetValueOrDefault(false); + RequireColons = model.RequireColons.GetValueOrDefault(false); + + Wumpus.Snowflake[] roleIds = model.RoleIds.GetValueOrDefault() ?? new Wumpus.Snowflake[0]; + Role[] roles = new Role[roleIds.Length]; + for (int i = 0; i < roleIds.Length; i++) + roles[i] = null; // TODO guild.GetRole() + Roles = roles; + + CreatorId = model.User.IsSpecified ? model.User.Value.Id : (ulong?)null; // TODO: EntityOrId this guy + Name = model.Name.ToString(); + Guild = guild; + } + + public bool IsManaged { get; set; } + public bool RequireColons { get; set; } + public IReadOnlyList Roles { get; set; } + public ulong? CreatorId { get; set; } + public string Name { get; set; } + public IGuild Guild { get; set; } + + // IMentionable + public string Mention => throw new System.NotImplementedException(); + + public Task DeleteAsync() + => Discord.Rest.DeleteGuildEmojiAsync(Guild.Id, Id); + + public Task ModifyAsync() // TODO + { + throw new System.NotImplementedException(); + } + } +} diff --git a/src/Discord.Net/Models/Emotes/Emoji.cs b/src/Discord.Net/Models/Emotes/Emoji.cs new file mode 100644 index 000000000..8261e780a --- /dev/null +++ b/src/Discord.Net/Models/Emotes/Emoji.cs @@ -0,0 +1,14 @@ +namespace Discord +{ + internal class Emoji : IEmote + { + public Emoji(string name) + { + // TODO: validation? + Name = name; + } + + public string Name { get; set; } + public string Mention => Name; + } +} diff --git a/src/Discord.Net/Models/Emotes/Emote.cs b/src/Discord.Net/Models/Emotes/Emote.cs new file mode 100644 index 000000000..80bf8ce63 --- /dev/null +++ b/src/Discord.Net/Models/Emotes/Emote.cs @@ -0,0 +1,18 @@ +namespace Discord +{ + // placeholder for user-constructed guild emotes + // TODO: naming - should be called GuildEmote? but does not impl IGuildEmote, so maybe not... + internal class Emote : IEmote + { + public Emote(ulong id, string name) + { + Id = id; + Name = name; + } + + public ulong Id { get; set; } + public string Name { get; set; } + + public string Mention => throw new System.NotImplementedException(); // TODO: EmojiUtils + } +} diff --git a/src/Discord.Net/Models/Emotes/EmoteBuilder.cs b/src/Discord.Net/Models/Emotes/EmoteBuilder.cs new file mode 100644 index 000000000..86a1ce38b --- /dev/null +++ b/src/Discord.Net/Models/Emotes/EmoteBuilder.cs @@ -0,0 +1,14 @@ +using System; + +namespace Discord +{ + public static class EmoteBuilder + { + public static IEmote FromEmoji(string emoji) + => new Emoji(emoji); + public static IEmote FromMention(string mention) + => throw new NotImplementedException(); // TODO: emoteutil + public static IEmote FromID(ulong id, string name) + => new Emote(id, name); + } +}