示例#1
0
 private void AddCoach()
 {
     commands.CreateCommand("AddCoach")
     .Parameter("User")
     .Parameter("Role", ParameterType.Optional)
     .Parameter("ChampionName", ParameterType.Unparsed)
     .Do(async(e) =>
     {
         string returnstring   = "";
         ServerRepo serverRepo = new ServerRepo(new ServerContext());
         CoachTrigger trigger  = new CoachTrigger();
         if (e.Server.Id == 302775478824075267 && serverRepo.IsAdmin(e.User.Id, e.Server.Id))
         {
             try
             {
                 trigger.AddCoach(e.Message.MentionedUsers.First().Id, e.GetArg("ChampionName"),
                                  e.GetArg("Role"));
                 returnstring = "Coach added successfully.";
             }
             catch
             {
                 returnstring = "Failed to add coach";
             }
         }
         else
         {
             returnstring = Eng_Default.NotAllowed();
         }
         await e.Channel.SendMessage(returnstring);
     });
 }
 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);
     });
 }
示例#3
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);
     });
 }