public async Task GetOperator([Remainder] string text = null) { var model = await RestService.GetOperator(text, sideEnum.ToString(), baseUrl, stratKey); await ReplyAsync("Thank you for using the StratBot, here are your random operator(s), have fun!"); foreach (var operatorModel in model) { await SendOperator(operatorModel); } }
/// <summary> /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>. /// </summary> /// <returns> /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>. /// </returns> /// <remarks>Documented by Dev02, 2008-03-29</remarks> public override string ToString() { switch (type) { case TypeEnum.AudioField: return((example ? "Ex. " : string.Empty) + side.ToString()); case TypeEnum.Silence: return(string.Format("Silence ({0})", silenceduration > 0 ? string.Format("{0:0.0} s", silenceduration) : "custom")); default: return("Undefined"); } }
public async Task GetStrat([Remainder] string text) { try { var model = await RestService.GetStrat(text, sideEnum.ToString(), difficultyEnum.ToString(), "1", gameModeEnum.ToString(), controller.ToString(), keyboardandmouse.ToString(), baseUrl, stratKey); if (model == null) { await ReplyAsync($"We found no strats for **{text}**, please be less strict with the search creteria."); return; } foreach (var m in model) { await SendStrat(m); } } catch (Exception ex) { if (ex.Message.Contains("Failed to fetch") || ex.Message.Contains("BadGateway")) { await ReplyAsync($"StratRoulette API is down, we will be back shortly, if this takes more than 24 hours send a message to Dakpan#6955"); return; } await ReplyAsync($"Something went wrong, I send a message to the developers they will look into it, please try again later!"); var builder = new EmbedBuilder(); builder.AddField("Message", text); //Exception Message splitting var exceptionMessage = ex.Message; var exceptionMessageLength = exceptionMessage.Length; var nr_of_exceptionMessages = (exceptionMessage.Length / 1000) + 1; if (nr_of_exceptionMessages == 1) { builder.AddField("Exception Message", exceptionMessage); } else { for (var i = 0; i < nr_of_exceptionMessages; i++) { builder.AddField("Exception Message Nr " + (i + 1), exceptionMessage.Substring(0, 1000)); } } //Stacktrace splitting var stackTrace = ex.StackTrace; var stackTraceLength = stackTrace.Length; var nr_of_stacktraces = (stackTrace.Length / 1000) + 1; if (nr_of_stacktraces == 1) { builder.AddField("Exception Stacktrace", stackTrace); } else { for (var i = 0; i < nr_of_stacktraces; i++) { builder.AddField("Exception Stacktrace Nr " + (i + 1), stackTrace.Substring(0, 1000)); } } builder.Author = new EmbedAuthorBuilder { IconUrl = "https://i.redd.it/iznunq2m8vgy.png", Name = "Error Caught", //Url = "http://r6db.com/player/" + model.id }; builder.Footer = new EmbedFooterBuilder { IconUrl = "https://i.redd.it/iznunq2m8vgy.png", Text = "Created by Dakpan#6955" }; //builder.ThumbnailUrl = StringVisualiser.GetRankImage(rankNr); //builder.ImageUrl = "http://r6db.com/player/" + model?.id; builder.Timestamp = DateTime.UtcNow; //builder.Url = "http://r6db.com/player/" + model?.id; builder.WithColor(Color.Red); var u = Context.Guild.GetUser(132556381046833152); await u.SendMessageAsync(string.Empty, false, builder); } }
async Task PersistInCache(string id, SideEnum side, string value) { await this._cache.AddAsync(id + side.ToString(), new Data(id, side, value, this._hashStrategy)); }