-
Notifications
You must be signed in to change notification settings - Fork 38
/
disgo.go
98 lines (90 loc) · 2.29 KB
/
disgo.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Package disgo is a collection of packages for interaction with the Discord Bot and OAuth2 API.
//
// # Discord
//
// Package discord is a collection of structs and types of the Discord API.
//
// # Bot
//
// Package bot connects the Gateway/Sharding, HTTPServer, Cache, Rest & Events packages into a single high level client interface.
//
// # Gateway
//
// Package gateway is used to connect and interact with the Discord Gateway.
//
// # Sharding
//
// Package sharding is used to connect and interact with the Discord Gateway.
//
// # Cache
//
// Package cache provides a generic cache interface for Discord entities.
//
// # HTTPServer
//
// Package httpserver is used to interact with the Discord outgoing webhooks for interactions.
//
// # Events
//
// Package events provide high level events around the Discord Events.
//
// # Rest
//
// Package rest is used to interact with the Discord REST API.
//
// # Webhook
//
// Package webhook provides a high level client interface for interacting with Discord webhooks.
//
// # OAuth2
//
// Package oauth2 provides a high level client interface for interacting with Discord oauth2.
//
// # Voice
//
// Package voice provides a high level client interface for interacting with Discord voice.
package disgo
import (
"runtime"
"runtime/debug"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/handlers"
)
const (
// Name is the library name
Name = "disgo"
// Module is the library module name
Module = "github.com/disgoorg/disgo"
// GitHub is a link to the libraries GitHub repository
GitHub = "https://github.com/disgoorg/disgo"
)
var (
// Version is the currently used version of DisGo
Version = getVersion()
SemVersion = "semver:" + Version
)
func getVersion() string {
bi, ok := debug.ReadBuildInfo()
if ok {
for _, dep := range bi.Deps {
if dep.Path == Module {
return dep.Version
}
}
}
return "unknown"
}
// New creates a new bot.Client with the provided token & bot.ConfigOpt(s)
func New(token string, opts ...bot.ConfigOpt) (bot.Client, error) {
config := bot.DefaultConfig(handlers.GetGatewayHandlers(), handlers.GetHTTPServerHandler())
config.Apply(opts)
return bot.BuildClient(token,
config,
handlers.DefaultGatewayEventHandlerFunc,
handlers.DefaultHTTPServerEventHandlerFunc,
runtime.GOOS,
Name,
GitHub,
Version,
)
}