public async Task SaveDucat() { Dictionary <string, string> itemList = new Dictionary <string, string>(); string theurl = ""; string tmpitem = ""; var ducatsJson = File.ReadAllText("SystemLang/Ducats.json"); var json = GetMarketItems(); if (string.IsNullOrEmpty(json)) { return; } var ducats = Ducats.FromJson(ducatsJson); var itemDucats = ducats.Payload.PreviousHour; var market = Items.FromJson(json); var items = market.Payload.Items.En; foreach (var item in itemDucats) { var curitem = item.Item; foreach (var theitem in items) { if (curitem == theitem.Id) { itemList.Add(theitem.ItemName, item.Ducats.ToString()); } } } string json2 = JsonConvert.SerializeObject(itemList, Formatting.Indented); File.WriteAllText("ducatlist.json", json2); }
public async Task DucatSearch([Remainder] string msg) { string theurl = ""; string tmpitem = ""; var ducatsJson = File.ReadAllText("SystemLang/Ducats.json"); var json = GetMarketItems(); if (string.IsNullOrEmpty(json)) { return; } var ducats = Ducats.FromJson(ducatsJson); var itemDucats = ducats.Payload.PreviousHour; var market = Items.FromJson(json); var items = market.Payload.Items.En; foreach (var item in items) { if (item.ItemName.ToLower().Contains(msg.ToLower())) { tmpitem = item.Id; break; } } foreach (var ducat in itemDucats) { if (ducat.Item == tmpitem) { await Context.Channel.SendMessageAsync( // $"Ducat price is {ducat.Ducats} and ducats per plat is {ducat.DucatsPerPlatinum}"); $"You would get {ducat.Ducats} ducats for {msg}"); break; } } }