diff --git a/.gitignore b/.gitignore index 2eea525..e58e5a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.env \ No newline at end of file +.env +.idea diff --git a/djpianalto.com/goff/events/message_events.go b/djpianalto.com/goff/events/message_events.go index 9748da5..ade9933 100644 --- a/djpianalto.com/goff/events/message_events.go +++ b/djpianalto.com/goff/events/message_events.go @@ -3,10 +3,32 @@ package events import ( "fmt" + "djpianalto.com/goff/djpianalto.com/goff/utils" "github.com/bwmarrin/discordgo" ) func OnMessageUpdate(session *discordgo.Session, m *discordgo.MessageUpdate) { - fmt.Println(m.Content) - fmt.Println(m.BeforeUpdate.Content) + if m.Author.Bot { + return + } + var channelID string + row := utils.Database.QueryRow("SELECT logging_channel FROM guilds where id=$1", m.GuildID) + err := row.Scan(&channelID) + if err != nil || channelID == "" { + return + } + channel, err := session.State.Channel(m.ChannelID) + if err != nil { + return + } + embed := &discordgo.MessageEmbed{ + Title: fmt.Sprintf("Edited Message: %v in %v", m.ID, channel.Mention()), + Description: fmt.Sprintf("**Before:** %v\n**After:** %v", m.BeforeUpdate.Content, m.Content), + Color: session.State.UserColor(m.Author.ID, channelID), + Footer: &discordgo.MessageEmbedFooter{ + Text: fmt.Sprintf("Author: %v", m.Author.String()), + IconURL: m.Author.AvatarURL(""), + }, + } + session.ChannelMessageSendEmbed(channelID, embed) } diff --git a/go.sum b/go.sum index 304ded5..d334ce0 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustinpianalto/disgoman v0.0.2 h1:VaXG4SOeJl4oa3mIAEG5dwp5d4lXRW10RO91XX13CVI= github.com/dustinpianalto/disgoman v0.0.2/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= +github.com/dustinpianalto/disgoman v0.0.9 h1:fAJspATr2MAv7AGAPPViIThRxKU/KMSpQiXIGznvXnw= +github.com/dustinpianalto/disgoman v0.0.9/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=