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); }); }