예제 #1
0
        public LocalizedEmbedBuilder AddToEmbed(LocalizedEmbedBuilder emb, MovieInfo info)
        {
            emb.WithTitle(info.Title);
            emb.WithDescription(info.Plot);
            emb.WithColor(DiscordColor.Yellow);
            emb.WithUrl(this.Service.GetUrl(info.IMDbId));

            emb.AddLocalizedTitleField("str-type", info.Type, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-year", info.Year, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-id", info.IMDbId, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-genre", info.Genre, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-rel-date", info.ReleaseDate, inline: true, unknown: false);
            emb.AddLocalizedField("str-score", "fmt-rating-imdb", inline: true, contentArgs: new[] { info.IMDbRating, info.IMDbVotes });
            emb.AddLocalizedTitleField("str-rating", info.Rated, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-duration", info.Duration, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-writer", info.Writer, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-director", info.Director, inline: true, unknown: false);
            emb.AddLocalizedTitleField("str-actors", info.Actors, inline: true, unknown: false);
            if (!string.IsNullOrWhiteSpace(info.Poster) && info.Poster != "N/A")
            {
                emb.WithThumbnail(info.Poster);
            }

            emb.WithLocalizedFooter("fmt-powered-by", null, "OMDb");
            return(emb);
        }
예제 #2
0
        public static async Task <bool> SendFeedUpdateAsync(TheGodfatherBot shard, RssSubscription sub, SyndicationItem latest)
        {
            DiscordChannel?chn;

            try {
                chn = await shard.Client.GetShard(sub.GuildId).GetChannelAsync(sub.ChannelId);
            } catch (NotFoundException) {
                return(false);
            }

            if (chn is null)
            {
                return(false);
            }

            var emb = new LocalizedEmbedBuilder(shard.Services.GetRequiredService <LocalizationService>(), sub.GuildId);

            emb.WithTitle(latest.Title.Text);
            emb.WithUrl(sub.Feed.LastPostUrl);
            emb.WithColor(DiscordColor.Gold);
            emb.WithLocalizedTimestamp(latest.LastUpdatedTime > latest.PublishDate ? latest.LastUpdatedTime : latest.PublishDate);

            if (latest.Content is TextSyndicationContent content)
            {
                string?imageUrl = RedditService.GetImageUrl(content);
                if (imageUrl is { })
예제 #3
0
        public static DiscordEmbed ToStarboardEmbed(this DiscordMessage msg, LocalizationService lcs, DiscordEmoji star, int count)
        {
            var emb = new LocalizedEmbedBuilder(lcs, msg.Channel.Guild.Id);

            emb.WithColor(DiscordColor.Gold);
            emb.WithUrl(msg.JumpLink);
            emb.WithAuthor(msg.Author.ToDiscriminatorString(), iconUrl: msg.Author.AvatarUrl);
            emb.WithDescription(msg.Content.Truncate(DiscordLimits.EmbedDescriptionLimit - 5, " ..."));
            emb.AddLocalizedTitleField("str-votes", $"{Formatter.Bold(count.ToString())} {star}", inline: true);
            emb.AddLocalizedTitleField("str-chn", msg.Channel.Mention, inline: true);

            string jumplink = Formatter.MaskedUrl(lcs.GetString(msg.Channel.Guild.Id, "str-jumplink"), msg.JumpLink);

            emb.AddLocalizedTitleField("str-link", jumplink, inline: true);

            string?url = msg.Attachments
                         .Select(a => a.Url)
                         .FirstOrDefault(u => u.EndsWith(".jpg") || u.EndsWith(".png") || u.EndsWith(".jpeg") || u.EndsWith(".gif"))
            ;

            if (url is { })