Skip to content

Commit

Permalink
Return a message ID when sending with a webhook (discord) (#1976)
Browse files Browse the repository at this point in the history
Resolves #1975
  • Loading branch information
yousefmansy1 authored Mar 14, 2023
1 parent d422779 commit 839f384
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bridge/discord/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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
}

Expand Down

0 comments on commit 839f384

Please sign in to comment.