Example #1
0
 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;
 }
Example #3
0
 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;
 }
Example #4
0
 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;
 }
Example #5
0
            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}");
            }
Example #6
0
            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());
            }
Example #7
0
        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));
        }
Example #8
0
 /// <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)}";
Example #9
0
 public MessageSticker(StickerItemJsonModel model)
 {
     Id         = model.Id;
     Name       = model.Name;
     FormatType = model.FormatType;
 }
Example #10
0
 internal StickerItem(BaseDiscordClient client, Model model)
     : base(client, model.Id)
 {
     Name   = model.Name;
     Format = model.FormatType;
 }