I would like to have a discord bot reply to a message made in a public channel via a private message.
I am able to detect whether a channel is private or not using the following code from the FAQ:
func isTheChannelTheMessageWasSentInPrivate(s *discordgo.Session, m *discordgo.MessageCreate) {
channel, err := s.State.Channel(m.ChannelID)
if err != nil {
astilog.Fatal(err)
return
} else if m.Author.ID == s.State.User.ID {
return
}
channelIsPrivate := strconv.FormatBool(channel.IsPrivate)
print("Channel ID: " + m.ChannelID + ". Is it private? " + channelIsPrivate + "
")
}
And I can reply to a message on the same channel it was received using this code:
func recieveMessage(s *discordgo.Session, m *discordgo.MessageCreate) {
s.ChannelMessageSend(m.ChannelID, "Reply!")
}
But I can't figure our how to get the ChannelID
of a user's direct message channel from the Message
object that is available upon receiving a message.