mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-25 20:22:03 -08:00
Show error message when file upload fails (discord)
This commit is contained in:
parent
6f18790352
commit
7dbebd3ea7
@ -147,16 +147,18 @@ func (b *bdiscord) Send(msg config.Message) (string, error) {
|
|||||||
// check if we have files to upload (from slack, telegram or mattermost)
|
// check if we have files to upload (from slack, telegram or mattermost)
|
||||||
if len(msg.Extra["file"]) > 0 {
|
if len(msg.Extra["file"]) > 0 {
|
||||||
var err error
|
var err error
|
||||||
var res *discordgo.Message
|
|
||||||
for _, f := range msg.Extra["file"] {
|
for _, f := range msg.Extra["file"] {
|
||||||
fi := f.(config.FileInfo)
|
fi := f.(config.FileInfo)
|
||||||
files := []*discordgo.File{}
|
files := []*discordgo.File{}
|
||||||
files = append(files, &discordgo.File{fi.Name, "", bytes.NewReader(*fi.Data)})
|
files = append(files, &discordgo.File{fi.Name, "", bytes.NewReader(*fi.Data)})
|
||||||
res, err = b.c.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{Content: msg.Text, Files: files})
|
_, err = b.c.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{Content: msg.Text, Files: files})
|
||||||
}
|
if err != nil {
|
||||||
return res.ID, err
|
flog.Errorf("file upload failed: %#v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res, err := b.c.ChannelMessageSend(channelID, msg.Username+msg.Text)
|
res, err := b.c.ChannelMessageSend(channelID, msg.Username+msg.Text)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
Loading…
Reference in New Issue
Block a user