Example #1
0
 private async Task ProcessSet(string name, string value)
 {
     try
     {
         value = value.Trim();
         FormattedEmbedBuilder message = new FormattedEmbedBuilder();
         try
         {
             Property property = Property.GetUpdatableByName(name);
             string   oldValue = property.Value;
             property.Value = value;
             message
             .AppendTitle($"{XayahReaction.Success} Done")
             .AppendDescription($"I updated `{name}` for you.")
             .AppendDescription($"Old:{oldValue}{Environment.NewLine}New:{value}", AppendOption.Codeblock);
         }
         catch (NotExistingException)
         {
             message
             .AppendTitle($"{XayahReaction.Error} This didn't work")
             .AppendDescription($"I couldn't find a property named `{name}`.");
         }
         await this.ReplyAsync(message);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Example #2
0
        public async Task <FormattedEmbedBuilder> BuildForRoleAsync(LeagueRole role)
        {
            FormattedEmbedBuilder message = new FormattedEmbedBuilder();

            try
            {
                await this.LoadFromApi();

                if (LeagueRole.All.Equals(role))
                {
                    foreach (LeagueRole leagueRole in LeagueRole.Values())
                    {
                        this.AppendStatsOfRole(leagueRole, 3, message);
                    }
                }
                else
                {
                    this.AppendStatsOfRole(role, 6, message);
                }
                message.AppendTitle($"{XayahReaction.Clipboard} Winrates");
                ChampionStatsDto first = this._championStats.ElementAtOrDefault(0);
                if (first != null)
                {
                    message.AppendTitle($" for Patch {first.Patch}");
                }
                message.AppendDescription("Short explanation of the table: `Position - Win % - Play %` - Name", AppendOption.Italic);
            }
            catch (NoApiResultException)
            {
                message = new FormattedEmbedBuilder()
                          .AppendTitle($"{XayahReaction.Error} This didn't work")
                          .AppendDescription("Apparently some random API refuses cooperation. Have some patience while I convince them again...");
            }
            return(message);
        }
Example #3
0
        public static async Task <FormattedEmbedBuilder> BuildAsync(string name)
        {
            name = name.Trim();
            ChampionDataBuilder   championBuilder = new ChampionDataBuilder();
            FormattedEmbedBuilder message         = new FormattedEmbedBuilder();

            try
            {
                List <ChampionDto> matches = await championBuilder.GetMatchingChampionsAsync(name);

                if (matches.Count == 0)
                {
                    message
                    .AppendTitle($"{XayahReaction.Error} This didn't work")
                    .AppendDescription($"Oops! Your bad. I couldn't find a champion (fully or partially) named `{name}`.");
                }
                else if (matches.Count > 1)
                {
                    message
                    .AppendTitle($"{XayahReaction.Warning} This didn't went as expected")
                    .AppendDescription($"I found more than one champion (fully or partially) named `{name}`.");
                    foreach (ChampionDto champion in matches)
                    {
                        message.AppendDescription(Environment.NewLine + champion.Name);
                    }
                }
                else
                {
                    ChampionDto champion = await championBuilder.GetChampionAsync(matches.First().Id);

                    championBuilder.AppendMiscData(champion, message);
                    championBuilder.AppendStatisticData(champion, message);
                    championBuilder.AppendSpellData(champion, message);
                    championBuilder.AppendSkinData(champion, message);
                }
            }
            catch (NoApiResultException)
            {
                message = new FormattedEmbedBuilder()
                          .AppendTitle($"{XayahReaction.Error} This didn't work")
                          .AppendDescription("Apparently some random API refuses cooperation. Have some patience while I convince them again...");
            }
            return(message);
        }
Example #4
0
        public static async Task <FormattedEmbedBuilder> BuildAsync(string name)
        {
            name = name.Trim();
            ItemDataBuilder       itemBuilder = new ItemDataBuilder();
            FormattedEmbedBuilder message     = new FormattedEmbedBuilder();

            try
            {
                List <ItemDto> matches = await itemBuilder.GetMatchingItemsAsync(name);

                if (matches.Count == 0)
                {
                    message
                    .AppendTitle($"{XayahReaction.Error} This didn't work")
                    .AppendDescription($"Oops! Your bad. I couldn't find an item (fully or partially) named `{name}`.");
                }
                else if (matches.Count > 1)
                {
                    message
                    .AppendTitle($"{XayahReaction.Warning} This didn't went as expected")
                    .AppendDescription($"I found more than one item (fully or partially) named `{name}`.");
                    foreach (ItemDto item in matches)
                    {
                        message.AppendDescription(Environment.NewLine + item.Name);
                    }
                }
                else
                {
                    ItemDto item = matches.First();
                    await itemBuilder.AppendData(item, message);
                }
            }
            catch (NoApiResultException)
            {
                message = new FormattedEmbedBuilder()
                          .AppendTitle($"{XayahReaction.Error} This didn't work")
                          .AppendDescription("Apparently some random API refuses cooperation. Have some patience while I convince them again...");
            }
            return(message);
        }