示例#1
0
        public void SendLogStart(string starter)
        {
            if (Message != null)
            {
                return;
            }
            var embed = new Discord.EmbedBuilder();

            if (Program.BOT_DEBUG)
            {
                embed.Title = "Debug Game Started";
                embed.Color = Discord.Color.Red;
            }
            else
            {
                embed.Title = "Online Game Started";
            }
            embed.WithUrl(MLAPI.Handler.LocalAPIUrl + "/chess/online");
            embed.WithDescription($"{starter} has started an cross-network game of chess.\n" +
                                  $"Click the link title above to view.\n" +
                                  $"To play or spectate, you will need to [review the Terms]({MLAPI.Handler.LocalAPIUrl}/chess/terms#online), " +
                                  $"then [download the client](https://github.com/CheAle14/bot-chess/releases/latest/download/ChessInstaller.exe)");
            var msg = ChessS.DiscussionChannel.SendMessageAsync("[...]", embed: embed.Build()).Result;

            Message = msg;
            updateBoard();
        }
示例#2
0
        public static Discord.EmbedBuilder UserInfo(string username)
        {
            RootObject root = RequestHandler.GetUserByName(username);
            User       user = root.user;

            Discord.EmbedBuilder builder = Builders.BaseBuilder("Link to " + Names.SmashLadder + " Profile", "All information known about **" + user.username + "**",
                                                                ColorPicker.SmashModule,
                                                                new EmbedAuthorBuilder().WithName(Names.SmashLadder)
                                                                .WithUrl("http://www.smashladder.com"), "");
            builder.WithThumbnailUrl("https://www.smashladder.com/images/subhypepikachu-logo.png");
            if (user.selected_flair != null)
            {
                builder.WithAuthor(new EmbedAuthorBuilder().WithName(Names.SmashLadder)
                                   .WithUrl("http://www.smashladder.com").WithIconUrl("http:" + user.selected_flair.url));
            }
            string location = "";

            if (!string.IsNullOrEmpty(user.location.Locality))
            {
                location += user.location.Locality + ", ";
            }
            if (!string.IsNullOrEmpty(user.location.State))
            {
                location += user.location.State + ", ";
            }
            if (!string.IsNullOrEmpty(user.location.Country.name))
            {
                location += user.location.Country.name;
            }
            string status = "Offline";
            string sub    = "";

            if (user.is_online != null)
            {
                status = "Online";
            }
            if (user.is_subscribed != null)
            {
                sub = "**User is subscribed!**\n";
            }
            builder.AddField(new EmbedFieldBuilder().WithName("Profile").WithValue(
                                 "**Name: **" + user.username + "\n" +
                                 "**Member Since: **" + user.member_since.full.ToLongDateString() + "\n" +
                                 "**Location: **" + location + "\n" +
                                 "**Status message: **" + user.away_message + "\n" +
                                 "**Total matches played: **" + user.total_matches_played + "\n" +
                                 "**Status: **" + status + "\n" + sub
                                 ));
            var filteredgames = user.ladder_information.AllGames.Where(x => x != null).ToList();

            try
            {
                filteredgames = filteredgames.Where(x => x.league.stats.RankedPlayed != 0).ToList();
            }
            catch
            {
                //No ranked games played
            }
            foreach (var game in filteredgames)
            {
                try
                {
                    var characters = "";
                    var count      = 3;
                    if (game.characters.Count < count)
                    {
                        count = game.characters.Count;
                    }
                    if (count != 0)
                    {
                        characters = "**Characters:**\n";
                        for (int i = 0; i < count; i++)
                        {
                            characters += "**  " + game.characters[i].name + ": **" + game.characters[i].percent + "%\n";
                        }
                    }
                    var rank = "**Ranked: **Unranked\n";
                    if (!string.IsNullOrEmpty(game.league.Tier))
                    {
                        rank = "**Ranked: **" + game.league.Tier + " " + game.league.Division + "\n";
                    }
                    builder.AddField(new EmbedFieldBuilder().WithName(game.name).WithValue(
                                         "**Total ranked games played: **" + game.league.stats.RankedPlayed + "\n" +
                                         rank +
                                         characters
                                         ));
                }
                catch
                {
                }
            }

            if (root.now_playing != null)
            {
                string type = "Friendlies";
                if (root.now_playing.is_ranked)
                {
                    type = "Ranked";
                }

                string rankp1 = "Unranked";
                try
                {
                    var games1 = root.now_playing.player1.ladder_information.AllGames;
                    games1 = games1.Where(x => x != null).ToList();
                    SmashHandler.DataTypes.Game gamep1 = games1.Single(x => x.id == root.now_playing.ladder.id);
                    if (!string.IsNullOrEmpty(gamep1.league.Tier))
                    {
                        rankp1 = gamep1.league.Tier + " " + gamep1.league.Division;
                    }
                }
                catch { }
                string rankp2 = "Unranked";
                try
                {
                    var games2 = root.now_playing.player2.ladder_information.AllGames;
                    games2 = games2.Where(x => x != null).ToList();
                    SmashHandler.DataTypes.Game gamep2 = games2.Single(x => x.id == root.now_playing.ladder.id);
                    if (!string.IsNullOrEmpty(gamep2.league.Tier))
                    {
                        rankp2 = gamep2.league.Tier + " " + gamep2.league.Division;
                    }
                }
                catch { }
                builder.AddField(new EmbedFieldBuilder().WithName("Currently Playing").WithValue(
                                     "**" + root.now_playing.ladder_name + " " + type + "**: \n" +
                                     "Using " + root.now_playing.preferred_build.name + "\n" +
                                     root.now_playing.player1.username + " " + "(" + rankp1 + ")" + " vs " + root.now_playing.player2.username + " (" + rankp2 + ")"));
            }
            builder.WithUrl(user.profile_url);
            return(builder);
        }
示例#3
0
        public async Task GetCharacter([Remainder][Summary("The name of the chracter")] string name)
        {
            var character = RequestHandler.GetCharacterName(name);

            if (character == null)
            {
                await ReplyAsync("", embed : Builders.ErrorBuilder("Character not found"));
            }
            var moves = RequestHandler.GetMoves(name);

            Discord.EmbedBuilder builder = Builders.BaseBuilder("", "", Color.DarkTeal,
                                                                new EmbedAuthorBuilder().WithName("KuroganeHammer Result:").WithUrl("http://kuroganehammer.com"),
                                                                character.ThumbnailURL);
            //builder.WithImageUrl(character.MainImageURL);
            builder.WithUrl(character.FullURL);
            string info = "";

            info += "**Name: **" + character.Name;
            if (!string.IsNullOrEmpty(character.Description))
            {
                info += "**Description: **" + character.Description;
            }
            if (!string.IsNullOrEmpty(character.Style))
            {
                info += "**Style: **" + character.Style;
            }
            builder.AddField(new EmbedFieldBuilder().WithName("Information").WithValue(info));
            var movement = RequestHandler.GetMovement(name);
            var half     = movement.Attributes.Count / 2;
            var info1    = "";
            var info2    = "";

            for (int i = 0; i < movement.Attributes.Count / 2; i++)
            {
                info1 += $"**{movement.Attributes[i].Name}**: {movement.Attributes[i].Value}\n";
                info2 += $"**{movement.Attributes[i + half].Name}**: {movement.Attributes[i + half].Value}\n";
            }
            builder.AddInlineField("Movement", info1);
            builder.AddInlineField("Movement", info2);
            string movesinfo    = "";
            string specials     = "";
            int    specialcount = 0;
            string aerials      = "";
            string smashes      = "";
            string grabs        = "";
            string tilts        = "";

            moves.ForEach(x =>
            {
                if (x.MoveType == "ground")
                {
                    if (x.Name.Contains("smash"))
                    {
                        smashes += x.Name + "\n";
                    }
                    else if (x.Name.Contains("tilt"))
                    {
                        tilts += x.Name + "\n";
                    }
                    else if (x.Name.ToLower().Contains("grab"))
                    {
                        grabs += x.Name + "\n";
                    }
                    else
                    {
                        movesinfo += x.Name + "\n";
                    }
                }

                if (x.MoveType == "special")
                {
                    specials += x.Name + "\n";
                    specialcount++;
                }
                if (x.MoveType == "aerial")
                {
                    aerials += x.Name + "\n";
                }
            });
            builder.AddInlineField("Ground Moves", movesinfo);
            builder.AddInlineField("Smashes", smashes);
            builder.AddInlineField("Specials", specials);
            builder.AddInlineField("Aerials", aerials);
            builder.AddInlineField("Tilts", tilts);
            builder.AddInlineField("Grabs", tilts);
            await ReplyAsync("", embed : builder.Build());
        }