public async Task GetDropRates([Remainder] string itemName) { await Context.Message.DeleteAsync(); try { var dropRates = _contribService.FindDropRates(itemName); if (!dropRates.Any()) { await ReplyAsync($"Sorry {Context.Message.Author.Username}, I could not find any drop rates for {itemName}"); } else { var result = new DropRateResult { ItemName = itemName, DropRates = dropRates }; await ReplyAsync(result); } } catch (Exception ex) { var userMessage = $"Sorry {Context.Message.Author.Username}, I could not find any drop rates for {itemName}"; await HandleErrorAsync(userMessage, ex); } }
public async Task AddDropRate(string itemName, string odds, [Remainder] string source) { await Context.Message.DeleteAsync(); try { var input = string.Join(" ", itemName, odds, source); if (!DropRate.TryParse(input, out var dropRate)) { await ReplyAsync($"Sorry {Context.Message.Author.Username}, that drop rate is in an incorrect format"); } else if (_contribService.Exists(dropRate)) { await ReplyAsync($"Sorry {Context.Message.Author.Username}, these odds already exist"); var result = new DropRateResult { ItemName = dropRate.ItemName, DropRates = new[] { _contribService.FindByNaturalKey(dropRate) as DropRate } }; await ReplyAsync(result); } else { await _contribService.AddContrib(dropRate, Context.Message.Author); await ReplyAsync($"Ok {Context.Message.Author.Username}, the drop rate has been added"); } } catch (Exception ex) { var userMessage = $"Sorry {Context.Message.Author.Username}, I was unable to add that drop rate"; await HandleErrorAsync(userMessage, ex); } }
public async Task AddNote(int contribKey, [Remainder] string noteText) { await Context.Message.DeleteAsync(); try { var note = new Note { AssociatedContribKey = contribKey, Text = noteText }; if (_contribService.Exists(note)) { await ReplyAsync($"Sorry {Context.Message.Author.Username}, this note already exist"); var dropRate = _contribService.FindByContribKey(contribKey) as DropRate; var result = new DropRateResult { ItemName = dropRate.ItemName, DropRates = new[] { dropRate } }; await ReplyAsync(result); } else { // Temporarily only allow adding notes to drop rates if (!(_contribService.FindByContribKey(contribKey) is DropRate dropRate)) { await ReplyAsync($"Sorry {Context.Message.Author.Username}, you can only add notes to odds for now"); return; } await _contribService.AddContrib(note, Context.Message.Author); await ReplyAsync($"Ok {Context.Message.Author.Username}, the note has been added"); } } catch (Exception ex) { var userMessage = $"Sorry {Context.Message.Author.Username}, I was unable to add that note"; await HandleErrorAsync(userMessage, ex); } }