forked from LuminalDev/dgate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdgate_test.go
50 lines (41 loc) · 1.01 KB
/
dgate_test.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
package selfcord
import (
"fmt"
"github.com/QuartzWarrior/discordgo-self/types"
"os"
"testing"
"time"
)
func handleErr(err error) {
if err != nil {
panic(err)
}
}
func Test_Close(t *testing.T) {
token, err := os.ReadFile("test_token")
handleErr(err)
client := NewClient(string(token), &types.DefaultConfig)
client.AddHandler(types.GatewayEventReady, func(e *types.ReadyEventData) {
fmt.Printf("%#v", e)
})
go func() {
handleErr(client.Connect())
}()
time.Sleep(10 * time.Second)
client.Close()
}
func Test_Main(t *testing.T) {
token, err := os.ReadFile("test_token")
handleErr(err)
client := NewClient(string(token), &types.DefaultConfig)
client.AddHandler(types.GatewayEventReady, func(e *types.ReadyEventData) {
fmt.Printf("%#v\n", e)
})
client.AddHandler(types.GatewayEventMessageCreate, func(e *types.MessageEventData) {
fmt.Printf("%#v\n", e)
})
client.AddHandler(types.GatewayEventMessageUpdate, func(e *types.MessageEventData) {
fmt.Printf("%#v\n", e)
})
handleErr(client.Connect())
}