diff options
author | David Hill <dhill@mindcry.org> | 2018-11-07 14:36:50 -0500 |
---|---|---|
committer | Wim <wim@42.be> | 2018-11-07 20:36:50 +0100 |
commit | 0e2522279e8671a345c1be6b8b07c0f1a505e23e (patch) | |
tree | 968ac4b1acd0352ae9962d6f71bfd7d9c668596f /bridge/discord/discord.go | |
parent | 141a42a75b47b0a05f5b360ff5711819d3727a75 (diff) | |
download | matterbridge-msglm-0e2522279e8671a345c1be6b8b07c0f1a505e23e.tar.gz matterbridge-msglm-0e2522279e8671a345c1be6b8b07c0f1a505e23e.tar.bz2 matterbridge-msglm-0e2522279e8671a345c1be6b8b07c0f1a505e23e.zip |
Clean up various stuff (#508)
* various cleanups
Diffstat (limited to 'bridge/discord/discord.go')
-rw-r--r-- | bridge/discord/discord.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index 116bf86d..0549187f 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -91,6 +91,7 @@ func (b *Bdiscord) Connect() error { } // obtaining guild members and initializing nickname mapping b.Lock() + defer b.Unlock() members, err := b.c.GuildMembers(b.guildID, "", 1000) if err != nil { b.Log.Error("Error obtaining guild members", err) @@ -103,7 +104,6 @@ func (b *Bdiscord) Connect() error { b.nickMemberMap[member.Nick] = member } } - b.Unlock() return nil } @@ -488,9 +488,16 @@ func (b *Bdiscord) handleUploadFile(msg *config.Message, channelID string) (stri var err error for _, f := range msg.Extra["file"] { fi := f.(config.FileInfo) - files := []*discordgo.File{} - files = append(files, &discordgo.File{fi.Name, "", bytes.NewReader(*fi.Data)}) - _, err = b.c.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{Content: msg.Username + fi.Comment, Files: files}) + file := discordgo.File{ + Name: fi.Name, + ContentType: "", + Reader: bytes.NewReader(*fi.Data), + } + m := discordgo.MessageSend{ + Content: msg.Username + fi.Comment, + Files: []*discordgo.File{&file}, + } + _, err = b.c.ChannelMessageSendComplex(channelID, &m) if err != nil { return "", fmt.Errorf("file upload failed: %#v", err) } |