Exemple #1
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 { })