Esempio n. 1
0
        private static Task UpdateSteamAsync()
        {
            Console.WriteLine("Updating Steam App List...");
            var service = new BotServices();
            var token   = service.GetAPIToken("steam");
            var apps    = new SteamApps(token);
            var games   = apps.GetAppListAsync().Result.Data;

            GlobalVariables.SteamAppList.Clear();
            foreach (var game in games)
            {
                if (!string.IsNullOrWhiteSpace(game.Name))
                {
                    GlobalVariables.SteamAppList.Add(Convert.ToUInt32(game.AppId), game.Name);
                }
            }

            Console.WriteLine("Updating TF2 Item Schema...");
            var schema = new EconItems(token, EconItemsAppId.TeamFortress2);
            var items  = schema.GetSchemaForTF2Async();

            GlobalVariables.TFItemSchema.Clear();
            foreach (var item in items.Result.Data.Items)
            {
                if (!string.IsNullOrWhiteSpace(item.ItemName))
                {
                    GlobalVariables.TFItemSchema.Add(Convert.ToUInt32(item.DefIndex), item.ItemName);
                }
            }

            return(Task.CompletedTask);
        }
Esempio n. 2
0
        public async Task TF2Item(CommandContext ctx)
        {
            await ctx.TriggerTypingAsync();

            var rnd      = new Random();
            var textInfo = new CultureInfo("en-US", false).TextInfo;
            var service  = new BotServices();
            var schema   = new EconItems(service.GetAPIToken("steam"), EconItemsAppId.TeamFortress2);
            var items    = await schema.GetSchemaForTF2Async();

            var index    = rnd.Next(0, items.Data.Items.Count);
            var wikiName = items.Data.Items[index].ItemName.Replace(' ', '_');
            var output   = new DiscordEmbedBuilder()
                           .WithTitle(items.Data.Items[index].ItemName)
                           .WithThumbnailUrl(items.Data.Items[index].ImageUrl)
                           .WithUrl($"https://wiki.teamfortress.com/wiki/{wikiName}")
                           .WithColor(DiscordColor.Orange);

            if (items.Data.Items[index].ItemDescription != null)
            {
                output.WithDescription(items.Data.Items[index].ItemDescription);
            }
            if (items.Data.Items[index].ItemSlot != null)
            {
                output.AddField("Item Slot:", textInfo.ToTitleCase(items.Data.Items[index].ItemSlot), true);
            }
            var classes = items.Data.Items[index].UsedByClasses.Aggregate <string, string>(null, (current, userClass) => current + $" {userClass} ");

            if (classes != null)
            {
                output.AddField("Used by:", textInfo.ToTitleCase(classes), true);
            }
            if (items.Data.Items[index].ModelPlayer != null)
            {
                await ctx.RespondAsync(embed : output.Build());
            }
        }
Esempio n. 3
0
        private async Task RetrieveBaseItems()
        {
            var items = await _econItems.GetSchemaForTF2Async();

            _items = items.Data.Items;
        }