Discord bot not seeing message.content in discord server

Viewed 24

So I am following a simple tutorial on youtube to create a basic chat bot using python. My code for some reason is refusing to see message content sent by anyone but the bot. I have attached a screenshot of

import discord

TOKEN = "..."

client = discord.Client(intents=discord.Intents.default())

@client.event
async def on_ready():
    print("We have logged in as {0.user}".format(client))


@client.event
async def on_message(message):
    username = str(message.author).split("#")[0]
    user_message = str(message.content)
    channel = str(message.channel.name)
    print(f"{username}: {user_message} ({channel})")

    if message.channel.name == "general":
        if username.lower() == "cheeseburger":
            await message.channel.send(f"Test")
            if "hello" in user_message.lower():
                await message.channel.send(f"Hello {username}!")
                return
            return
        return

The first part of the on_message function gives me a running log of what messages are sent in the server, so I can see that the message from the user is not recorded at all. But when the bot sends "Test", it is recorded.

I have tried getting rid of User_message and just using message.content.

Apologies if it has been asked before, I've been looking around and couldn't find a useful answer. Any suggestions would be great.

Example of the output

0 Answers
Related