mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 09:37:44 +00:00
Add support for sending files via webhook (discord) (#872)
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package bdiscord
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"regexp"
|
||||
"strings"
|
||||
@ -236,26 +235,3 @@ func enumerateUsernames(s string) []string {
|
||||
}
|
||||
return usernames
|
||||
}
|
||||
|
||||
// webhookExecute executes a webhook.
|
||||
// webhookID: The ID of a webhook.
|
||||
// token : The auth token for the webhook
|
||||
// wait : Waits for server confirmation of message send and ensures that the return struct is populated (it is nil otherwise)
|
||||
func (b *Bdiscord) webhookExecute(webhookID, token string, wait bool, data *discordgo.WebhookParams) (st *discordgo.Message, err error) {
|
||||
uri := discordgo.EndpointWebhookToken(webhookID, token)
|
||||
|
||||
if wait {
|
||||
uri += "?wait=true"
|
||||
}
|
||||
response, err := b.c.RequestWithBucketID("POST", uri, data, discordgo.EndpointWebhookToken("", ""))
|
||||
if !wait || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(response, &st)
|
||||
if err != nil {
|
||||
return nil, discordgo.ErrJSONUnmarshal
|
||||
}
|
||||
|
||||
return st, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user