Esempio n. 1
0
 private void LeaveQueue()
 {
     commands.CreateCommand("LeaveQueue")
     .Do(async(e) =>
     {
         string reaction           = "";
         SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());
         ServerRepo serverRepo     = new ServerRepo(new ServerContext());
         if (serverRepo.IsServerVerified(e.Server.Id) && settingsRepo.lfgStatus(e.Server.Id))
         {
             try
             {
                 trigger.LeaveQueue(e.User);
                 reaction = "You have left queue.";
             }
             catch
             {
                 reaction = "Could not find you in the queue.";
             }
         }
         else
         {
         }
         await e.Channel.SendMessage(reaction);
     });
 }
 public void ChannelSettings()
 {
     commands.CreateCommand("LFGChannel")
     .Parameter("CommandType")
     .Parameter("Channel", ParameterType.Optional)
     .Do(async(e) =>
     {
         string returnstring       = "";
         SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());
         ServerRepo serverRepo     = new ServerRepo(new ServerContext());
         if (serverRepo.IsServerVerified(e.Server.Id) && serverRepo.IsAdmin(e.User.Id, e.Server.Id))
         {
             if (e.GetArg("CommandType").ToLower() == "set")
             {
                 try
                 {
                     settingsRepo.SetLfgChannel(e.Message.MentionedChannels.First().Id, e.Server.Id);
                     returnstring = "Looking for group channel has been set.";
                 }
                 catch
                 {
                     returnstring = "Failed to set a channel, have you tagged a channel?";
                 }
             }
             else if (e.GetArg("CommandType").ToLower() == "disable")
             {
                 settingsRepo.DisableLfg(e.Server.Id);
                 returnstring = "Looking for group has been disabled.";
             }
         }
         else
         {
             returnstring = Eng_Default.ServerIsNotVerified();
         }
         await e.Channel.SendMessage(returnstring);
     });
 }
Esempio n. 3
0
 public void UniversalRole()
 {
     commands.CreateCommand("Roles")
     .Parameter("Parameter", ParameterType.Unparsed)
     .Do(async(e) =>
     {
         string returnstring;
         ServerRepo serverRepo     = new ServerRepo(new ServerContext());
         SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());
         if (serverRepo.IsServerVerified(e.Server.Id))
         {
             try
             {
                 Discord.Role r = RoleSearch(e.Server, e.GetArg("Parameter").ToLower());
                 if (!settingsRepo.IsRoleDisabled(r.Name.ToLower(), e.Server.Id))
                 {
                     await e.User.AddRoles(r);
                     returnstring = Eng_Default.RoleHasBeenGiven(r.Name);
                 }
                 else
                 {
                     returnstring = Eng_Default.RoleHasBeenDisabled();
                 }
             }
             catch
             {
                 returnstring = Eng_Default.RoleNotFound(e.GetArg("Parameter"));
             }
         }
         else
         {
             returnstring = Eng_Default.ServerIsNotVerified();
         }
         await e.Channel.SendMessage(returnstring);
     });
 }
Esempio n. 4
0
        public void Update()
        {
            commands.CreateCommand("Update")
            .Do(async(e) =>
            {
                RankCommands rankCommands = new RankCommands(BotUser, commands);
                string returnstring       = "";
                ServerRepo serverRepo     = new ServerRepo(new ServerContext());
                UserRepo userRepo         = new UserRepo(new UserContext());
                RoleManagementTrigger rmt = new RoleManagementTrigger(BotUser, commands);

                /*
                 * if (userRepo.IsAtlasAdmin(e.User.Id))
                 * {
                 *  foreach (Discord.Server server in BotUser.Servers)
                 *  {
                 *      if (serverRepo.IsServerVerified(server.Id))
                 *      {
                 *          foreach (Discord.User user in server.Users)
                 *          {
                 *
                 *              try
                 *              {
                 *                  await Task.Run(() => rmt.RemoveRoles(server, user));
                 *                  await Task.Run(() => rankCommands.GetRankRoles(server, user));
                 *              }
                 *              catch
                 *              {
                 *
                 *              }
                 *
                 *          }
                 *      }
                 *  }
                 *  returnstring = "System update complete.";
                 * }
                 *
                 * else*/if (new ServerRepo(new ServerContext()).IsAdmin(e.User.Id, e.Server.Id))
                {
                    if ((serverRepo.GetLastupdateDateServer(e.Server.Id) < DateTime.Today) && serverRepo.IsServerVerified(e.Server.Id))
                    {
                        foreach (Discord.User user in e.Server.Users)
                        {
                            try
                            {
                                await Task.Run(() => rmt.RemoveRoles(e.Server, user));
                                await Task.Run(() => rankCommands.GetRankRoles(e.Server, user));
                            }
                            catch
                            {
                                Console.WriteLine("Failed to give roles, account not registered.");
                            }
                        }
                        serverRepo.SetUpdateDateServer(e.Server.Id, DateTime.Today);
                        returnstring = "Server update successfull.";
                    }
                    else
                    {
                        returnstring = "Please wait for one day to update your server again.";
                    }
                }
                else
                {
                    if (userRepo.GetLastRefreshDate(e.User.Id) > DateTime.Today && serverRepo.IsServerVerified(e.Server.Id))
                    {
                        try
                        {
                            await Task.Run(() => rmt.RemoveRoles(e.Server, e.User));
                            await Task.Run(() => rankCommands.GetRankRoles(e.Server, e.User));
                        }
                        catch
                        {
                        }
                        userRepo.SetLastRefreshDate(e.User.Id, DateTime.Now);
                    }
                }
                await e.Channel.SendMessage(returnstring);
            });
        }
Esempio n. 5
0
 private void QueueUp()
 {
     commands.CreateCommand("QueueUp")
     .Alias("Queue")
     .Parameter("Queue", ParameterType.Unparsed)
     .Do(async(e) =>
     {
         string returnstring       = "";
         StringHandler SH          = new StringHandler(e.Server);
         SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());
         ServerRepo serverRepo     = new ServerRepo(new ServerContext());
         if (serverRepo.IsServerVerified(e.Server.Id) && settingsRepo.lfgStatus(e.Server.Id) || e.Server.Id == DiscordIds.AtlasId)
         {
             Summoner summoner = null;
             try
             {
                 DataLibary.Models.User user =
                     new UserRepo(new UserContext()).GetUserByDiscord(e.User.Id);
                 summoner =
                     new SummonerAPI().GetSummoner(
                         new SummonerRepo(new SummonerContext()).GetSummonerByUserId(user),
                         ToolKit.LeagueAndDatabase.GetRegionFromDatabaseId(
                             new RegionRepo(new RegionContext()).GetRegionId(user)
                             ));
             }
             catch
             {
                 returnstring = Eng_Default.RegisterAccount();
             }
             if (summoner != null)
             {
                 try
                 {
                     bool found   = false;
                     string queue = "";
                     foreach (string line in Queues.GetQueues())
                     {
                         if (e.GetArg("Queue").ToLower() == line)
                         {
                             found = true;
                             queue = line;
                         }
                     }
                     if (found == true)
                     {
                         trigger.QueuePerson(summoner, e.User, e.Server, queue);
                         returnstring = SH.Build("QUP1");
                         //returnstring = "You were queued!";
                     }
                     else
                     {
                         returnstring = "Please enter one of the following queues: ";
                         foreach (string line in Queues.GetQueues())
                         {
                             returnstring += "\n -" + line;
                         }
                     }
                 }
                 catch
                 {
                     returnstring = "You are already queued.";
                 }
             }
         }
         await e.Channel.SendMessage(returnstring);
     });
 }
Esempio n. 6
0
 public void AdminMastery()
 {
     commands.CreateCommand("ConfigMastery")
     .Parameter("CommandType")
     .Parameter("Parameter", ParameterType.Optional)
     .Parameter("Points", ParameterType.Optional)
     .Do(async(e) =>
     {
         string returnstring       = "";
         SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());
         ServerRepo serverRepo     = new ServerRepo(new ServerContext());
         if (serverRepo.IsServerVerified(e.Server.Id) && serverRepo.IsAdmin(e.User.Id, e.Server.Id))
         {
             if (e.GetArg("CommandType") == "?" || e.GetArg("CommandType").ToLower() == "help")
             {
                 returnstring =
                     "**This command can be used to configure the Mastery Point system on your server.**" +
                     "\nUse *-ConfigMastery champion <champion>* to set a champion for your server:" +
                     "\nExample: -ConfigMastery champion Thresh" +
                     "\n\nUse *-ConfigMastery list* to get a list of all the roles you have set up." +
                     "\n\nUse *-ConfigMastery add <RoleName> <Amount>* to add a rank to the system:" +
                     "\nExample: -ConfigMastery add \"1 Million\" 1000000" +
                     "\n\nUse *-ConfigMastery remove <Points>* to remove a milestone rank:" +
                     "\nExample: -ConfigMastery remove 1000000";
             }
             else if (e.GetArg("CommandType").ToLower() == "champion")
             {
                 try
                 {
                     settingsRepo.SetChampionId(e.Server.Id, new ChampionAPI().GetChampionId(e.GetArg("Parameter").ToString()));
                     returnstring = "Champion set to " + e.GetArg("Parameter");
                 }
                 catch
                 {
                     returnstring = "Did not find champion called " + e.GetArg("Parameter");
                 }
             }
             else if (e.GetArg("CommandType").ToLower() == "list")
             {
                 try
                 {
                     returnstring = "Server looks at mastery points for " +
                                    new ChampionAPI().GetChampionName(
                         settingsRepo.GetChampionId(e.Server.Id));
                     returnstring += "\nRoles for this server: ```";
                     foreach (string line in settingsRepo.GetAllMasteryRoles(e.Server.Id))
                     {
                         returnstring += "\n" + line.Split(':').First() + " points uses role: " +
                                         e.Server.GetRole(Convert.ToUInt64(line.Split(':').Last())).Name;
                     }
                     returnstring += "\n```";
                 }
                 catch
                 {
                     returnstring = "No champion or role found, please set this up first!";
                 }
             }
             else if (e.GetArg("CommandType").ToLower() == "add")
             {
                 try
                 {
                     Discord.Role r = e.Server.FindRoles(e.GetArg("Parameter"), false).First();
                     settingsRepo.SetRoleByPoints(r.Id, e.Server.Id, Convert.ToInt32(e.GetArg("Points")));
                     returnstring = "Added to the list!";
                 }
                 catch
                 {
                     returnstring = "Failed to add, role not found.";
                 }
             }
             else if (e.GetArg("CommandType").ToLower() == "remove")
             {
                 try
                 {
                     settingsRepo.RemoveRoleByPoints(e.Server.Id, Convert.ToInt32(e.GetArg("Parameter")));
                     returnstring = "Removed the role with the points " + e.GetArg("Parameter");
                 }
                 catch
                 {
                     returnstring = "Failed to remove the role with points " + e.GetArg("Parameter");
                 }
             }
         }
         await e.Channel.SendMessage(returnstring);
     });
 }
Esempio n. 7
0
 public void CreateRank()
 {
     commands.CreateCommand("CreateRoles")
     .Do(async(e) =>
     {
         SettingsRepo settingsRepo = new SettingsRepo(new SettingsContext());
         ServerRepo serverRepo     = new ServerRepo(new ServerContext());
         if (serverRepo.IsServerVerified(e.Server.Id))
         {
             if (settingsRepo.RankByAccount(e.Server.Id) || settingsRepo.RankByParameter(e.Server.Id))
             {
                 if (settingsRepo.RankCommandType(e.Server.Id) == CommandType.Basic)
                 {
                     try
                     {
                         await e.Server.CreateRole("Challenger", null, Color.Purple);
                         await e.Server.CreateRole("Master", null, new Color(255, 165, 0));
                         await e.Server.CreateRole("Diamond", null, new Color(0, 191, 255));
                         await e.Server.CreateRole("Platinum", null, new Color(0, 255, 127));
                         await e.Server.CreateRole("Gold", null, Color.Gold);
                         await e.Server.CreateRole("Silver", null, Color.LightGrey);
                         await e.Server.CreateRole("Bronze", null, new Color(139, 69, 19));
                     }
                     catch
                     {
                     }
                 }
                 else if (settingsRepo.RankCommandType(e.Server.Id) == CommandType.PerQueue)
                 {
                     await e.Server.CreateRole("Solo Challenger", null, Color.Purple);
                     await e.Server.CreateRole("Flex Challenger", null, Color.Purple);
                     await e.Server.CreateRole("3v3 Challenger", null, Color.Purple);
                     await e.Server.CreateRole("Solo Master", null, new Color(255, 165, 0));
                     await e.Server.CreateRole("Flex Master", null, new Color(255, 165, 0));
                     await e.Server.CreateRole("3v3 Master", null, new Color(255, 165, 0));
                     await e.Server.CreateRole("Solo Diamond", null, new Color(0, 191, 255));
                     await e.Server.CreateRole("Flex Diamond", null, new Color(0, 191, 255));
                     await e.Server.CreateRole("3v3 Diamond", null, new Color(0, 191, 255));
                     await e.Server.CreateRole("Solo Platinum", null, new Color(0, 255, 127));
                     await e.Server.CreateRole("Flex Platinum", null, new Color(0, 255, 127));
                     await e.Server.CreateRole("3v3 Platinum", null, new Color(0, 255, 127));
                     await e.Server.CreateRole("Solo Gold", null, Color.Gold);
                     await e.Server.CreateRole("Flex Gold", null, Color.Gold);
                     await e.Server.CreateRole("3v3 Gold", null, Color.Gold);
                     await e.Server.CreateRole("Solo Silver", null, Color.LightGrey);
                     await e.Server.CreateRole("Flex Silver", null, Color.LightGrey);
                     await e.Server.CreateRole("3v3 Silver", null, Color.LightGrey);
                     await e.Server.CreateRole("Solo Bronze", null, new Color(139, 69, 19));
                     await e.Server.CreateRole("Flex Bronze", null, new Color(139, 69, 19));
                     await e.Server.CreateRole("3v3 Bronze", null, new Color(139, 69, 19));
                 }
             }
             if (settingsRepo.RegionByAccount(e.Server.Id) || settingsRepo.RegionByParameter(e.Server.Id))
             {
                 foreach (string line in new RegionRepo(new RegionContext()).GetAllRegions())
                 {
                     try
                     {
                         Role r      = e.Server.FindRoles(line).First();
                         string test = r.Name;
                     }
                     catch
                     {
                         try
                         {
                             await e.Server.CreateRole(line);
                         }
                         catch
                         {
                             //ignored
                         }
                     }
                 }
             }
             await e.Channel.SendMessage("Roles created");
         }
     });
 }