40 lines
798 B
Go
40 lines
798 B
Go
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)
|
|
}
|