Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nonce for interaction and message #1516

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package discordgo

import (
"net/http"
"runtime"
"time"

"github.com/gorilla/websocket"
Expand All @@ -26,9 +25,12 @@ const VERSION = "0.28.1"

// New creates a new Discord session with provided token.
// If the token is for a bot, it must be prefixed with "Bot "
// e.g. "Bot ..."
//
// e.g. "Bot ..."
//
// Or if it is an OAuth2 token, it must be prefixed with "Bearer "
// e.g. "Bearer ..."
//
// e.g. "Bearer ..."
func New(token string) (s *Session, err error) {

// Create an empty Session interface.
Expand All @@ -45,17 +47,19 @@ func New(token string) (s *Session, err error) {
MaxRestRetries: 3,
Client: &http.Client{Timeout: (20 * time.Second)},
Dialer: websocket.DefaultDialer,
UserAgent: "DiscordBot (https://github.com/bwmarrin/discordgo, v" + VERSION + ")",
sequence: new(int64),
LastHeartbeatAck: time.Now().UTC(),
//UserAgent: "DiscordBot (https://github.com/bwmarrin/discordgo, v" + VERSION + ")"
UserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
sequence: new(int64),
LastHeartbeatAck: time.Now().UTC(),
}

// Initialize the Identify Package with defaults
// These can be modified prior to calling Open()
s.Identify.Compress = true
s.Identify.LargeThreshold = 250
s.Identify.Properties.OS = runtime.GOOS
s.Identify.Properties.Browser = "DiscordGo v" + VERSION
//s.Identify.Properties.OS = runtime.GOOS
s.Identify.Properties.OS = "Mac OS X"
s.Identify.Properties.Browser = "Chrome"
s.Identify.Intents = IntentsAllWithoutPrivileged
s.Identify.Token = token
s.Token = token
Expand Down
51 changes: 51 additions & 0 deletions examples/voice_receive/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,58 @@
module github.com/bwmarrin/discordgo/examples/voice_receive

go 1.22.2

require (
github.com/bwmarrin/discordgo v0.21.1
github.com/pion/rtp v1.6.0
github.com/pion/webrtc/v3 v3.0.0-20200721060053-ca3cc9d940bc
)

require (
github.com/cheekybits/genny v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/golang/mock v1.2.0 // indirect
github.com/golang/protobuf v1.2.0 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gorilla/websocket v1.4.0 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/kr/pty v1.1.1 // indirect
github.com/kr/text v0.1.0 // indirect
github.com/lucas-clemente/quic-go v0.7.1-0.20190401152353-907071221cf9 // indirect
github.com/marten-seemann/qtls v0.2.3 // indirect
github.com/onsi/ginkgo v1.7.0 // indirect
github.com/onsi/gomega v1.4.3 // indirect
github.com/pion/datachannel v1.4.19 // indirect
github.com/pion/dtls/v2 v2.0.2 // indirect
github.com/pion/ice/v2 v2.0.0-rc.8 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/mdns v0.0.4 // indirect
github.com/pion/quic v0.1.1 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/rtcp v1.2.3 // indirect
github.com/pion/sctp v1.7.8 // indirect
github.com/pion/sdp/v2 v2.4.0 // indirect
github.com/pion/srtp v1.5.0 // indirect
github.com/pion/stun v0.3.5 // indirect
github.com/pion/transport v0.10.1 // indirect
github.com/pion/turn/v2 v2.0.4 // indirect
github.com/pion/udp v0.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sclevine/agouti v3.0.0+incompatible // indirect
github.com/stretchr/objx v0.1.0 // indirect
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect
golang.org/x/text v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
2 changes: 2 additions & 0 deletions interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ type Interaction struct {

Token string `json:"token"`
Version int `json:"version"`

Nonce string `json:"nonce"`
}

type interaction Interaction
Expand Down
2 changes: 2 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ type Message struct {

// An array of StickerItem objects, representing sent stickers, if there were any.
StickerItems []*StickerItem `json:"sticker_items"`

Nonce string `json:"nonce"`
}

// UnmarshalJSON is a helper function to unmarshal the Message.
Expand Down