Search code examples
pythondiscordpycord

message.content is empty for bot client (pycord)


I have simplest python program of discord bot

from discord.ext import commands

bot = commands.Bot(command_prefix='!')

@bot.event
async def on_message(msg):
    print(msg.content)

bot.run('token')

And it prints just empty string. Before that I tried bot.command() but bot simply doesn't responds to it probably because message is empty so like there's no command. I saw this problem mostly occurs for selfbot clients but in my case client is bot. Would be glad for any help


Solution

  • You have to enable the message intents on https://discord.com/developers/applications and need to pass them to your commands.Bot

    bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
    

    would be an example of how you can do that.