'discord.py on_message no content
This usually always works, but for some reason my Message object has an empty "content" attribute, even when a normal message is sent (no embeds). Keep in mind im running this with the py-cord beta release.
from discord.ext import commands
bot = commands.Bot(command_prefix="$")
@bot.event
async def on_message(ctx):
print(ctx.content) # Prints empty string
bot.run(token)
(All intents are already enabled in the developer portal)
Solution 1:[1]
The on_message event accepts message as a parameter.
Do this:
@bot.event
async def on_message(message: discord.Message) -> None:
print(message.content)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sandy |
