/// <summary> /// Constructs a new embed builder using another embed as prototype. /// </summary> /// <param name="original">Embed to use as prototype.</param> public DiscordEmbedBuilder(DiscordEmbed original) : this() { Title = original.Title; Description = original.Description; Url = original.Url?.ToString(); Color = original.Color; Timestamp = original.Timestamp; if (original.Thumbnail != null) { Thumbnail = new EmbedThumbnail { Url = original.Thumbnail.Url?.ToString(), Height = original.Thumbnail.Height, Width = original.Thumbnail.Width } } ; if (original.Author != null) { Author = new EmbedAuthor { IconUrl = original.Author.IconUrl?.ToString(), Name = original.Author.Name, Url = original.Author.Url?.ToString() } } ; if (original.Footer != null) { Footer = new EmbedFooter { IconUrl = original.Footer.IconUrl?.ToString(), Text = original.Footer.Text } } ; if (original.Fields?.Any() == true) { _fields.AddRange(original.Fields); } while (_fields.Count > 25) { _fields.RemoveAt(_fields.Count - 1); } }
public Embed(Model model) { Url = model.Url; Type = model.Type; Title = model.Title; Description = model.Description; if (model.Provider.IsSpecified) { Provider = new EmbedProvider(model.Provider.Value); } if (model.Thumbnail.IsSpecified) { Thumbnail = new EmbedThumbnail(model.Thumbnail.Value); } }
/// <inheritdoc /> public async Task <Result> RespondAsync(IGuildMemberAdd ev, CancellationToken ct = default) { var getLogsChannelResult = await _guildApi.FindGuildChannelByName(ev.GuildID, _discordSettings.ChannelNames.LogsSpam); if (!getLogsChannelResult.IsSuccess) { return(Result.FromError(getLogsChannelResult.Error)); } if (!ev.User.HasValue || ev.User.Value is null || ev.User.Value.IsBot.HasValue && ev.User.Value.IsBot.Value || ev.User.Value.IsSystem.HasValue && ev.User.Value.IsSystem.Value ) { return(Result.FromSuccess()); } var user = ev.User.Value; var iconUrl = new Optional <string>(); var embedThumbnail = new Optional <IEmbedThumbnail>(); if (user.Avatar?.Value is not null) { var url = $"https://cdn.discordapp.com/avatars/{user.ID.Value}/{user.Avatar.Value}.png"; iconUrl = url; embedThumbnail = new EmbedThumbnail(url); } var embed = new Embed { Author = new EmbedAuthor($"{user.Username}#{user.Discriminator}", $"https://discord.com/users/{user.ID}", iconUrl), Description = $":inbox_tray: <@{user.ID}> joined the server.", Thumbnail = embedThumbnail, Colour = _colourPalette.Green, Footer = new EmbedFooter($"ID: {user.ID}"), Timestamp = DateTimeOffset.UtcNow }; var sendMessageResult = await _channelApi.CreateMessageAsync(getLogsChannelResult.Entity.ID, embeds : new[] { embed }, ct : ct); return(!sendMessageResult.IsSuccess ? Result.FromError(sendMessageResult) : Result.FromSuccess()); }
public Embed(Model model) { Url = model.Url; Type = model.Type; Title = model.Title; Description = model.Description; Color = model.Color.Value; Timestamp = model.Timestamp.Value; if (model.Provider.IsSpecified) { Provider = new EmbedProvider(model.Provider.Value); } if (model.Provider.IsSpecified) { Provider = new EmbedProvider(model.Provider.Value); } if (model.Thumbnail.IsSpecified) { Thumbnail = new EmbedThumbnail(model.Thumbnail.Value); } if (model.Author.IsSpecified) { Author = new EmbedAuthor(model.Author.Value); } if (model.Image.IsSpecified) { Image = EmbedImage.Create(model.Image.Value); } if (model.Video.IsSpecified) { Video = EmbedVideo.Create(model.Video.Value); } if (model.Footer.IsSpecified) { Footer = new EmbedFooter(model.Footer.Value); } if (model.Fields.IsSpecified) { Fields = model.Fields.Value.Select(EmbedField.Create).ToImmutableArray(); } else { Fields = ImmutableArray.Create <EmbedField>(); } }
public static API.EmbedThumbnail ToModel(this EmbedThumbnail entity) { return(new API.EmbedThumbnail { Url = entity.Url }); }
public static EmbedThumbnailModel ToModel(this EmbedThumbnail thumbnail) => thumbnail == null ? null : new EmbedThumbnailModel { Url = thumbnail.Url };
/* * author : yuha * funcName : makeMstContent * summary : 웹훅 string content 생성 * input : SearchVo * return : string */ public Webhook makeMstContent(SearchVo searchVo) { Webhook webhook = new Webhook(searchVo.webHookUrl); MstInfo mstInfo = searchVo.mstInfo; Dictionary <string, DetailInfo> detailMap = mstInfo.detailInfoMap; List <Embed> embeds = new List <Embed>(); List <EmbedField> fileds = new List <EmbedField>(); Embed embed1 = new Embed(); EmbedThumbnail thumbnail = new EmbedThumbnail(); string title = "product name : [" + mstInfo.prdNm + "]\n"; string description = "stockX url : [stockX](" + searchVo.stockXUrl + ")\nkream url : [kream](" + searchVo.kreamUrl + ")"; string thumbnailUrl = mstInfo.thumbnailUrl; thumbnail.Url = thumbnailUrl; if (detailMap.Count > 0) { foreach (string key in detailMap.Keys) { EmbedField field = new EmbedField(); field.Name = detailMap[key].sizeLabel; if (detailMap[key].latestYn.Equals("N")) { /*kreamX 최근 판매가 널인경우 추가 2021-02-18*/ field.Value += detailMap[key].stockXUsPriceLabel + " | " + detailMap[key].stockXKrPriceLabel + " | " + detailMap[key].kreamKrPriceLabel + " | " + detailMap[key].differenceLabel + " | " + detailMap[key].roiLabel; } else { field.Value += detailMap[key].stockXUsPriceLabel + "(" + detailMap[key].stockXLatestUsPriceLabel + ")" + " | " + detailMap[key].stockXKrPriceLabel + "(" + detailMap[key].stockXLatestKrPriceLabel + ")" + " | " + detailMap[key].kreamKrPriceLabel + "(" + detailMap[key].kreamKrLatestPriceLabel + ")" + " | " + detailMap[key].differenceLabel + " | " + detailMap[key].roiLabel + "(" + detailMap[key].latestRoiLabel + ")"; } fileds.Add(field); } embed1.Fields = fileds; } else { description += "\n\n**No Mapped fields**"; } embed1.Title = title; embed1.Description = description; embed1.Thumbnail = thumbnail; embeds.Add(embed1); webhook.Embeds = embeds; /* * string content = ""; * * content = "product name : [" + mstInfo.prdNm + "]\n"; * Dictionary<string, DetailInfo> detailMap = mstInfo.detailInfoMap; * content += "[size] | [stockX_price] | [stockX_Krprice] | [kream_Krprice] | [difference_price] \n"; * foreach (string key in detailMap.Keys) * { * content += detailMap[key].sizeLabel + " | " + detailMap[key].stockXUsPriceLabel + " | " + detailMap[key].stockXKrPriceLabel + * " | " + detailMap[key].kreamKrPriceLabel + " | " + detailMap[key].differenceLabel + "\n"; * } */ return(webhook); }
public RichEmbed SetThumbnail(EmbedThumbnail thumbnail) { this.embed.Thumbnail = thumbnail; return(this); }