Skip to content

Commit

Permalink
udpated go to 1.16, fixed testbot & nil exception
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Mar 28, 2021
1 parent ce84355 commit 2505ff5
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16

- name: Build
run: go build -v ./...
Expand Down
25 changes: 0 additions & 25 deletions api/application_command.go → api/slash_command.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
package api

import (
"bytes"
"encoding/json"
)

// SlashCommands is a slice of SlashCommand
type SlashCommands []SlashCommand

// MarshalJSON is used for marshalling multiple commands into a []byte
func (commands SlashCommands) MarshalJSON() ([]byte, error) {
buffer := bytes.NewBufferString("[")
for i, command := range commands {
commandBytes, err := json.Marshal(command)
if err != nil {
return nil, err
}
buffer.Write(commandBytes)
if i < len(commands) {
buffer.WriteString(",")
}
}
buffer.WriteString("]")
return buffer.Bytes(), nil
}

// SlashCommand is the base "command" model that belongs to an application.
type SlashCommand struct {
ID Snowflake `json:"id,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module github.com/DisgoOrg/disgo

go 1.15
go 1.16

require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
3 changes: 3 additions & 0 deletions internal/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ func (g *GatewayImpl) heartbeat() {

// Close cleans up the gateway internals
func (g *GatewayImpl) Close() {
if g.quit == nil {
return
}
log.Info("closing gateway goroutines...")
close(g.quit)
log.Info("closed gateway goroutines")
Expand Down
2 changes: 1 addition & 1 deletion internal/restclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (r RestClientImpl) SetGlobalCommands(applicationID api.Snowflake, commands
err = api.ErrTooMuchApplicationCommands
return
}
return rCommands, r.Request(endpoints.SetGlobalCommands.Compile(applicationID), api.SlashCommands(commands), &rCommands)
return rCommands, r.Request(endpoints.SetGlobalCommands.Compile(applicationID), commands, &rCommands)
}

// GetGlobalCommand gets you a specific global global command
Expand Down
6 changes: 2 additions & 4 deletions testbot/testbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ func main() {
token := os.Getenv("token")
publicKey := os.Getenv("public-key")

log.Print(publicKey)

dgo, err := disgo.NewBuilder(token).
SetLogLevel(log.InfoLevel).
SetIntents(api.IntentsGuilds|api.IntentsGuildMessages|api.IntentsGuildMembers).
Expand All @@ -35,7 +33,7 @@ func main() {
return
}

/*_, err = dgo.RestClient().SetGuildCommands(dgo.ApplicationID(), "817327181659111454",
_, err = dgo.RestClient().SetGuildCommands(dgo.ApplicationID(), "817327181659111454",
api.SlashCommand{
Name: "test",
Description: "test test test test test test",
Expand Down Expand Up @@ -91,7 +89,7 @@ func main() {
)
if err != nil {
log.Errorf("error while registering guild commands: %s", err)
}*/
}

err = dgo.Start()
if err != nil {
Expand Down

0 comments on commit 2505ff5

Please sign in to comment.