Beispiel #1
0
        public static void RegisterRemoveBaseNoteCommand(CommandService commands, DiscordClient discord)
        {
            commands.CreateCommand("Remove Enemy Note")
            .Description("!remove enemy note [base number] - remove the note from the enemy war base.")
            .AddCheck((command, user, channel) => !user.IsBot)
            .Parameter("Base", ParameterType.Required)
            .Do(async(e) =>
            {
                try
                {
                    ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                    War curWar = new War();
                    curWar     = (from w in dc.Wars
                                  orderby w.Date descending
                                  select w).Take(1).SingleOrDefault();

                    EnemyBase eb = new EnemyBase();
                    eb           = (from b in dc.EnemyBases
                                    where b.WarID == curWar.WarID &&
                                    b.EnemyBaseNo.ToString() == e.GetArg("Base")
                                    select b).SingleOrDefault();


                    eb.Notes = null;

                    dc.SubmitChanges();

                    await e.Channel.SendMessage("NOTE REMOVED FROM ENEMY BASE #" + e.GetArg("Base"));
                }
                catch (Exception ex) { discord.Log.Error("RegisterRemoveBaseNoteCommand", ex.Message); }
            });
        }
Beispiel #2
0
        public static async Task LogWarNews(string msg, DateTime eventTime, string userName)
        {
            await Task.Delay(500);

            ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
            WarNew newNews = new WarNew();

            newNews.NewsID       = Guid.NewGuid();
            newNews.News         = msg;
            newNews.PostDateTime = eventTime;
            newNews.UserName     = userName;
            try
            {
                dc.WarNews.InsertOnSubmit(newNews);
                dc.SubmitChanges();
            }
            catch (Exception ex) { throw ex; }
        }
Beispiel #3
0
 public static void RegisterPlayerWarningCommand(CommandService commands, DiscordClient discord)
 {
     commands.CreateCommand("Add Warning")
     .Description("!add warning [name] [warning] - add a player warning!")
     .AddCheck((command, user, channel) => !user.IsBot)
     .AddCheck((command, user, channel) => user.Roles.FirstOrDefault().Name == "@Co-Leader")
     .Parameter("name", ParameterType.Required)
     .Parameter("warning", ParameterType.Required)
     .Do(async(e) =>
     {
         try
         {
             ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
             User user = (from u in dc.Users
                          where u.UserName.ToLower().Equals(e.GetArg(0).ToLower())
                          select u).First();
             if (user != null)
             {
                 Warning warning = (from w in dc.Warnings
                                    where w.WarningName.ToUpper() == e.GetArg(1).ToUpper()
                                    select w).First();
                 if (warning != null)
                 {
                     UserWarning uw = new UserWarning {
                         UserId = user.UserId, WarningId = warning.WarningId, WarningDateTime = DateTime.UtcNow
                     };
                     dc.UserWarnings.InsertOnSubmit(uw);
                     dc.SubmitChanges();
                     await e.Channel.SendMessage(warning.WarningName + " WARNING ADDED TO " + e.GetArg(0).ToUpper());
                 }
                 else
                 {
                     await e.Channel.SendMessage(e.GetArg(1).ToUpper() + " IS NOT A VALID WARNING CODE!");
                 }
             }
             else
             {
                 await e.Channel.SendMessage(e.GetArg(0).ToUpper() + " NOT FOUND!");
             }
         }
         catch (Exception ex) { discord.Log.Error("RegisterGetClaimedBasesCommand", ex.Message); }
     });
 }
Beispiel #4
0
 public static void RegisterRemovePlayerWarningCommand(CommandService commands, DiscordClient discord)
 {
     commands.CreateCommand("Remove Warning")
     .Description("!remove warning [name] - remove players last warning!")
     .AddCheck((command, user, channel) => !user.IsBot)
     .AddCheck((command, user, channel) => user.Roles.FirstOrDefault().Name == "@Co-Leader")
     .Parameter("name", ParameterType.Required)
     .Do(async(e) =>
     {
         try
         {
             ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
             User user = (from u in dc.Users
                          where u.UserName.ToLower().Contains(e.GetArg(0).ToLower())
                          select u).First();
             if (user != null)
             {
                 UserWarning uw = (from warning in dc.UserWarnings
                                   where warning.UserId == user.UserId
                                   orderby warning.WarningDateTime descending
                                   select warning).First();
                 if (uw != null)
                 {
                     dc.UserWarnings.DeleteOnSubmit(uw);
                     dc.SubmitChanges();
                     string warning = (from w in dc.Warnings where w.WarningId == uw.WarningId select w.WarningName).ToString();
                     await e.Channel.SendMessage(warning.ToUpper() + " WARNING REMOVED FROM " + e.GetArg(0).ToUpper());
                 }
                 else
                 {
                     await e.Channel.SendMessage("NO WARNINGS NOT FOUND FOR " + e.GetArg(0).ToUpper() + "!");
                 }
             }
             else
             {
                 await e.Channel.SendMessage(e.GetArg(0).ToUpper() + " NOT FOUND!");
             }
             await e.Channel.SendMessage("WARING LOGGED AGAINST " + e.GetArg(0).ToUpper());
         }
         catch (Exception ex) { discord.Log.Error("RegisterGetClaimedBasesCommand", ex.Message); }
     });
 }
Beispiel #5
0
        public static void RegisterWarningCommands(CommandService commands, DiscordClient discord)
        {
            commands.CreateGroup("warning", cgb =>
            {
                cgb.Category("=== WARNING COMMANDS ===");
                cgb.CreateCommand("list")
                .Description("!warning list - list all member warnings for current season.")
                .Alias(new string[] { "-l", "" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Do(async(e) =>
                {
                    #region warning list
                    try
                    {
                        string message = "**MEMBER WARNINGS** \n";

                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        List <Warning> warnings      = new List <Warning>();
                        warnings = (from w in dc.Warnings
                                    select w).ToList();
                        message += "```";
                        foreach (Warning w in warnings)
                        {
                            message += "| " + w.WarningName + " = " + w.WarningDescription + " ";
                        }
                        message += "|``` ```";
                        foreach (Warning w in warnings)
                        {
                            message += "" + w.WarningName + ": ";
                            List <UserWarning> userwarnings = new List <UserWarning>();
                            userwarnings = (from uw in dc.UserWarnings
                                            join u in dc.Users on uw.UserId equals u.UserId
                                            join uir in dc.UsersInRoles on u.UserId equals uir.UserId
                                            where uw.WarningId == w.WarningId &&
                                            uir.Role.RoleRank <= 3
                                            select uw).Distinct().ToList();
                            userwarnings = userwarnings
                                           .GroupBy(uw => uw.UserId)
                                           .Select(g => g.First())
                                           .ToList();
                            foreach (UserWarning uw in userwarnings)
                            {
                                User user = (from u in dc.Users
                                             where u.UserId == uw.UserId
                                             select u).FirstOrDefault();
                                int count = (from uwCount in dc.UserWarnings
                                             where uwCount.UserId == user.UserId &&
                                             uwCount.WarningId == w.WarningId
                                             select uwCount).Count();
                                message += user.UserName + "(" + count + "), ";
                            }
                            message += "\n";
                        }
                        message += "```";
                        await e.Channel.SendMessage(message);
                    }
                    catch (Exception ex) { discord.Log.Error("RegisterGetClaimedBasesCommand", ex.Message); }
                    #endregion
                });

                cgb.CreateCommand("Add")
                .Description("!warning add [name] [warning] - add a player warning!")
                .Alias(new string[] { "-a" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("name", ParameterType.Required)
                .Parameter("warning", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region warning add
                    try
                    {
                        if (e.Message.User.Roles.First().Name == "@Co-Leader")
                        {
                            ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                            User user = (from u in dc.Users
                                         where u.UserName.ToLower().Equals(e.GetArg(0).ToLower())
                                         select u).First();
                            if (user != null)
                            {
                                Warning warning = (from w in dc.Warnings
                                                   where w.WarningName.ToUpper() == e.GetArg(1).ToUpper()
                                                   select w).First();
                                if (warning != null)
                                {
                                    UserWarning uw = new UserWarning {
                                        UserId = user.UserId, WarningId = warning.WarningId, WarningDateTime = DateTime.UtcNow
                                    };
                                    dc.UserWarnings.InsertOnSubmit(uw);
                                    dc.SubmitChanges();
                                    await e.Channel.SendMessage(warning.WarningName + " WARNING ADDED TO " + e.GetArg(0).ToUpper());
                                }
                                else
                                {
                                    await e.Channel.SendMessage(e.GetArg(1).ToUpper() + " IS NOT A VALID WARNING CODE!");
                                }
                            }
                            else
                            {
                                await e.Channel.SendMessage(e.GetArg(0).ToUpper() + " NOT FOUND!");
                            }
                        }
                        else
                        {
                            await e.Channel.SendMessage("YOU DO NOT HAVE PERMISSION! " + e.Message.User.Roles.First());
                        }
                    }
                    catch (Exception ex) { discord.Log.Error("RegisterGetClaimedBasesCommand", ex.Message); }
                    #endregion
                });

                cgb.CreateCommand("remove")
                .Description("!warning remove [name] [warning] - remove a player warning!")
                .Alias(new string[] { "-r" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("name", ParameterType.Required)
                .Parameter("warning", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region warning remove
                    try
                    {
                        if (e.Message.User.Roles.First().Name == "@Co-Leader")
                        {
                            ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                            Warning warningToRemove      = (from wtr in dc.Warnings
                                                            where wtr.WarningName.ToUpper() == e.GetArg(1).ToUpper()
                                                            select wtr).First();
                            User user = (from u in dc.Users
                                         where u.UserName.ToLower() == (e.GetArg(0).ToLower())
                                         select u).First();
                            if (user != null)
                            {
                                UserWarning uw = (from uwarning in dc.UserWarnings
                                                  where uwarning.UserId == user.UserId &&
                                                  uwarning.WarningId == warningToRemove.WarningId
                                                  orderby uwarning.WarningDateTime descending
                                                  select uwarning).FirstOrDefault();
                                if (uw != null)
                                {
                                    dc.UserWarnings.DeleteOnSubmit(uw);
                                    dc.SubmitChanges();
                                    string warning = (from w in dc.Warnings where w.WarningId == uw.WarningId select w.WarningName).ToString();
                                    await e.Channel.SendMessage(warningToRemove.WarningName.ToUpper() + " WARNING REMOVED FROM " + e.GetArg(0).ToUpper());
                                }
                                else
                                {
                                    await e.Channel.SendMessage("NO WARNINGS NOT FOUND FOR " + e.GetArg(0).ToUpper() + "!");
                                }
                            }
                            else
                            {
                                await e.Channel.SendMessage(e.GetArg(0).ToUpper() + " NOT FOUND!");
                            }
                        }
                        else
                        {
                            await e.Channel.SendMessage("YOU DO NOT HAVE PERMISSION! " + e.Message.User.Roles.First());
                        }
                    }
                    catch (Exception ex)
                    {
                        discord.Log.Error("RegisterGetClaimedBasesCommand", ex);
                    }
                    #endregion
                });
            });
        }
Beispiel #6
0
        /// <summary>
        /// Handles the register of all setting commands with the discord server
        /// </summary>
        /// <param name="commands">CommandService pointer</param>
        /// <param name="discord">DiscordClient pointer</param>
        public static void RegisterWebsiteCommands(CommandService commands, DiscordClient discord)
        {
            //create group for settings commands
            commands.CreateGroup("set", cgb =>
            {
                cgb.Category("=== SETTING COMMANDS ===");
                //create link command to link discord account to website account
                cgb.CreateCommand("link")
                .Description("!set link - link your discord to the website, allowing website commands.")
                .Alias(new string[] { "-l" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("username", ParameterType.Optional)
                .Parameter("password", ParameterType.Optional)
                .Do(async(e) =>
                {
                    #region set link
                    List <Message> myMessages = new List <Message>();
                    Message[] messages        = null;
                    //if message came from public channel
                    if (!e.Channel.IsPrivate)
                    {
                        if (currentCommands == null)
                        {
                            currentCommands = new List <ResultObjects.TwoPartCommand>();
                        }
                        List <ResultObjects.TwoPartCommand> oldCommands = new List <ResultObjects.TwoPartCommand>();
                        //check is the user has any incomple two part commands
                        foreach (ResultObjects.TwoPartCommand tpc in currentCommands)
                        {
                            if (tpc.user.Id == e.User.Id)
                            {
                                oldCommands.Add(tpc);
                            }
                        }
                        //remove the incomplete commands
                        currentCommands.RemoveAll(item => oldCommands.Contains(item));
                        //add this new command so we can get the origin message event
                        currentCommands.Add(new ResultObjects.TwoPartCommand()
                        {
                            command = e, channel = e.Channel, user = e.User
                        });

                        //if someone posts username and password into public channel, delete it ASAP
                        if (e.GetArg(0) != "" || e.GetArg(1) != "")
                        {
                            try
                            {
                                messages = await e.Channel.DownloadMessages(25);
                                messages = messages.OrderByDescending(x => x.Timestamp).ToArray();
                                //currenly just gets last message.. this needs improving to check for user of last message
                                myMessages.Add(messages[0]);
                                await e.Channel.DeleteMessages(myMessages.ToArray());
                                myMessages.Clear();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("ERROR! - " + ex.Message);
                            }
                            await e.Message.Channel.SendMessage("**WARNING** ```DO NOT POST YOU WEBSITE LOGIN IN A PUBLIC CHANNEL. IF THE DETAILS WERE CORRECT, YOU SHOULD CHANGE YOUR PASSWORD ASAP!...```");
                        }

                        await e.Message.Channel.SendMessage("**WEBSITE LINK STARTED** ```PLEASE COMPLETE VIA PRIVATE MESSAGE...```");
                        await e.User.PrivateChannel.SendMessage("```WEBSITE LINK WARNING: only ever attempt this via private message. linking from a chat channel will reveal your password! \n"
                                                                + " To link discord to the website repeat the previous command with the addition of your website username and password. \n"
                                                                + " e.g !set link <website_username> <website_password>```");
                    }
                    //if message is private message
                    else
                    {
                        try
                        {
                            bool success = false;
                            //attempt to select user with entered username
                            ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                            User user = (from u in dc.Users
                                         where u.UserName == e.GetArg(0)
                                         select u).FirstOrDefault();
                            //if user exists
                            if (user != null)
                            {
                                //hash, salt and check passwords is correct
                                if (Encode.EncodePassword(e.GetArg(1), MembershipPasswordFormat.Hashed, user.Membership.PasswordSalt) == user.Membership.Password)
                                {
                                    //if user is not linked
                                    if (user.DiscordId == null)
                                    {
                                        //link discord id
                                        user.DiscordId = e.User.Id.ToString();
                                        try
                                        {
                                            dc.SubmitChanges();
                                            success = true;
                                        }
                                        catch (Exception ex)
                                        {
                                            discord.Log.Error("Admin.RegisterLinkAccountCommand: error submitting changes.", ex.Message);
                                        }
                                        if (success)
                                        {
                                            await e.User.PrivateChannel.SendMessage("```WEBSITE LINK SUCCESSFUL: you can now claim bases on the website and much more...!```");
                                            if (currentCommands.Find(item => e.User.Id == item.user.Id).channel != null)
                                            {
                                                await currentCommands.Find(item => e.User.Id == item.user.Id).channel.SendMessage("**WEBSITE LINK COMPLETE** ```" + e.User.Name.ToUpper() + " IS POWERED UP AND READY!!```");
                                            }
                                        }
                                    }
                                    //if user is already linked to that account
                                    else if (user.DiscordId == e.User.Id.ToString())
                                    {
                                        success = true;
                                        await e.User.PrivateChannel.SendMessage("```WEBSITE LINK SUCCESSFUL: that account is already linked!```");
                                        if (currentCommands.Find(item => e.User.Id == item.user.Id).channel != null)
                                        {
                                            await currentCommands.Find(item => e.User.Id == item.user.Id).channel.SendMessage("**WEBSITE LINK COMPLETE** ```" + e.User.Name.ToUpper() + " IS POWERED UP AND READY!!```");
                                        }
                                    }
                                    //if user is linked but to a differant discord account
                                    else
                                    {
                                        await e.User.PrivateChannel.SendMessage("```WEBSITE LINK FAILED: that account is already linked!```");
                                    }
                                }
                                //if incorrect password
                                else
                                {
                                    await e.User.PrivateChannel.SendMessage("```WEBSITE LINK FAILED: please check your username and password are correct!```");
                                }
                            }
                            //if incorrect username
                            else
                            {
                                await e.User.PrivateChannel.SendMessage("```WEBSITE LINK FAILED: user not found!```");
                            }

                            //if account link failed for any reason
                            if (!success)
                            {
                                if (currentCommands != null)
                                {
                                    if (currentCommands.Find(item => e.User.Id == item.user.Id).channel != null)
                                    {
                                        await currentCommands.Find(item => e.User.Id == item.user.Id).channel.SendMessage("**WEBSITE LINK CANCELED** ```PLEASE CHECK PRIVATE MESSAGE FOR DETAILS.```");
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            discord.Log.Error("Admin.RegisterLinkAccountCommand", ex.Message);
                        }
                    }
                    #endregion
                });
            });
        }
Beispiel #7
0
        public static void RegisterEnemyNoteCommands(CommandService commands, DiscordClient discord)
        {
            commands.CreateGroup("enemy note", cgb =>
            {
                cgb.Category("=== ENEMY NOTES COMMANDS ===");
                cgb.CreateCommand("list")
                .Description("!enemy note list - list all enemy base notes")
                .Alias(new string[] { "-l" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Do(async(e) =>
                {
                    #region enemy note list
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        List <EnemyBasesView> res    = new List <EnemyBasesView>();
                        res = (from ebv in dc.EnemyBasesViews select ebv).ToList();

                        string message = "ENEMY BASE NOTES: \n";
                        foreach (EnemyBasesView eb in res)
                        {
                            if (eb.NOTES != null && eb.NOTES != "")
                            {
                                message += "BASE: #" + eb.BASE__
                                           + ((eb.CLAIMED_BY == null) ? " | NOT CLAIMED" : " | CLAIMED BY: " + eb.CLAIMED_BY)
                                           + ((eb.ATTACKS == 0) ? "" : (" | ATTACKS: " + eb.ATTACKS
                                                                        + " | BEST ATTACK: " + eb.BEST
                                                                        + " | STARS: " + eb.STARS
                                                                        + " | DAMAGE: " + eb.DAMAGE + "%"))
                                           + ((eb.NOTES == null) ? "" : (" | NOTES: " + eb.NOTES)) + "\n";
                            }
                        }

                        await e.Channel.SendMessage(message);
                    }
                    catch (Exception ex) { discord.Log.Error("RegisterDisplayEnemyBaseNotes", ex.Message); }
                    #endregion
                });

                cgb.CreateCommand("add")
                .Description("!enemy note add [base number] ['note'] - add a note to the enemy war base.")
                .Alias(new string[] { "-a" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("Base", ParameterType.Required)
                .Parameter("Note", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region enemy note add
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        War curWar = new War();
                        curWar     = (from w in dc.Wars
                                      orderby w.Date descending
                                      select w).Take(1).SingleOrDefault();

                        EnemyBase eb = new EnemyBase();
                        eb           = (from b in dc.EnemyBases
                                        where b.WarID == curWar.WarID &&
                                        b.EnemyBaseNo.ToString() == e.GetArg("Base")
                                        select b).SingleOrDefault();


                        eb.Notes = e.GetArg("Note");

                        dc.SubmitChanges();

                        await e.Channel.SendMessage("NOTE ADDED TO ENEMY BASE #" + e.GetArg("Base"));
                    }
                    catch (Exception ex) { discord.Log.Error("RegisterAddBaseNoteCommand", ex.Message); }
                    #endregion
                });

                cgb.CreateCommand("remove")
                .Description("!enemy note remove [base number] - remove the note from the enemy war base.")
                .Alias(new string[] { "-r" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("Base", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region enemy note remove
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        War curWar = new War();
                        curWar     = (from w in dc.Wars
                                      orderby w.Date descending
                                      select w).Take(1).SingleOrDefault();

                        EnemyBase eb = new EnemyBase();
                        eb           = (from b in dc.EnemyBases
                                        where b.WarID == curWar.WarID &&
                                        b.EnemyBaseNo.ToString() == e.GetArg("Base")
                                        select b).SingleOrDefault();


                        eb.Notes = null;

                        dc.SubmitChanges();

                        await e.Channel.SendMessage("NOTE REMOVED FROM ENEMY BASE #" + e.GetArg("Base"));
                    }
                    catch (Exception ex) { discord.Log.Error("RegisterRemoveBaseNoteCommand", ex.Message); }
                    #endregion
                });
            });
        }
Beispiel #8
0
        public static void RegisterWarCommands(CommandService commands, DiscordClient discord)
        {
            commands.CreateGroup("war", cgb =>
            {
                cgb.Category("=== WAR COMMANDS ===");
                cgb.CreateCommand("info")
                .Description("!war info - list all war bases.")
                .Alias(new string[] { "-i", "" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Do(async(e) =>
                {
                    #region war info
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        List <EnemyBasesView> res    = new List <EnemyBasesView>();
                        res = (from ebv in dc.EnemyBasesViews select ebv).ToList();

                        string message = "WAR INFO: \n";
                        foreach (EnemyBasesView eb in res)
                        {
                            if (eb.STARS == 3)
                            {
                                message += "`#" + eb.BASE__
                                           + ((eb.CLAIMED_BY == null) ? " | FLAT" : " | CLAIMED BY: " + eb.CLAIMED_BY)
                                           + ((eb.ATTACKS == 0) ? "" : (" | ATTACKS: " + eb.ATTACKS
                                                                        + " | BEST ATTACK: " + eb.BEST
                                                                        + " | STARS: " + eb.STARS
                                                                        + " | DAMAGE: " + eb.DAMAGE + "%")) + "`\n";
                            }
                            else
                            {
                                message += "`#" + eb.BASE__
                                           + ((eb.CLAIMED_BY == null) ? " | FREE" : " | CLAIMED BY: " + eb.CLAIMED_BY)
                                           + ((eb.ATTACKS == 0) ? "" : (" | ATTACKS: " + eb.ATTACKS
                                                                        + " | BEST ATTACK: " + eb.BEST
                                                                        + " | STARS: " + eb.STARS
                                                                        + " | DAMAGE: " + eb.DAMAGE + "%")) + "`\n";
                            }
                        }

                        await e.Channel.SendMessage(message);
                    }
                    catch (Exception ex) { discord.Log.Error("RegisterDisplayWarInfoCommand", ex.Message); }
                    #endregion
                });

                cgb.CreateCommand("claimed")
                .Description("!war claimed - get a list of claimed war bases.")
                .Alias(new string[] { "-c" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Do(async(e) =>
                {
                    #region war claimed bases
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        List <EnemyBasesView> res    = new List <EnemyBasesView>();
                        res = (from ebv in dc.EnemyBasesViews select ebv).ToList();

                        string message = "**CLAIMED WAR BASES** \n";
                        foreach (EnemyBasesView eb in res)
                        {
                            if (eb.CLAIMED_BY != null && eb.CLAIMED_BY != "")
                            {
                                TimeSpan t        = TimeSpan.FromSeconds((int)eb.DATETIME);
                                string timepassed = string.Format("{0:D2}h:{1:D2}m:{2:D2}s", t.Hours, t.Minutes, t.Seconds);
                                message          += "```#" + eb.BASE__ + (((int)eb.BASE__ < 10) ? "  | CLAIMED BY: " : " | CLAIMED BY: ")
                                                    + eb.CLAIMED_BY + " | CLAIMED FOR: " + timepassed + "\n"
                                                    + ((eb.ATTACKS == 0) ? "" : ("    | ATTACKS: " + eb.ATTACKS
                                                                                 + " | BEST ATTACK: " + eb.BEST
                                                                                 + " | STARS: " + eb.STARS
                                                                                 + " | DAMAGE: " + eb.DAMAGE + "%")) + "```";
                            }
                        }
                        message += "";
                        await e.Channel.SendMessage(message);
                    }
                    catch (Exception ex) { discord.Log.Error("RegisterGetClaimedBasesCommand", ex.Message); }
                    #endregion
                });

                cgb.CreateCommand("enemy")
                .Description("!war enemy [base number] - show details of the requested war base.")
                .Alias(new string[] { "-e" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("Base", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region war enemy info
                    bool sucess = false;
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        EnemyBasesView ebv           = new EnemyBasesView();
                        ebv = (from eb in dc.EnemyBasesViews
                               where eb.BASE__.Equals(e.GetArg("Base"))
                               select eb).FirstOrDefault();
                        if (ebv == null)
                        {
                            await e.Channel.SendMessage("INVALID BASE NUMBER OR NO WAR IN PROGRESS");
                        }
                        else
                        {
                            await e.Channel.SendMessage("BASE: #" + ebv.BASE__
                                                        + ((ebv.CLAIMED_BY == null) ? " | NOT CLAIMED" : " | CLAIMED BY: " + ebv.CLAIMED_BY)
                                                        + ((ebv.ATTACKS == 0) ? "" : (" | ATTACKS: " + ebv.ATTACKS
                                                                                      + " | BEST ATTACK: " + ebv.BEST
                                                                                      + " | STARS: " + ebv.STARS
                                                                                      + " | DAMAGE: " + ebv.DAMAGE + "%"))
                                                        + ((ebv.NOTES == null) ? "" : (" | NOTES: " + ebv.NOTES)));
                        }
                        sucess = true;
                    }
                    catch (Exception ex) { sucess = false; throw ex; }
                    if (!sucess)
                    {
                        await e.Channel.SendMessage("THAT COMMAND IS NOT AVAILABLE RIGHT NOW!");
                    }
                    #endregion
                });

                cgb.CreateCommand("damage")
                .Description("!war damage - calculate and list available damage from remaining bases.")
                .Alias(new string[] { "-d", "dmg" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Do(async(e) =>
                {
                    #region war damage
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        List <EnemyBasesView> ebv    = new List <EnemyBasesView>();
                        ebv = (from eb in dc.EnemyBasesViews
                               select eb).ToList();
                        if (ebv != null)
                        {
                            double totaldamage = 0;
                            int warSize        = ebv.Count();

                            string result = "**AVAILABLE DAMAGE**\n";
                            foreach (EnemyBasesView eb in ebv)
                            {
                                double baseDmg = (100 / warSize) * (eb.DAMAGE ?? 0);
                                totaldamage   += baseDmg;
                                if (eb.DAMAGE != 100)
                                {
                                    if (eb.BASE__ < 10)
                                    {
                                        result += "`#" + eb.BASE__ + " ";
                                    }
                                    else
                                    {
                                        result += "`#" + eb.BASE__;
                                    }
                                    result += " | STARS: " + (eb.STARS ?? 0) + " | DAMAGE: " + (eb.DAMAGE ?? 0) + "% | AVAILABLE OVERALL DAMAGE: " + Math.Round(((100.00 / warSize) / 100) * (100.00 - (double)(eb.DAMAGE ?? 0.00)), 2) + "%`\n";
                                }
                            }
                            await e.Channel.SendMessage(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion
                });

                cgb.CreateCommand("claim target")
                .Description("!war claim target [base number] - claim a war base. **note: must have acount linked**")
                .Alias(new string[] { "-ct", "claim" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("baseNumber", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region war claim a target
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        User user = (from u in dc.Users
                                     where u.DiscordId == e.User.Id.ToString()
                                     select u).FirstOrDefault();

                        if (user != null)
                        {
                            int?returnValue = dc.ClaimBase(user.UserId.ToString(), e.GetArg(0));

                            switch (returnValue)
                            {
                            case 1:                 // Claim successful.
                                String msg = "TARGET CLAIMED: #" + e.GetArg(0) + " watch out! " + user.UserName + " is coming for you.";
                                await e.Channel.SendMessage("**CLAIM BASE** ```" + msg + "```");
                                await LogWarNews(msg, DateTime.UtcNow, user.UserName + " via ClanBot");
                                break;

                            case 51000:             // Both attacks already used.
                                await e.Channel.SendMessage("**CLAIM BASE** ```CLAIM FAILED: sorry " + user.UserName + " you have already used both of your attacks this war.```");
                                break;

                            case 51001:             // Base is already claimed.
                                await e.Channel.SendMessage("**CLAIM BASE** ```CLAIM FAILED: sorry " + user.UserName + " that base is already claimed.```");
                                break;

                            case 51002:             // Cannot hit the same base twice.
                                await e.Channel.SendMessage("**CLAIM BASE** ```CLAIM FAILED: sorry " + user.UserName + " you cannot attack the same base twice.```");
                                break;

                            case 0:                 // error claiming
                                await e.Channel.SendMessage("**CLAIM BASE** ```CLAIM FAILED: sorry " + user.UserName + " unable to claim base at the moment... please use the website.```");
                                break;
                            }
                        }
                        else
                        {
                            await e.Channel.SendMessage("**CLAIM BASE** ```CLAIM FAILED: account is not linked!```");
                        }
                    }
                    catch (Exception ex)
                    {
                        discord.Log.Error("RegisterDisplayWarInfoCommand", ex.Message);
                    }
                    #endregion
                });

                cgb.CreateCommand("unclaim target")
                .Description("!war unclaim target [base number] - unclaim a war base. **note: must have acount linked**")
                .Alias(new string[] { "-ut", "unclaim" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("baseNumber", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region war unclaim target
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        User user = (from u in dc.Users
                                     where u.DiscordId == e.User.Id.ToString()
                                     select u).FirstOrDefault();

                        if (user != null)
                        {
                            CurWarAttack attack = (from a in dc.CurWarAttacks
                                                   where a.UserID == user.UserId &&
                                                   a.EnemyBase.EnemyBaseNo.ToString() == e.GetArg(0)
                                                   select a).FirstOrDefault();

                            if (attack != null)
                            {
                                dc.CurWarAttacks.DeleteOnSubmit(attack);
                                dc.SubmitChanges();
                                String msg = "TARGET UNCLAIMED: #" + e.GetArg(0) + " you're lucky! " + user.UserName + " has decided not to smash your base.";
                                await e.Channel.SendMessage("**UNCLAIM BASE** ```" + msg + "```");
                                await LogWarNews(msg, DateTime.UtcNow, user.UserName + " via ClanBot");
                            }
                            else
                            {
                                await e.Channel.SendMessage("**UNCLAIM BASE** ```UNCLAIM FAILED: sorry " + user.UserName + " you do not seem to have claimed or attacked that base.```");
                            }
                        }
                        else
                        {
                            await e.Channel.SendMessage("**UNCLAIM BASE** ```UNCLAIM FAILED: account is not linked!```");
                        }
                    }
                    catch (Exception ex)
                    {
                        discord.Log.Error("RegisterDisplayWarInfoCommand", ex.Message);
                    }
                    #endregion
                });

                cgb.CreateCommand("enter result")
                .Description("!war enter result [base number] [stars] [attack_type] [damage] - enter attack results. **note: must have acount linked**")
                .Alias(new string[] { "-er", "result" })
                .AddCheck((command, user, channel) => !user.IsBot)
                .Parameter("baseNumber", ParameterType.Required)
                .Parameter("numOfStars", ParameterType.Required)
                .Parameter("attackType", ParameterType.Required)
                .Parameter("damagePerc", ParameterType.Required)
                .Do(async(e) =>
                {
                    #region war enter result
                    try
                    {
                        ClasherDynastyDataContext dc = new ClasherDynastyDataContext();
                        User user = (from u in dc.Users
                                     where u.DiscordId == e.User.Id.ToString()
                                     select u).FirstOrDefault();

                        // if user is linked
                        if (user != null)
                        {
                            CurWarAttack attack = (from a in dc.CurWarAttacks
                                                   where a.UserID == user.UserId &&
                                                   a.EnemyBase.EnemyBaseNo.ToString() == e.GetArg(0)
                                                   select a).FirstOrDefault();

                            // if claim or attack found for specified base
                            if (attack != null)
                            {
                                // if no resul entered
                                if (attack.Damage == null)
                                {
                                    // validate stars attack type and damage
                                    AttackValidationResult res = ValidateResults(e.GetArg(1), e.GetArg(2), e.GetArg(3));
                                    if (res.success)
                                    {
                                        attack.Stars      = res.stars;
                                        attack.AttackType = res.attackType;
                                        attack.Damage     = res.damage;
                                        dc.SubmitChanges();

                                        String msg = " ATTACK: " + user.UserName + " just smashed #" + e.GetArg(0) + " for " + e.GetArg(1) + " stars and " + e.GetArg(3) + "% damage with " + e.GetArg(2) + ".";
                                        await e.Channel.SendMessage("**ENTER RESULT** ```" + msg + "```");
                                        await LogWarNews(msg, DateTime.UtcNow, user.UserName + " via ClanBot");
                                    }
                                    else
                                    {
                                        string failMessage = "invalid results for: ";
                                        if (res.stars == null)
                                        {
                                            failMessage += "stars";
                                        }
                                        if (res.attackType == null)
                                        {
                                            if (res.stars == null)
                                            {
                                                failMessage += ", ";
                                            }
                                            failMessage += "attack type";
                                        }
                                        if (res.damage == null)
                                        {
                                            if (res.attackType == null)
                                            {
                                                failMessage += ", ";
                                            }
                                            failMessage += "damege";
                                        }
                                        await e.Channel.SendMessage("**ENTER RESULT** ```ENTER RESULT FAILED: sorry " + user.UserName + " " + failMessage + ".```");
                                    }
                                }
                                // if result already entered
                                else
                                {
                                    // validate stars attack type and damage
                                    AttackValidationResult res = ValidateResults(e.GetArg(1), e.GetArg(2), e.GetArg(3));
                                    if (res.success)
                                    {
                                        attack.Stars      = res.stars;
                                        attack.AttackType = res.attackType;
                                        attack.Damage     = res.damage;
                                        dc.SubmitChanges();
                                        await e.Channel.SendMessage("**ENTER RESULT** ```RESULT UPDATED: " + user.UserName + " actually hit #" + e.GetArg(0) + " for " + e.GetArg(1) + " stars and " + e.GetArg(3) + "% damage with " + e.GetArg(2) + ".```");
                                    }
                                    else
                                    {
                                        string failMessage = "invalid results for: ";
                                        if (res.stars == null)
                                        {
                                            failMessage += "stars";
                                        }
                                        if (res.attackType == null)
                                        {
                                            if (res.stars == null)
                                            {
                                                failMessage += ", ";
                                            }
                                            failMessage += "attack type";
                                        }
                                        if (res.damage == null)
                                        {
                                            if (res.attackType == null || res.stars == null)
                                            {
                                                failMessage += ", ";
                                            }
                                            failMessage += "damage";
                                        }
                                        await e.Channel.SendMessage("**ENTER RESULT** ```RESULT UPDATED FAILED: sorry " + user.UserName + " " + failMessage + ".```");
                                    }
                                }
                            }
                            // if no claim or attack found for specified base
                            else
                            {
                                await e.Channel.SendMessage("**ENTER RESULT** ```ENTER RESULT FAILED: sorry " + user.UserName + " you do not seem to have claimed or attacked that base.```");
                            }
                        }
                        // if user is not linked
                        else
                        {
                            await e.Channel.SendMessage("**ENTER RESULT** ```ENTER RESULT FAILED: account is not linked!```");
                        }
                    }
                    catch (Exception ex)
                    {
                        discord.Log.Error("RegisterDisplayWarInfoCommand", ex.Message);
                    }
                    #endregion
                });
            });
        }