예제 #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 ToDiscordEmbed(this Poll poll, LocalizationService lcs)
        {
            var emb = new LocalizedEmbedBuilder(lcs, poll.Channel.GuildId);

            emb.WithTitle(poll.Question);
            emb.WithLocalizedDescription("str-vote-text");
            emb.WithColor(DiscordColor.Orange);

            for (int i = 0; i < poll.Options.Count; i++)
            {
                if (!string.IsNullOrWhiteSpace(poll.Options[i]))
                {
                    emb.AddField($"{i + 1} : {poll.Options[i]}", $"{poll.Results.Count(kvp => kvp.Value == i)}");
                }
            }

            if (poll.EndTime is { })
예제 #4
0
        public static DiscordEmbed ToEmbed(this ReactionsPoll poll, LocalizationService lcs)
        {
            var emb = new LocalizedEmbedBuilder(lcs, poll.Channel.GuildId);

            emb.WithTitle(poll.Question);
            emb.WithLocalizedDescription("str-vote-react");
            emb.WithColor(DiscordColor.Orange);

            for (int i = 0; i < poll.Options.Count; i++)
            {
                if (!string.IsNullOrWhiteSpace(poll.Options[i]))
                {
                    emb.AddField($"{i + 1}", poll.Options[i], inline: true);
                }
            }

            if (poll.EndTime is { })