workgroups/vendor/github.com/DisgoOrg/disgohook/disgohook.go
Marvin Preuss 1d4ae27878
All checks were successful
continuous-integration/drone/push Build is passing
ci: drone yaml with reusable anchors
2021-09-24 17:34:17 +02:00

25 lines
1.0 KiB
Go

package disgohook
import (
"net/http"
"strings"
"github.com/DisgoOrg/disgohook/api"
"github.com/DisgoOrg/disgohook/internal"
"github.com/DisgoOrg/log"
)
// NewWebhookClientByToken returns a new api.WebhookClient with the given http.Client, log.Logger & webhookID/webhookToken
func NewWebhookClientByToken(httpClient *http.Client, logger log.Logger, webhookToken string) (api.WebhookClient, error) {
webhookTokenSplit := strings.SplitN(webhookToken, "/", 2)
if len(webhookTokenSplit) != 2 {
return nil, api.ErrMalformedWebhookToken
}
return NewWebhookClientByIDToken(httpClient, logger, api.Snowflake(webhookTokenSplit[0]), webhookTokenSplit[1])
}
// NewWebhookClientByIDToken returns a new api.WebhookClient with the given http.Client, log.Logger, webhookID & webhookToken
func NewWebhookClientByIDToken(httpClient *http.Client, logger log.Logger, webhookID api.Snowflake, webhookToken string) (api.WebhookClient, error) {
return internal.NewWebhookClientImpl(httpClient, logger, webhookID, webhookToken), nil
}