Why doesn't my discord.py bot see messages in discord

Question:

I am making a basic discord bot (python) and it should print out into the terminal who messaged what and in what channel. The only issue is when it prints out the message part in the terminal it is blank as if nothing was there. My code is intended to respond but it isn’t "seeing" what I message in discord. There is no error message.

Image of the terminal

import discord
import random
import os



client = discord.Client(intents=discord.Intents.default())

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    username = str(message.author).split('#')[0]
    user_message = str(message.content)
    channel = str(message.channel.name)
    print(f'{username}: {user_message} ({channel}))')

Then I would make it respond to what I messaged but it doesn’t SEE the message.
If it’s a really stupid mistake sorry I’m a starter

Asked By: James

||

Answers:

you should activate the message content intent in discord.com/developers/applications then replace :
discord.Client(intents=discord.Intents.default())
With

intents = discord.Intents.default()
intents.message_content = True
discord.Client(intents=intents)

message content intent activation screenshot

Answered By: Okba Eds
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.