INNER CODE UNIT · Go
messageCreate
instead-hub/instead · src/tiny/ifbot/discord-bot/main.go:88
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
// Ignore all messages created by the bot itself
// This isn't required in this specific example but it's a good practice.
if m.Author.ID == s.State.User.ID {
return
}
text := m.Content
if !(isChannel(s, m) || isPrivate(s, m)) {
return
}
reply := ifbot.Input(hash(m.ChannelID), text)
s.ChannelMessageSend(m.ChannelID, reply)
ifbot.Cleanup()
}