Start with discord integration
This commit is contained in:
39
pkg/discord/client.go
Normal file
39
pkg/discord/client.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package discord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
type ChannelInfo struct{}
|
||||
|
||||
type DiscordClient struct {
|
||||
client *http.Client
|
||||
defaultChannel string
|
||||
baseUrl string
|
||||
apiVersion string
|
||||
}
|
||||
|
||||
func NewClient(ctx context.Context, tokenSrc oauth2.TokenSource) DiscordClient {
|
||||
return DiscordClient{
|
||||
client: oauth2.NewClient(ctx, tokenSrc),
|
||||
baseUrl: "https://discord.com",
|
||||
apiVersion: "v10",
|
||||
}
|
||||
}
|
||||
|
||||
func (dc DiscordClient) WithDefaultChannel(channelID string) DiscordClient {
|
||||
dc.defaultChannel = channelID
|
||||
return dc
|
||||
}
|
||||
|
||||
func (dc DiscordClient) GetChannel() ChannelInfo {
|
||||
return ChannelInfo{}
|
||||
}
|
||||
|
||||
func (dc DiscordClient) doRequest(path string, method string, body io.Reader) (*http.Response, error) {
|
||||
return dc.client.Do(method, path, body)
|
||||
}
|
||||
Reference in New Issue
Block a user