from discord.ext import commands
import data_bot
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print('Bot is ready!')
@bot.event
async def on_message(message):
if message.author.bot:
return # Ігнорує повідомлення від інших ботів
print(f"{message.author}: {message.content}")
await bot.process_commands(message)
bot.run(data_bot.TOKEN)
enter image description here I am a beginner in programming and wanted to write a Discord bot that would display all messages that were on the server in the console. Unfortunately, the bot does not output the text itself. I do not understand what the problem is.
You are missing the message content privileged intents. Without this, all messages will be empty. This has to be both enabled in the code, and in the developer portal.
intents = discord.Intents.default()
intents.message_content = True
And on the developer portal, where you first created your bot: