comcord/events/messages.go

35 lines
779 B
Go
Raw Normal View History

2023-07-08 20:51:26 +00:00
package events
import (
2023-07-09 04:42:58 +00:00
"github.com/Cynosphere/comcord/lib"
2023-07-08 20:51:26 +00:00
"github.com/Cynosphere/comcord/state"
"github.com/bwmarrin/discordgo"
)
func MessageCreate(session *discordgo.Session, msg *discordgo.MessageCreate) {
2023-07-09 04:42:58 +00:00
if msg.Author.ID == session.State.User.ID {
2023-07-08 20:51:26 +00:00
return
}
channel, err := session.State.Channel(msg.ChannelID)
if err != nil {
return
}
2023-07-09 04:42:58 +00:00
isDM := channel.Type == discordgo.ChannelTypeDM || channel.Type == discordgo.ChannelTypeGroupDM
2023-07-08 20:51:26 +00:00
if state.IsInPrompt() {
2023-07-09 04:42:58 +00:00
state.AddMessageToQueue(msg.Message)
2023-07-08 20:51:26 +00:00
} else {
2023-07-09 04:42:58 +00:00
lib.ProcessMessage(session, msg.Message, lib.MessageOptions{NoColor: state.HasNoColor()})
2023-07-08 20:51:26 +00:00
}
2023-07-09 04:42:58 +00:00
if isDM {
2023-07-08 20:51:26 +00:00
state.SetLastDM(msg.ChannelID)
}
}
func MessageUpdate(session *discordgo.Session, msg *discordgo.MessageUpdate) {
}