Use BeforeUpdate in OnMessageUpdate
This commit is contained in:
parent
47028c8227
commit
b419eaee1f
@ -13,26 +13,27 @@ func OnMessageUpdate(session *discordgo.Session, m *discordgo.MessageUpdate) {
|
||||
fmt.Println("Recovered from panic in OnMessageUpdate", r)
|
||||
}
|
||||
}()
|
||||
if m.Author.Bot {
|
||||
msg := m.BeforeUpdate
|
||||
if msg.Author.Bot {
|
||||
return
|
||||
}
|
||||
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)
|
||||
if err != nil || channelID == "" {
|
||||
return
|
||||
}
|
||||
channel, err := session.State.Channel(m.ChannelID)
|
||||
channel, err := session.State.Channel(msg.ChannelID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
embed := &discordgo.MessageEmbed{
|
||||
Title: fmt.Sprintf("Message Edited: %v", m.ID),
|
||||
Description: fmt.Sprintf("**Before:** %v\n**After:** %v\nIn Channel: %v", m.BeforeUpdate.Content, m.Content, channel.Mention()),
|
||||
Color: session.State.UserColor(m.Author.ID, channelID),
|
||||
Title: fmt.Sprintf("Message Edited: %v", msg.ID),
|
||||
Description: fmt.Sprintf("**Before:** %v\n**After:** %v\nIn Channel: %v", msg.Content, m.Content, channel.Mention()),
|
||||
Color: session.State.UserColor(msg.Author.ID, channelID),
|
||||
Footer: &discordgo.MessageEmbedFooter{
|
||||
Text: fmt.Sprintf("Author: %v", m.Author.String()),
|
||||
IconURL: m.Author.AvatarURL(""),
|
||||
Text: fmt.Sprintf("Author: %v", msg.Author.String()),
|
||||
IconURL: msg.Author.AvatarURL(""),
|
||||
},
|
||||
}
|
||||
session.ChannelMessageSendEmbed(channelID, embed)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user