Exemple #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);
     }
 }
Exemple #2
0
        private void AppendStatisticData(ChampionDto champion, FormattedEmbedBuilder message)
        {
            StatsDto    stats          = champion.Stats;
            int         decimals       = 3;
            NumberAlign statList       = new NumberAlign(decimals, stats.GetStats());
            NumberAlign statGrowthList = new NumberAlign(decimals, stats.GetStatGrowthList());
            string      statData       =
                $"Health         - {statList.Align(stats.Hp)} | + {statGrowthList.TrimmedAlign(stats.HpPerLevel)}" +
                Environment.NewLine +
                $"Health Regen.  - {statList.Align(stats.HpRegen)} | + {statGrowthList.TrimmedAlign(stats.HpRegenPerLevel)}" +
                Environment.NewLine +
                $"Mana           - {statList.Align(stats.Mp)} | + {statGrowthList.TrimmedAlign(stats.MpPerLevel)}" +
                Environment.NewLine +
                $"Mana Regen     - {statList.Align(stats.MpRegen)} | + {statGrowthList.TrimmedAlign(stats.MpRegenPerLevel)}" +
                Environment.NewLine +
                $"Attack Damage  - {statList.Align(stats.AttackDamage)} | + {statGrowthList.TrimmedAlign(stats.AttackDamagePerLevel)}" +
                Environment.NewLine +
                $"Attack Speed   - {statList.Align(stats.GetBaseAttackSpeed())} | + {statGrowthList.TrimmedAlign(stats.AttackSpeedPerLevel)}%" +
                Environment.NewLine +
                $"Armor          - {statList.Align(stats.Armor)} | + {statGrowthList.TrimmedAlign(stats.ArmorPerLevel)}" +
                Environment.NewLine +
                $"Magic Resist   - {statList.Align(stats.Spellblock)} | + {statGrowthList.TrimmedAlign(stats.SpellblockPerLevel)}" +
                Environment.NewLine +
                $"Attack Range   - {statList.Align(stats.AttackRange)}" +
                Environment.NewLine +
                $"Movement Speed - {statList.Align(stats.MoveSpeed)}";

            message.AddField("Stats", statData,
                             new AppendOption[] { AppendOption.Underscore },
                             new AppendOption[] { AppendOption.Codeblock }, inline: false);
        }
Exemple #3
0
        private async Task ProcessList()
        {
            try
            {
                IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this.Context);

                List <TReminder> reminders = this._reminderDAO.GetAll(this.Context.User.Id);
                IOrderedEnumerable <TReminder> orderedList = reminders.OrderBy(x => x.ExpirationTime);

                FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                                .AppendTitle($"{XayahReaction.Hourglass} Active reminders");
                if (orderedList.Count() > 0)
                {
                    foreach (TReminder entry in orderedList)
                    {
                        message.AddField($"Expires: {entry.ExpirationTime} UTC", entry.Message, inline: false);
                    }
                }
                else
                {
                    message.AppendDescription("imagine a soulrending void", AppendOption.Italic);
                }
                await channel.SendEmbedAsync(message);

                await this.Context.Message.AddReactionIfNotDMAsync(this.Context, XayahReaction.Envelope);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #4
0
 private FormattedEmbedBuilder AppendGeneralHelp(FormattedEmbedBuilder message)
 {
     this.AppendDescriptionTitle(message, _cHelpTitle)
     .AppendDescription("Hello human. If you need help then you came to the right place. I'll tell you how to proceed.")
     .AppendDescriptionNewLine(2)
     .AppendDescription("The help is neatly organized in pages to have a clear view of all possible categories. " +
                        "Just mention me with the corresponding page number and I'll tell you all of the details I think you should know of.")
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Usage")
     .AppendDescription("The keyword to this command is `help` followed by an optional page number.")
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Examples")
     .AppendDescription($"{this.Context.Client.CurrentUser.Mention} help")
     .AppendDescriptionNewLine()
     .AppendDescription($"{this.Context.Client.CurrentUser.Mention} help 2")
     .AppendDescriptionNewLine(2)
     .AppendDescription($"Tip: You don't need to mention me in private messages. There are only both of us so I'll know right away what to do.", AppendOption.Italic)
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Help Index")
     .AppendDescription($"`1` - {_cAreTitle}")
     .AppendDescriptionNewLine()
     .AppendDescription($"`2` - {_cRemindTitle}")
     .AppendDescriptionNewLine()
     .AppendDescription($"`3` - {_cRiotDataTitle}")
     .AppendDescriptionNewLine()
     .AppendDescription($"`4` - Champion statistics (via ChampionGG-API) [Soon™]")
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Contact")
     .AppendDescription("If you still got questions, problems or even suggestions just contact `Aergwyn#8786` and all your desires will be fulfilled " +
                        "(Aergwyn also takes full responsibility, I never said this).")
     .AppendDescriptionNewLine(2)
     .AppendDescription("If that is too direct and you prefer to hide in the shadows (or are just curious) you can just join [this server](https://discord.gg/YhQYAFW) and have a look.");
     return(message);
 }
Exemple #5
0
 private async Task ProcessGet()
 {
     try
     {
         string text     = string.Empty;
         int    maxWidth = Property.UpdatableValues().OrderByDescending(x => x.Name.Length).First().Name.Length;
         IEnumerable <Property> properties = Property.UpdatableValues();
         for (int i = 0; i < properties.Count(); i++)
         {
             if (i > 0)
             {
                 text += Environment.NewLine;
             }
             Property property = properties.ElementAt(i);
             text += property.Name.PadRight(maxWidth) + ":" + property.Value;
         }
         FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                         .AppendTitle($"{XayahReaction.Option} Property list")
                                         .AppendDescription(text, AppendOption.Codeblock);
         await this.ReplyAsync(message);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Exemple #6
0
        private FormattedEmbedBuilder AppendRemindHelp(FormattedEmbedBuilder message)
        {
            string timeUnits = ListUtil.BuildEnumeration(TimeUnit.Values());

            this.AppendDescriptionTitle(message, _cRemindTitle)
            .AppendDescription("If you tend to forget things or just need someone to handle your appointments this is your solution.")
            .AppendDescriptionNewLine(2)
            .AppendDescription($"Currently they are capped at `{Property.RemindDayCap}` days with only `{Property.RemindTextCap}` characters.")
            .AppendDescriptionNewLine(2);
            this.AppendDescriptionTitle(message, "Usage")
            .AppendDescription("This command is split in three parts:")
            .AppendDescriptionNewLine()
            .AppendDescription("- `remind me [number] [time-unit] [text]`; while number and time-unit tell me how long to wait, the text is the message I'll remind you with")
            .AppendDescriptionNewLine()
            .AppendDescription("- `remind me list` shows a list of your active reminders")
            .AppendDescriptionNewLine()
            .AppendDescription("- `remind me clear` if you want to get rid of them")
            .AppendDescriptionNewLine(2)
            .AppendDescription($"Tip: The possible time-units are `{timeUnits}`.", AppendOption.Italic)
            .AppendDescriptionNewLine(2);
            this.AppendDescriptionTitle(message, "Examples")
            .AppendDescription($"{this.Context.Client.CurrentUser.Mention} remind me 2 days finally take the trash out")
            .AppendDescriptionNewLine()
            .AppendDescription($"{this.Context.Client.CurrentUser.Mention} remind me list")
            .AppendDescriptionNewLine()
            .AppendDescription($"{this.Context.Client.CurrentUser.Mention} remind me clear");
            return(message);
        }
Exemple #7
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);
        }
        protected void NotifyDisabledCommand()
        {
            FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                            .CreateFooterIfNotDM(this.Context)
                                            .AppendTitle($"{XayahReaction.Warning} Command disabled")
                                            .AppendDescription("This command is disabled because a certain someone is too lazy to fix it.");

            this.ReplyAsync(message);
        }
Exemple #9
0
        private async void HandleExpiredReminder(object state)
        {
            TReminder reminder = state as TReminder;

            await this._reminderDAO.RemoveAsync(reminder);

            StopTimer(this.BuildTimerKey(reminder.UserId, reminder.ExpirationTime));

            IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this._client, reminder.UserId);

            FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                            .AppendTitle($"{XayahReaction.Clock} Reminder expired")
                                            .AppendDescription(reminder.Message);
            await channel.SendEmbedAsync(message);
        }
Exemple #10
0
 private void AppendMiscData(ChampionDto champion, FormattedEmbedBuilder message)
 {
     champion.Tags.Sort();
     message
     .SetThumbnail($"http://ddragon.leagueoflegends.com/cdn/{Property.RiotUrlVersion.Value}/img/champion/{champion.Name}.png")
     .AppendTitle($"{champion.Name} {champion.Title}", AppendOption.Bold, AppendOption.Underscore)
     .AppendDescription("Classified as:", AppendOption.Italic)
     .AppendDescription($" {string.Join(", ", champion.Tags)}")
     .AppendDescriptionNewLine()
     .AppendDescription("Resource:", AppendOption.Italic)
     .AppendDescription($" {champion.Resource}")
     .AppendDescriptionNewLine()
     .AppendDescription("Passive:", AppendOption.Italic)
     .AppendDescription($" {champion.Passive.Name}");
 }
Exemple #11
0
        private async Task ProcessRemindMe(int value, TimeUnit timeUnit, string text)
        {
            try
            {
                text = text.Trim();
                DateTime expirationTime = DateTime.UtcNow;
                int      maxTime        = int.Parse(Property.RemindDayCap.Value);
                if (TimeUnit.Day.Equals(timeUnit))
                {
                    value          = this.SetValueInRange(value, 1, maxTime);
                    expirationTime = DateTime.UtcNow.AddDays(value);
                }
                else if (TimeUnit.Hour.Equals(timeUnit))
                {
                    value          = this.SetValueInRange(value, 1, maxTime * 24);
                    expirationTime = DateTime.UtcNow.AddHours(value);
                }
                else // Minute == Default
                {
                    value          = this.SetValueInRange(value, 1, maxTime * 24 * 60);
                    expirationTime = DateTime.UtcNow.AddMinutes(value);
                }
                int maxLength = int.Parse(Property.RemindTextCap.Value);
                if (text.Length > maxLength)
                {
                    text = text.Substring(0, maxLength);
                }
                await this._remindService.AddNewAsync(new TReminder
                {
                    ExpirationTime = expirationTime,
                    Message        = text,
                    UserId         = this.Context.User.Id
                });

                FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                                .CreateFooterIfNotDM(this.Context)
                                                .AppendTitle($"{XayahReaction.Success} Done")
                                                .AppendDescription($"I'm going to remind you at `{expirationTime} UTC`.{Environment.NewLine}I think...");
                await this.ReplyAsync(message);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #12
0
 private FormattedEmbedBuilder Append8BallHelp(FormattedEmbedBuilder message)
 {
     this.AppendDescriptionTitle(message, _cAreTitle)
     .AppendDescription("Every bot needs an 8ball command. A bot without it can't even call itself complete. Also it's the most random and funny command to abuse and spam the chat with.")
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Usage")
     .AppendDescription("The keywords to this command are `are`, `is` or `am` followed by a highly creative sentence of yours.")
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Examples")
     .AppendDescription($"{this.Context.Client.CurrentUser.Mention} are you jealous of Ahri?")
     .AppendDescriptionNewLine()
     .AppendDescription($"{this.Context.Client.CurrentUser.Mention} is Riot doing a mistake by not buffing Viktor?")
     .AppendDescriptionNewLine()
     .AppendDescription($"{this.Context.Client.CurrentUser.Mention} am I really a challenger level player?")
     .AppendDescriptionNewLine(2)
     .AppendDescription("Tip: There are a few more possible answers than you might expect.", AppendOption.Italic);
     return(message);
 }
Exemple #13
0
 private void AppendSpellData(ChampionDto champion, FormattedEmbedBuilder message)
 {
     for (int i = 0; i < champion.Spells.Count; i++)
     {
         ChampionSpellDto     spell       = champion.Spells.ElementAt(i);
         FormattedTextBuilder spellDetail = new FormattedTextBuilder()
                                            .Append("Cost:", AppendOption.Italic)
                                            .Append($" {spell.GetCostString()}")
                                            .AppendNewLine()
                                            .Append("Range:", AppendOption.Italic)
                                            .Append($" {spell.GetRangeString()}")
                                            .AppendNewLine()
                                            .Append("Cooldown:", AppendOption.Italic)
                                            .Append($" {spell.GetCooldownString()}");
         message.AddField($"{GetSpellKey(i)} - {spell.Name}", spellDetail.ToString(),
                          new AppendOption[] { AppendOption.Underscore }, inline: false);
     }
 }
Exemple #14
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);
        }
        private async Task ProcessWinrate(LeagueRole role)
        {
            try
            {
                if (role == null)
                {
                    role = LeagueRole.All;
                }
                ChampionStatsBuilder  statsBuilder = new ChampionStatsBuilder();
                FormattedEmbedBuilder message      = await statsBuilder.BuildForRoleAsync(role);

                message.CreateFooterIfNotDM(this.Context);
                await this.ReplyAsync(message);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #16
0
        private void AppendSkinData(ChampionDto champion, FormattedEmbedBuilder message)
        {
            List <SkinDto> skins = champion.Skins.Where(x => x.Num > 0).ToList();

            skins.Sort((a, b) => a.Num.CompareTo(b.Num));
            string skinData = string.Empty;

            foreach (SkinDto skin in skins)
            {
                string skinNum = skin.Num.ToString();
                while (skinNum.Length < 2)
                {
                    skinNum = "0" + skinNum;
                }
                skinData += $"{Environment.NewLine}`{skinNum}` - {skin.Name}";
            }
            message.AddField("Skins", skinData,
                             new AppendOption[] { AppendOption.Underscore }, inline: false);
        }
Exemple #17
0
        private async Task ProcessMessageReceived(SocketMessage arg)
        {
            try
            {
                SocketUserMessage message = arg as SocketUserMessage;
                if (message == null || message.Author.IsBot)
                {
                    return;
                }
                DiscordSocketClient client         = this._serviceProvider.GetService(typeof(DiscordSocketClient)) as DiscordSocketClient;
                CommandService      commandService = this._serviceProvider.GetService(typeof(CommandService)) as CommandService;

                int            pos     = 0;
                CommandContext context = new CommandContext(client, message);
                if (context.IsPrivate || message.HasMentionPrefix(client.CurrentUser, ref pos))
                {
                    IResult result = await commandService.ExecuteAsync(context, pos, this._serviceProvider);

                    if (!result.IsSuccess)
                    {
                        if (this.IsUserError(result.Error))
                        {
                            IMessageChannel dmChannel = await ChannelProvider.GetDMChannelAsync(context);

                            FormattedEmbedBuilder errorResponse = new FormattedEmbedBuilder()
                                                                  .AppendTitle($"{XayahReaction.Error} This didn't work")
                                                                  .AddField("Why, you ask?", result.ErrorReason);
                            await dmChannel.SendEmbedAsync(errorResponse);

                            await context.Message.AddReactionIfNotDMAsync(context, XayahReaction.Error);
                        }
                        else if (this.IsInterestingError(result.Error))
                        {
                            Logger.Debug($"Command failed: {result.ErrorReason}");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #18
0
        private async Task AppendData(ItemDto item, FormattedEmbedBuilder message)
        {
            message
            .SetThumbnail($"http://ddragon.leagueoflegends.com/cdn/{Property.RiotUrlVersion.Value}/img/item/{item.Id}.png")
            .AppendTitle(item.Name, AppendOption.Bold, AppendOption.Underscore)
            .AppendDescription(item.SanitizedDescription)
            .AppendDescriptionNewLine(2)
            .AppendDescription($"Total Cost:", AppendOption.Italic).AppendDescription($" {item.Gold.Total} Gold")
            .AppendDescriptionNewLine()
            .AppendDescription($"Selling for:", AppendOption.Italic).AppendDescription($" {item.Gold.Sell} Gold")
            .AppendDescriptionNewLine()
            .AppendDescription($"Completion Cost:", AppendOption.Italic).AppendDescription($" {item.Gold.Base} Gold");

            if (item.From != null)
            {
                message.AppendDescriptionNewLine(2)
                .AppendDescription("Components", AppendOption.Bold, AppendOption.Underscore);

                List <ItemDto> componentList = await this.GetFromList(item.From);

                componentList.Sort((a, b) => a.Gold.Base.CompareTo(b.Gold.Base));
                foreach (ItemDto component in componentList)
                {
                    message.AppendDescriptionNewLine()
                    .AppendDescription($"{component.Name} ({component.Gold.Base} Gold)");
                }
            }
            if (item.Into != null)
            {
                message.AppendDescriptionNewLine(2)
                .AppendDescription("Builds Into", AppendOption.Bold, AppendOption.Underscore);

                List <ItemDto> parentList = await this.GetFromList(item.Into);

                parentList.Sort((a, b) => a.Gold.Base.CompareTo(b.Gold.Base));
                foreach (ItemDto parent in parentList)
                {
                    message.AppendDescriptionNewLine()
                    .AppendDescription($"{parent.Name} ({parent.Gold.Base} Gold)");
                }
            }
        }
Exemple #19
0
        private async Task ProcessClear()
        {
            try
            {
                IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this.Context);

                await this._remindService.ClearUserAsync(this.Context.User.Id);

                FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                                .AppendTitle($"{XayahReaction.Success} Done")
                                                .AppendDescription("I purged all of your reminders.");
                await channel.SendEmbedAsync(message);

                await this.Context.Message.AddReactionIfNotDMAsync(this.Context, XayahReaction.Envelope);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #20
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);
        }
Exemple #21
0
        private async Task ProcessItem(string name)
        {
            try
            {
                if (this.IsDisabled())
                {
                    this.NotifyDisabledCommand();
                    return;
                }
                IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this.Context);

                FormattedEmbedBuilder message = await ItemDataBuilder.BuildAsync(name);

                await channel.SendEmbedAsync(message);

                await this.Context.Message.AddReactionIfNotDMAsync(this.Context, XayahReaction.Envelope);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #22
0
 private FormattedEmbedBuilder AppendRiotDataHelp(FormattedEmbedBuilder message)
 {
     this.AppendDescriptionTitle(message, _cRiotDataTitle)
     .AppendDescription("Have you ever wondered how far I could throw my Double Daggers? How much base armor Viktor has? How much does Essence Reaver cost? " +
                        "I at least know the answer to the first and last one. Not enough and way too much, respectively.")
     .AppendDescriptionNewLine(2)
     .AppendDescription("If you need data about a champion or item just use these commands and you'll get an overview about stats, spells and skins for champions and item cost and composition " +
                        "for... well, items.")
     .AppendDescriptionNewLine(2)
     .AppendDescription("Bonus:", AppendOption.Italic)
     .AppendDescription(" If you are unsure how to spell a certain champion or item name you can ignore special characters and/or whitespaces. " +
                        "If it's even worse (hello Cassiopeia) then I can also handle partial names.")
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Usage")
     .AppendDescription("The keyword to this command is `champ` or `item` followed by the name I should search for.")
     .AppendDescriptionNewLine(2);
     this.AppendDescriptionTitle(message, "Examples")
     .AppendDescription($"{this.Context.Client.CurrentUser.Mention} champ Xayah")
     .AppendDescriptionNewLine()
     .AppendDescription($"{this.Context.Client.CurrentUser.Mention} item Essence Reaver");
     return(message);
 }
Exemple #23
0
        private void AppendStatsOfRole(LeagueRole role, int entryCount, FormattedEmbedBuilder message)
        {
            List <ChampionStatsDto> roleStats = this._championStats.Where(x => x.Role.Equals(role.ApiRole)).ToList();

            if (entryCount * 2 > roleStats.Count)
            {
                entryCount = (int)Math.Truncate(roleStats.Count / (decimal)2);
            }
            FormattedTextBuilder winrates = new FormattedTextBuilder();

            for (int i = 0; i < entryCount && i < roleStats.Count; i++)
            {
                ChampionStatsDto topX         = roleStats.ElementAt(i);
                string           championLine = this.BuildChampionStats(topX, i + 1);
                if (i > 0)
                {
                    winrates.AppendNewLine();
                }
                winrates.Append(championLine);
            }
            if (roleStats.Count > entryCount * 2)
            {
                winrates.AppendNewLine();
            }
            for (int i = roleStats.Count - entryCount; i >= 0 && i < roleStats.Count; i++)
            {
                ChampionStatsDto bottomX      = roleStats.ElementAt(i);
                string           championLine = this.BuildChampionStats(bottomX, i + 1);
                winrates.AppendNewLine().Append(championLine);
            }
            string resultText = winrates.ToString();

            if (string.IsNullOrWhiteSpace(resultText))
            {
                resultText = ". . .";
            }
            message.AddField(role.Name, resultText, new AppendOption[] { AppendOption.Underscore });
        }
Exemple #24
0
        private async Task ProcessHelp(string text)
        {
            try
            {
                text = this.TrimText(text);
                IMessageChannel channel = await ChannelProvider.GetDMChannelAsync(this.Context);

                FormattedEmbedBuilder message = new FormattedEmbedBuilder()
                                                .AppendTitle("Xayah Bot Help");
                switch (NumberUtil.StripForNumber(text))
                {
                case 1:
                    this.Append8BallHelp(message);
                    break;

                case 2:
                    this.AppendRemindHelp(message);
                    break;

                case 3:
                    this.AppendRiotDataHelp(message);
                    break;

                default:
                    this.AppendGeneralHelp(message);
                    break;
                }
                await channel.SendEmbedAsync(message);

                await this.Context.Message.AddReactionIfNotDMAsync(this.Context, XayahReaction.Envelope);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #25
0
 private FormattedEmbedBuilder AppendDescriptionTitle(FormattedEmbedBuilder message, string text)
 {
     return(message.AppendDescription(text, AppendOption.Underscore).AppendDescriptionNewLine());
 }
 public static Task <IUserMessage> SendEmbedAsync(this IMessageChannel channel, FormattedEmbedBuilder embedBuilder)
 {
     return(channel.SendMessageAsync("", embed: embedBuilder.ToEmbed()));
 }
Exemple #27
0
 public static Task <IUserMessage> ReplyAsync(this ModuleBase <ICommandContext> module, FormattedEmbedBuilder embedBuilder)
 {
     return(module.Context.Channel.SendEmbedAsync(embedBuilder));
 }