private static string FormatToExtension(StickerFormatType format) { return(format switch { StickerFormatType.None or StickerFormatType.Png or StickerFormatType.Apng => "png", // In the case of the Sticker endpoint, the sticker will be available as PNG if its format_type is PNG or APNG, and as Lottie if its format_type is LOTTIE. StickerFormatType.Lottie => "lottie", _ => throw new ArgumentException(nameof(format)), });
internal void Update(Model model) { PackId = model.PackId; Name = model.Name; Description = model.Description; Tags = model.Tags.IsSpecified ? model.Tags.Value.Split(',').Select(x => x.Trim()).ToArray() : Array.Empty <string>(); Type = model.Type; SortOrder = model.SortValue; IsAvailable = model.Available; Format = model.FormatType; }
public Sticker(StickerJsonModel model) { Id = model.Id; PackId = model.PackId; Name = model.Name; Description = model.Description; Tags = model.Tags.GetValueOrDefault(); AssetHash = model.Asset; PreviewAssetHash = model.PreviewAsset; FormatType = model.FormatType; }
internal Sticker(ulong id, ulong packId, string name, string description, string[] tags, string asset, string previewAsset, StickerFormatType formatType) { Id = id; PackId = packId; Name = name; Description = description; Tags = tags.ToReadOnlyCollection(); Asset = asset; PreviewAsset = previewAsset; FormatType = formatType; }
public static string GetStickerUrl(Snowflake stickerId, StickerFormatType format = StickerFormatType.Png) { Guard.IsDefined(format); var formatString = format switch { StickerFormatType.Lottie => "json", _ => "png" }; return($"{BaseAddress}stickers/{stickerId}.{formatString}"); }
public static string GetStickerUrl(Snowflake stickerId, StickerFormatType format = default) { var stringBuilder = new StringBuilder(BaseAddress); stringBuilder.Append($"stickers/{stickerId}"); var formatString = format switch { StickerFormatType.Lottie => "json", _ => "png" }; stringBuilder.Append('.').Append(formatString); return(stringBuilder.ToString()); }
public static Task <IGuildSticker> CreateStickerAsync(this IGuild guild, string name, string tags, Stream image, StickerFormatType imageType, string description = null, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { var client = guild.GetRestClient(); return(client.CreateGuildStickerAsync(guild.Id, name, tags, image, imageType, description, options, cancellationToken)); }
/// <summary> /// Gets a stickers url based off the id and format. /// </summary> /// <param name="stickerId">The id of the sticker.</param> /// <param name="format">The format of the sticker.</param> /// <returns> /// A URL to the sticker. /// </returns> public static string GetStickerUrl(ulong stickerId, StickerFormatType format = StickerFormatType.Png) => $"{DiscordConfig.CDNUrl}stickers/{stickerId}.{FormatToExtension(format)}";
public MessageSticker(StickerItemJsonModel model) { Id = model.Id; Name = model.Name; FormatType = model.FormatType; }
internal StickerItem(BaseDiscordClient client, Model model) : base(client, model.Id) { Name = model.Name; Format = model.FormatType; }