Get message.content with the bot class in pycord?

31 views Asked by At

I'm trying to get the message.content of messages sent in a server with my bot using pycord. I've been googling for an hour trying to find anything that's different from what I've done, with no luck.

here's what i have written (simplified):

and an edit: i should mention i've tried both @bot.event and @bot.listen, with and without () at the end. I have also ensured that I invited it with the necessary permissions.


import discord

bot = discord.Bot()


token = [token would go here]
intents = discord.Intents.default()
intents.typing = True
intents.messages = True
intents.message_content = True

@bot.event
async def on_message(message):
    print(f'Recieved {message.content}')

bot.run(token)

And from there, I should be getting

Recieved {message.content}

for every message that is sent in the server. However, all I'm getting in the shell is Receieved with no message content. Yes, I have toggled on message content intent in my bot's dashboard in the discord dev portal.

I can achieve the result I want using a client object instead of a bot, but that prevents me from using slash commands that I need, and I can't run both. So does anyone know what the hell pycord's deal is?

1

There are 1 answers

0
FlamingOranges On

FIXED IT: adding this block:

intents = discord.Intents.default()

intents.typing = True
intents.messages = True
intents.message_content = True
bot = discord.Bot(intents=intents)

has solved it. I feel stupid now but thats how this hobby goes ig.