/// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> public static async Task <GuildEmote> ModifyEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, Action <EmoteProperties> func, RequestOptions options) { if (func == null) { throw new ArgumentNullException(paramName: nameof(func)); } EmoteProperties props = new EmoteProperties(); func(props); ModifyGuildEmoteParams apiargs = new ModifyGuildEmoteParams { Name = props.Name }; if (props.Roles.IsSpecified) { apiargs.RoleIds = props.Roles.Value?.Select(xr => xr.Id).ToArray(); } API.EmojiJson emote = await client.ApiClient.ModifyGuildEmoteAsync(guild.Id, id, apiargs, options).ConfigureAwait(false); return(emote.ToEntity()); }
public static IEmote ToIEmote(this API.EmojiJson model) { if (model.Id.HasValue) { return(model.ToEntity()); } return(new Emoji(model.Name)); }
public static GuildEmote ToEntity(this API.EmojiJson model) => new GuildEmote(model.Id.Value, model.Name, model.Animated.GetValueOrDefault(), model.Managed, model.RequireColons, ImmutableArray.Create(model.Roles), model.User.IsSpecified ? model.User.Value.Id : (ulong?)null);
public static async Task <GuildEmote> CreateEmoteAsync(IGuild guild, BaseDiscordClient client, string name, Image image, Optional <IEnumerable <IRole> > roles, RequestOptions options) { CreateGuildEmoteParams apiargs = new CreateGuildEmoteParams { Name = name, Image = image.ToModel() }; if (roles.IsSpecified) { apiargs.RoleIds = roles.Value?.Select(xr => xr.Id).ToArray(); } API.EmojiJson emote = await client.ApiClient.CreateGuildEmoteAsync(guild.Id, apiargs, options).ConfigureAwait(false); return(emote.ToEntity()); }
//Emotes public static async Task <GuildEmote> GetEmoteAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options) { API.EmojiJson emote = await client.ApiClient.GetGuildEmoteAsync(guild.Id, id, options).ConfigureAwait(false); return(emote.ToEntity()); }