Use BeforeUpdate in OnMessageUpdate

pull/1/head
DustyP 6 years ago
parent 47028c8227
commit b419eaee1f

@ -13,26 +13,27 @@ func OnMessageUpdate(session *discordgo.Session, m *discordgo.MessageUpdate) {
fmt.Println("Recovered from panic in OnMessageUpdate", r) fmt.Println("Recovered from panic in OnMessageUpdate", r)
} }
}() }()
if m.Author.Bot { msg := m.BeforeUpdate
if msg.Author.Bot {
return return
} }
var channelID string var channelID string
row := utils.Database.QueryRow("SELECT logging_channel FROM guilds where id=$1", m.GuildID) row := utils.Database.QueryRow("SELECT logging_channel FROM guilds where id=$1", msg.GuildID)
err := row.Scan(&channelID) err := row.Scan(&channelID)
if err != nil || channelID == "" { if err != nil || channelID == "" {
return return
} }
channel, err := session.State.Channel(m.ChannelID) channel, err := session.State.Channel(msg.ChannelID)
if err != nil { if err != nil {
return return
} }
embed := &discordgo.MessageEmbed{ embed := &discordgo.MessageEmbed{
Title: fmt.Sprintf("Message Edited: %v", m.ID), Title: fmt.Sprintf("Message Edited: %v", msg.ID),
Description: fmt.Sprintf("**Before:** %v\n**After:** %v\nIn Channel: %v", m.BeforeUpdate.Content, m.Content, channel.Mention()), Description: fmt.Sprintf("**Before:** %v\n**After:** %v\nIn Channel: %v", msg.Content, m.Content, channel.Mention()),
Color: session.State.UserColor(m.Author.ID, channelID), Color: session.State.UserColor(msg.Author.ID, channelID),
Footer: &discordgo.MessageEmbedFooter{ Footer: &discordgo.MessageEmbedFooter{
Text: fmt.Sprintf("Author: %v", m.Author.String()), Text: fmt.Sprintf("Author: %v", msg.Author.String()),
IconURL: m.Author.AvatarURL(""), IconURL: msg.Author.AvatarURL(""),
}, },
} }
session.ChannelMessageSendEmbed(channelID, embed) session.ChannelMessageSendEmbed(channelID, embed)

Loading…
Cancel
Save