From 839f384e45ce518e3ed67a9f51b4593b28c1a79b Mon Sep 17 00:00:00 2001 From: Joseph Mansy <36427684+yousefmansy1@users.noreply.github.com> Date: Tue, 14 Mar 2023 15:16:22 -0700 Subject: Return a message ID when sending with a webhook (discord) (#1976) Resolves #1975 --- bridge/discord/webhook.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bridge/discord/webhook.go b/bridge/discord/webhook.go index c34fc945..b518ea62 100644 --- a/bridge/discord/webhook.go +++ b/bridge/discord/webhook.go @@ -47,8 +47,9 @@ func (b *Bdiscord) maybeGetLocalAvatar(msg *config.Message) string { // Returns messageID and error. func (b *Bdiscord) webhookSend(msg *config.Message, channelID string) (*discordgo.Message, error) { var ( - res *discordgo.Message - err error + res *discordgo.Message + res2 *discordgo.Message + err error ) // If avatar is unset, mutate the message to include the local avatar (but only if settings say we should do this) @@ -84,7 +85,7 @@ func (b *Bdiscord) webhookSend(msg *config.Message, channelID string) (*discordg } content := fi.Comment - _, e2 := b.transmitter.Send( + res2, err = b.transmitter.Send( channelID, &discordgo.WebhookParams{ Username: msg.Username, @@ -94,11 +95,16 @@ func (b *Bdiscord) webhookSend(msg *config.Message, channelID string) (*discordg AllowedMentions: b.getAllowedMentions(), }, ) - if e2 != nil { - b.Log.Errorf("Could not send file %#v for message %#v: %s", file, msg, e2) + if err != nil { + b.Log.Errorf("Could not send file %#v for message %#v: %s", file, msg, err) } } } + + if msg.Text == "" { + res = res2 + } + return res, err } -- cgit v1.2.3