Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
make nonce interface{}
Browse files Browse the repository at this point in the history
  • Loading branch information
andersfylling committed Oct 25, 2019
1 parent fd87582 commit 3972ff3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,15 @@ func (c *Channel) SendMsg(client MessageSender, message *Message) (msg *Message,
err = newErrorMissingSnowflake("snowflake ID not set for channel")
return
}
nonce := fmt.Sprint(message.Nonce)
if len(nonce) > 25 {
return nil, errors.New("nonce can not be longer than 25 characters")
}

message.RLock()
params := &CreateMessageParams{
Content: message.Content,
Nonce: message.Nonce, // THIS IS A STRING. NOT A SNOWFLAKE! DONT TOUCH!
Nonce: nonce, // THIS IS A STRING. NOT A SNOWFLAKE! DONT TOUCH!
Tts: message.Tts,
// File: ...
// Embed: ...
Expand Down
2 changes: 1 addition & 1 deletion iface_reseter_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/constant/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package constant

const Version = "v0.13.0"
const Version = "v0.14.0"
9 changes: 7 additions & 2 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type Message struct {
Attachments []*Attachment `json:"attachments"`
Embeds []*Embed `json:"embeds"`
Reactions []*Reaction `json:"reactions"` // ?
Nonce string `json:"nonce"` // THIS IS A STRING. NOT A SNOWFLAKE! DONT TOUCH!
Nonce interface{} `json:"nonce"` // NOT A SNOWFLAKE! DONT TOUCH!
Pinned bool `json:"pinned"`
WebhookID Snowflake `json:"webhook_id"` // ?
Type MessageType `json:"type"`
Expand Down Expand Up @@ -312,11 +312,16 @@ func (m *Message) Send(client MessageSender, flags ...Flag) (msg *Message, err e
if constant.LockedMethods {
m.RLock()
}
nonce := fmt.Sprint(m.Nonce)
if len(nonce) > 25 {
return nil, errors.New("nonce can not be more than 25 characters")
}

// TODO: attachments
params := &CreateMessageParams{
Content: m.Content,
Tts: m.Tts,
Nonce: m.Nonce,
Nonce: nonce,
// File: ...
// Embed: ...
}
Expand Down

0 comments on commit 3972ff3

Please sign in to comment.