Kraigie/nostrum

message.content coming in empty

mfilej opened this issue · 2 comments

I have a pretty simple bot that reacts to specific messages.

Today I wanted to tweak the code a bit and when I tried to run it locally I got some errors about the length of the Discord token, so I generated a new token and updated to 0.6.

After that I noticed that any messages that the bot receives from public channels come in without the content:

%Nostrum.Struct.Message{                                                                                                                                                                                                                                                                                                      
  activity: nil,                                                                                                                                                                                                                                                                                                              
  application: nil,                                                                                                                                                                                                                                                                                                           
  application_id: nil,                                                                                                                                                                                                                                                                                                        
  # ...
  content: "",                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  edited_timestamp: nil,                                                                                                                                                                                                                                                                                                      
  embeds: [],
  # …
}  

When I message the bot directly it is still able to read the content as before.

The permissions in the bot portal are still the same as far as I can tell. I also read announcements that message content is going to become a privileged intent, but they say it will only happen for more popular bots and mine just runs on this one Discord server.

I feel like I'm missing something pretty obvious here.

You must be sure to request the :message_content intent when connecting to the gateway if you are not already. (This is different from the :guild_messages intent!)

Thanks for the tip, that worked.

The way I read Discord's announcement I definitely understood like my bot wouldn't be affected by this, but I'm guessing I just won't need to ask them to verify me (hopefully!), but I still have to provide the intent.

For the record, this is how I set up the config (specifying just :message_content caused the bot not to receive any messages and I couldn't figure out what else was needed from the names, so I just added all the defaults):

config :nostrum,
  gateway_intents: [
    :guilds,
    :guild_bans,
    :guild_emojis,
    :guild_integrations,
    :guild_webhooks,
    :guild_invites,
    :guild_voice_states,
    :guild_messages,
    :guild_message_reactions,
    :guild_message_typing,
    :direct_messages,
    :direct_message_reactions,
    :direct_message_typing,
    :message_content,
    :guild_scheduled_events
  ]