iperf3exporter/vendor/github.com/DisgoOrg/disgohook/disgohook.go
Marvin Preuss 2343c9588a
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
first commit
2021-10-20 10:08:56 +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
}