Empty messages from discord - Repl.it Python Discord Bot

I’m trying to work through the beginner discord bot in Python video/instructional and I’m having a weird error. It seems that the messages from discord are triggering the code, but there is nothing in message.content. So replies based on content in a message doesn’t work.

I think everything else is set up because I can get message.id, and I can have the bot reply as long as it’s not a conditional format based off of the message content.

here’s the portion of the code in question:

@client.event
async def on_message(message):
msg = message.content
print(msg) #a blank line is printed here
print(message.id)
if message.author == client.user:
return
if message.content.startswith(‘j’): # this conditional will run if there is nothing
print(message.id) #between the apostrophes
quote = get_quote()
await message.channel.send(quote)

if any(word in msg for word in sad_words):
print(msg)
print(message.id)
await message.channel.send(random.choice(starter_encouragements))

if you have any ideas why the messages are coming through empty, I’d really appreciate it!

Hey, I’m sorry for replying, because I don’t have the answer, but I want to know more about this tutorial for creating this Bot, can you provide me with the link to it, I’m interested, Thank You

1 Like

Heya @manzadar,

That tutorial is a bit outdated. One of the breaking changes that Discord has rolled out on their API is the new Message Content privileged intent. Without enabling that, you won’t see the content property on any messages.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.