forked from andersfylling/disgord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
struct_webhook.go
48 lines (39 loc) · 1.12 KB
/
struct_webhook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package disgord
import "sync"
// Webhook Used to represent a webhook
// https://discordapp.com/developers/docs/resources/webhook#webhook-object
type Webhook struct {
sync.RWMutex `json:"-"`
ID Snowflake `json:"id"` // |
GuildID Snowflake `json:"guild_id,omitempty"` // |?
ChannelID Snowflake `json:"channel_id"` // |
User *User `json:"user,omitempty"` // ?|
Name string `json:"name"` // |?
Avatar string `json:"avatar"` // |?
Token string `json:"token"` // |
}
func (w *Webhook) DeepCopy() (copy interface{}) {
copy = &Webhook{}
w.CopyOverTo(copy)
return
}
func (w *Webhook) CopyOverTo(other interface{}) (err error) {
var ok bool
var hook *Webhook
if hook, ok = other.(*Webhook); !ok {
err = NewErrorUnsupportedType("given interface{} was not of type *Webhook")
return
}
w.RLock()
hook.Lock()
hook.ID = w.ID
hook.GuildID = w.GuildID
hook.ChannelID = w.ChannelID
hook.User = w.User.DeepCopy().(*User)
hook.Name = w.Name
hook.Avatar = w.Avatar
hook.Token = w.Token
w.RUnlock()
hook.Unlock()
return
}