hikari-py / hikari

A Discord API wrapper for Python and asyncio built on good intentions.
https://docs.hikari-py.dev/en/stable
MIT License
816 stars 94 forks source link

Message Event Bug #1300

Closed kshgr closed 2 years ago

kshgr commented 2 years ago

Steps to reproduce

  1. Create a GuildMessageCreateEvent
  2. Take the value of event.content
  3. type(event.content)
  4. Send a message in a Guild
  5. Check Terminal

Expected result

type(event.content) should be returned as a string for all text messages in server

Actual result

type(event.content) returns None type for all messages in server.

System info

hikari (2.0.0.dev111) [2d0c77b5]
located at C:\Users\kushagra\AppData\Local\Programs\Python\Python310\lib\site-packages\hikari
CPython 3.10.7 MSC v.1933 64 bit (AMD64)
Windows Kushagra-Z-Book 10 10.0.22000 AMD64 Intel64 Family 6 Model 154 Stepping 3, GenuineIntel

Further info

No response

Checklist

fdnt7 commented 2 years ago

Have you perhaps enabled message content intents in your bot's developer portal?

kshgr commented 2 years ago

You can alternatively refer to my tutorial video during which this bug was found https://www.youtube.com/watch?v=jlhZXFfS40s Timestamp - 9:25 to 10:15

kshgr commented 2 years ago

Have you perhaps enabled message content intents in your bot's developer portal?

All intents are enabled and the bot was working alright with GuildMessageCreateEvent until last time.

novanai commented 2 years ago

You have not, however, enabled intents within the bot's constructor in your code.

you need to add intents=hikari.Intents.MESSAGE_CONTENT (https://www.hikari-py.dev/hikari/intents.html#hikari.intents.Intents.MESSAGE_CONTENT)

Edit: Although watching more of the video, when you start using lightbulb you add all intents

kshgr commented 2 years ago

You have not, however, enabled intents within the bot's constructor in your code.

you need to add intents=hikari.Intents.MESSAGE_CONTENT (https://www.hikari-py.dev/hikari/intents.html#hikari.intents.Intents.MESSAGE_CONTENT)

Edit: Although watching more of the video, when you start using lightbulb you add all intents

Alright thanks Is there a recent change that requires this to be done?

I do not remember this being an issue a couple of months back.

novanai commented 2 years ago

Yes, Discord made message content a privileged intent. You can read more here: https://support-dev.discord.com/hc/en-us/articles/4404772028055-Message-Content-Privileged-Intent-FAQ

You can still enable the intent without needing verification if your bot is in less than 100 servers though, but you do need to turn it on and add it to the requested intents in your code

kshgr commented 2 years ago

Great, thank you for your help! I will be sure to pass on the message in the next video.