diff --git a/site-api.go b/site-api.go index 32a27a3..885cd5a 100644 --- a/site-api.go +++ b/site-api.go @@ -179,6 +179,29 @@ func getVerifications(w http.ResponseWriter, r *http.Request) { } fmt.Fprintf(w, string(verifications)) } + +func getUser(w http.ResponseWriter, r *http.Request) { + loggedIn, _ := detectUser(r, "getVerifications") + if !loggedIn { + notFoundPage(w, r) + return + } + vars := mux.Vars(r) + username := vars["userID"] + if len(username) == 0 { + username = r.FormValue("userID") + } + m, err := dg.GuildMember(config.GuildID, username) + if err != nil { + log.LogErrorType(err) + } + ret, err := json.Marshal(m) + if err != nil { + log.LogErrorType(err) + } + fmt.Fprintf(w, string(ret)) +} + func runWeb() { defer log.PanicSafe() router := mux.NewRouter().StrictSlash(true) @@ -191,6 +214,7 @@ func runWeb() { router.HandleFunc("/api/verifications", getVerifications) router.HandleFunc("/api/probations", getProbations) router.HandleFunc("/api/passreq", reqPass) + router.HandleFunc("/api/user", getUser) router.HandleFunc("/", greetUser) router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static")))) log.LogInfo("Starting server")