Determining a Message's ChannelType #1319
-
I would like to determine if a message is a DM or public channel message. We get ChannelID with the message object, but I can't find a function or path back to Channel.ChannelType. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Fetch the channel using the Session and get it's type from there |
Beta Was this translation helpful? Give feedback.
-
We can call the Channel function on the local session variable in messageCreate(session, message). st, err := s.Channel(m.ChannelID) |
Beta Was this translation helpful? Give feedback.
We can call the Channel function on the local session variable in messageCreate(session, message).
That will return a reference to the channel where we can get (int)Type and compare to the ChannelType constant to determine the message type.
st, err := s.Channel(m.ChannelID)
st.Type != discordgo.ChannelTypeDM