hello world

This commit is contained in:
2022-12-09 10:59:15 -06:00
commit 8ae527683b
13 changed files with 552 additions and 0 deletions

34
discord/get.go Normal file
View File

@@ -0,0 +1,34 @@
package discord
import (
"encoding/json"
"io"
"net/http"
)
func getDiscordUser(token string) User {
req, err := http.NewRequest("GET", "https://discord.com/api/v19/users/@me", nil)
if err != nil {
panic(err)
}
req.Header.Add("Authorization", "Bot "+token)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
respBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
var respObj = User{}
err = json.Unmarshal(respBody, &respObj)
if err != nil {
panic(err)
}
return respObj
}

19
discord/structs.go Normal file
View File

@@ -0,0 +1,19 @@
package discord
type User struct {
Id string `json:"id"`
Username string `json:"username"`
Discriminator string `json:"discriminator"`
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
System bool `json:"system"`
Mfa_enabled bool `json:"mfa_enabled"`
Banner string `json:"banner"`
Accent_color int `json:"accent_color"`
Locale string `json:"locale"`
Verified bool `json:"verified"`
Email string `json:"email"`
Flags int `json:"flags"`
Premium_type int `json:"premium_type"`
Public_flags int `json:"public_flags"`
}