Skip to content

Commit 0d06764

Browse files
committed
Update go deps
Don't touch node ones, because it's so outdated, it won't build well
1 parent 7d0b7d7 commit 0d06764

9 files changed

+7889
-5041
lines changed

discord.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
"net/url"
99
)
1010

11-
const userInfoEndpoint string = "https://discord.com/api/users/"
11+
const DiscordEndpoint = "https://discord.com/api/oauth2/token"
12+
const userInfoEndpoint string = "https://discord.com/api/v10/users/"
13+
const UserAgent string = "DiscordBot (https://github.com/MinecraftHopper, v0)"
1214

1315
var NoDiscordUser = errors.New("no discord user")
1416

@@ -50,14 +52,14 @@ func redeemCode(code string) (string, error) {
5052
}
5153

5254
func getUserId(accessToken string) (string, error) {
53-
url, err := url.Parse(userInfoEndpoint + "@me")
55+
u, err := url.Parse(userInfoEndpoint + "@me")
5456
if err != nil {
5557
return "", err
5658
}
5759

5860
request := &http.Request{
59-
URL: url,
60-
Header: map[string][]string{"Authorization": {"Bearer " + accessToken}},
61+
URL: u,
62+
Header: map[string][]string{"Authorization": {"Bearer " + accessToken}, "User-Agent": {UserAgent}},
6163
}
6264

6365
response, err := HttpClient.Do(request)
@@ -81,14 +83,14 @@ func getUserId(accessToken string) (string, error) {
8183
func getUser(id string) (DiscordUser, error) {
8284
var botToken = env.Get("discord.clientbot")
8385

84-
url, err := url.Parse(userInfoEndpoint + id)
86+
u, err := url.Parse(userInfoEndpoint + id)
8587
if err != nil {
8688
return DiscordUser{}, err
8789
}
8890

8991
request := &http.Request{
90-
URL: url,
91-
Header: map[string][]string{"Authorization": {"Bot " + botToken}},
92+
URL: u,
93+
Header: map[string][]string{"Authorization": {"Bot " + botToken}, "User-Agent": {UserAgent}},
9294
}
9395

9496
response, err := HttpClient.Do(request)

env/env.go

-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package env
22

33
import (
4-
"github.com/spf13/cast"
54
"github.com/spf13/viper"
65
"io"
76
"log"
@@ -35,42 +34,6 @@ func Get(key string) string {
3534
return val
3635
}
3736

38-
func Set(key string, val string) {
39-
cache[key] = val
40-
}
41-
42-
func GetOr(key string, def string) string {
43-
res := Get(key)
44-
if res == "" {
45-
return def
46-
}
47-
return res
48-
}
49-
50-
func GetBool(key string) bool {
51-
return cast.ToBool(Get(key))
52-
}
53-
54-
func GetBoolOr(key string, def bool) bool {
55-
res := Get(key)
56-
if res == "" {
57-
return def
58-
}
59-
return cast.ToBool(res)
60-
}
61-
62-
func GetInt(key string) int {
63-
return cast.ToInt(Get(key))
64-
}
65-
66-
func GetStringArray(key, separator string) []string {
67-
val := Get(key)
68-
if separator == "" {
69-
separator = ","
70-
}
71-
return strings.Split(val, separator)
72-
}
73-
7437
func readSecret(file string) (string, error) {
7538
f, err := os.Open(file)
7639
if err != nil {

go.mod

+43-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,51 @@
11
module github.com/MinecraftHopper/panel
22

3-
go 1.15
3+
go 1.19
44

55
require (
6-
github.com/gin-contrib/gzip v0.0.3
7-
github.com/gin-contrib/sessions v0.0.3
8-
github.com/gin-gonic/gin v1.6.3
9-
github.com/go-playground/validator/v10 v10.4.1 // indirect
10-
github.com/golang/protobuf v1.4.3 // indirect
11-
github.com/google/uuid v1.2.0
6+
github.com/gin-contrib/gzip v0.0.6
7+
github.com/gin-contrib/sessions v0.0.5
8+
github.com/gin-gonic/gin v1.8.2
9+
github.com/google/uuid v1.3.0
10+
github.com/spf13/cast v1.5.0
11+
github.com/spf13/viper v1.15.0
12+
gorm.io/driver/mysql v1.4.7
13+
gorm.io/gorm v1.24.5
14+
)
15+
16+
require (
17+
github.com/fsnotify/fsnotify v1.6.0 // indirect
18+
github.com/gin-contrib/sse v0.1.0 // indirect
19+
github.com/go-playground/locales v0.14.0 // indirect
20+
github.com/go-playground/universal-translator v0.18.0 // indirect
21+
github.com/go-playground/validator/v10 v10.11.1 // indirect
22+
github.com/go-sql-driver/mysql v1.7.0 // indirect
23+
github.com/goccy/go-json v0.9.11 // indirect
24+
github.com/gorilla/context v1.1.1 // indirect
25+
github.com/gorilla/securecookie v1.1.1 // indirect
1226
github.com/gorilla/sessions v1.2.1 // indirect
13-
github.com/json-iterator/go v1.1.10 // indirect
27+
github.com/hashicorp/hcl v1.0.0 // indirect
28+
github.com/jinzhu/inflection v1.0.0 // indirect
29+
github.com/jinzhu/now v1.1.5 // indirect
30+
github.com/json-iterator/go v1.1.12 // indirect
1431
github.com/leodido/go-urn v1.2.1 // indirect
15-
github.com/spf13/cast v1.5.0 // indirect
16-
github.com/spf13/viper v1.7.1
17-
github.com/ugorji/go v1.2.2 // indirect
18-
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
19-
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect
20-
google.golang.org/protobuf v1.25.0 // indirect
32+
github.com/magiconair/properties v1.8.7 // indirect
33+
github.com/mattn/go-isatty v0.0.16 // indirect
34+
github.com/mitchellh/mapstructure v1.5.0 // indirect
35+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
36+
github.com/modern-go/reflect2 v1.0.2 // indirect
37+
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
38+
github.com/spf13/afero v1.9.3 // indirect
39+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
40+
github.com/spf13/pflag v1.0.5 // indirect
41+
github.com/subosito/gotenv v1.4.2 // indirect
42+
github.com/ugorji/go/codec v1.2.7 // indirect
43+
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
44+
golang.org/x/net v0.4.0 // indirect
45+
golang.org/x/sys v0.3.0 // indirect
46+
golang.org/x/text v0.5.0 // indirect
47+
google.golang.org/protobuf v1.28.1 // indirect
48+
gopkg.in/ini.v1 v1.67.0 // indirect
2149
gopkg.in/yaml.v2 v2.4.0 // indirect
22-
gorm.io/driver/mysql v1.0.3
23-
gorm.io/gorm v1.20.9
50+
gopkg.in/yaml.v3 v3.0.1 // indirect
2451
)

0 commit comments

Comments
 (0)