Exemplo n.º 1
0
        public static async Task <EmbedBuilder> GetEmbedAsync(this Listing game)
        {
            var app = await AppDetails.GetAsync(game.AppId).ConfigureAwait(false);

            string releasetext = app.ReleaseDate.ComingSoon ? "Coming soon! (Date Number may not be accurate)" : "Released on:";

            var embed =
                new EmbedBuilder()
                .WithAuthor(
                    new EmbedAuthorBuilder()
                    .WithName(string.Join(", ", app.Developers))
                    )
                .WithDescription(SteamUtilities.GetSteamGameDescription(game, app))
                .WithImageUrl(app.Screenshots.RandomValue().PathFull)
                .WithRandomColor()
                .WithUrl($"https://store.steampowered.com/app/{game.AppId}/")
                .WithTitle(game.Name)
                .WithFooter(
                    new EmbedFooterBuilder()
                    .WithText(releasetext)
                    );

            if (int.TryParse(app.ReleaseDate.Date[0].ToString(), out int _))
            {
                embed.WithTimestamp(DateTime.ParseExact(app.ReleaseDate.Date, "dd MMM, yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces));
            }
            else
            {
                embed.WithTimestamp(DateTime.ParseExact(app.ReleaseDate.Date, "MMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces));
            }

            return(embed);
        }
Exemplo n.º 2
0
        /// <summary>
        /// <para type="description">ProcessRecord method</para>
        /// </summary>
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            try
            {
                WriteObject(Task.Run(async() => await AppDetails.GetAsync(AppId, Region, Language)).Result);
            }
            catch (PipelineStoppedException)
            {
                // Nothing to do here, the try block is simply to handle exceptions when the user aborts the command
                return;
            }
            catch (AggregateException ex)
            {
                foreach (var error in ex.InnerExceptions)
                {
                    WriteError(new ErrorRecord(error, "UnknownError", ErrorCategory.NotSpecified, null));
                }
                return;
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null));
                return;
            }
        }
Exemplo n.º 3
0
        static async Task Examples()
        {
            // Get details for SteamApp with ID 443790
            SteamApp steamApp1 = await AppDetails.GetAsync(460810);

            // Get details for SteamApp with ID 443790 for region US
            SteamApp steamApp2 = await AppDetails.GetAsync(322330, "US");

            // Get details for SteamApp with ID 443790 for region US with strings localized in german
            SteamApp steamApp3 = await AppDetails.GetAsync(322330, "US", "german");

            // Get details for Package with ID 68179 for region
            PackageInfo package1 = await PackageDetails.GetAsync(68179);

            // Get details for Package with ID 68179 for region JP
            PackageInfo package2 = await PackageDetails.GetAsync(68179, "JP");

            // Get a list of featured games
            FeaturedApps featured = await Featured.GetAsync();

            // Get a list of featured games for region DE
            FeaturedApps featured2 = await Featured.GetAsync("DE");

            // Get a list of featured games for region DE localized in english
            FeaturedApps featured3 = await Featured.GetAsync("DE", "english");

            // Get a list of featured games grouped by category
            List <FeaturedCategory> featuredCategories = (await FeaturedCategories.GetAsync()).ToList();

            // Get a list of featured games grouped by category for region US
            List <FeaturedCategory> featuredCategories2 = (await FeaturedCategories.GetAsync("DE")).ToList();
        }