-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.go
83 lines (73 loc) · 1.95 KB
/
client.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package guildedgo
import (
"net/http"
"os"
"sync"
"github.com/gorilla/websocket"
)
const (
guildedApi = "https://www.guilded.gg/api/v1"
)
type Client struct {
sync.RWMutex
wsMutex sync.Mutex
Token string
ServerID string
client *http.Client
conn *websocket.Conn
interrupt chan os.Signal
listening chan struct{}
Channel ChannelService
Members MembersService
Roles RoleService
Server ServerService
Forums ForumService
Calendar CalendarService
Reactions ReactionService
List ListService
Webhooks WebhookService
ServerXP ServerXPService
CommandService CommandService
DocComments DocCommentService
Docs DocsService
Socials SocialsService
Announcements AnnouncementService
Category CategoryService
Users UserService
events map[string][]Event
commands map[string]Command
}
type Event struct {
Callback func(*Client, any)
Type *interface{}
}
type Config struct {
Token string
ServerID string
}
func NewClient(config *Config) *Client {
c := &Client{
Token: config.Token,
ServerID: config.ServerID,
client: http.DefaultClient,
}
c.Channel = &channelService{client: c}
c.Members = &membersService{client: c}
c.Roles = &roleService{client: c}
c.Server = &serverService{client: c}
c.Forums = &forumService{client: c}
c.Calendar = &calendarService{client: c}
c.Reactions = &reactionService{client: c}
c.CommandService = &commandService{client: c}
c.List = &listService{client: c}
c.Webhooks = &webhookService{client: c}
c.ServerXP = &serverXPService{client: c}
c.Docs = &docsService{client: c}
c.DocComments = &docCommentService{client: c}
c.Socials = &socialsService{client: c}
c.Announcements = &announcementService{client: c}
c.Users = &userService{client: c}
c.Category = &categoryService{client: c}
c.events = make(map[string][]Event)
return c
}