| @@ -1,10 +1,6 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| public interface IEmote | |||||
| public interface IEmote : IMentionable // TODO: Is `Mention` the correct verbage here? | |||||
| { | { | ||||
| string Name { get; } | string Name { get; } | ||||
| } | } | ||||
| @@ -1,7 +1,44 @@ | |||||
| using System.Collections.Generic; | |||||
| using System.Threading.Tasks; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| public interface IGuildEmote : IEmote | |||||
| public interface IGuildEmote : IEmote, ISnowflakeEntity, IDeletable | |||||
| { | { | ||||
| // TODO | |||||
| /// <summary> | |||||
| /// Gets whether this emoji is managed by an integration. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A boolean that determines whether or not this emote is managed by a Twitch integration. | |||||
| /// </returns> | |||||
| bool IsManaged { get; } | |||||
| /// <summary> | |||||
| /// Gets whether this emoji must be wrapped in colons. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A boolean that determines whether or not this emote requires the use of colons in chat to be used. | |||||
| /// </returns> | |||||
| bool RequireColons { get; } | |||||
| /// <summary> | |||||
| /// Gets the roles that are allowed to use this emoji. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// A read-only list containing snowflake identifiers for roles that are allowed to use this emoji. | |||||
| /// </returns> | |||||
| IReadOnlyList<IRole> Roles { get; } | |||||
| /// <summary> | |||||
| /// Gets the user ID associated with the creation of this emoji. | |||||
| /// </summary> | |||||
| /// <returns> | |||||
| /// An <see cref="ulong"/> snowflake identifier representing the user who created this emoji; | |||||
| /// <c>null</c> if unknown. | |||||
| /// </returns> | |||||
| ulong? CreatorId { get; } | |||||
| /// <summary> | |||||
| /// Gets the guild this emote sourced from. | |||||
| /// </summary> | |||||
| IGuild Guild { get; } | |||||
| Task ModifyAsync(); // TODO | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| @@ -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<IRole> 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(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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 | |||||
| } | |||||
| } | |||||
| @@ -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); | |||||
| } | |||||
| } | |||||