new message

This commit is contained in:
Chris kerr 2024-04-26 22:30:28 -04:00
parent 22d05c4807
commit 50513cf3cd

19
main.go
View File

@ -60,6 +60,8 @@ func main() {
// Register messageCreate as a callback for the messageCreate events // Register messageCreate as a callback for the messageCreate events
dg.AddHandler(messageCreate) dg.AddHandler(messageCreate)
dg.AddHandler(message2Create)
// Open a websocket connection to Discord and begin listening // Open a websocket connection to Discord and begin listening
err = dg.Open() err = dg.Open()
if err != nil { if err != nil {
@ -173,8 +175,6 @@ func sendNotifications(session *discordgo.Session, channelID string, html string
} }
} }
// This function will be called whenever a new message is created // This function will be called whenever a new message is created
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
// Ignore messages created by the bot itself // Ignore messages created by the bot itself
@ -183,7 +183,20 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
} }
// If the message content is "!hello", respond with "Hello!" // If the message content is "!hello", respond with "Hello!"
if m.Content == "!hello" { if m.Content == "!hello1" {
_, _ = s.ChannelMessageSend(m.ChannelID, "Hello!") _, _ = s.ChannelMessageSend(m.ChannelID, "Hello!")
} }
} }
// This function will be called whenever a new message is created
func message2Create(s *discordgo.Session, m *discordgo.MessageCreate) {
// Ignore messages created by the bot itself
if m.Author.ID == s.State.User.ID {
return
}
// If the message content is "!hello", respond with "Hello!"
if m.Content == "!hello" {
_, _ = s.ChannelMessageSend(m.ChannelID, "You are SUCH a NERD")
}
}