Hi I'm doing a simple discord bot which will retrieve the last message send on a channel then will do a command x based on it but when I try to print the last message made by an user Y it show me nothing I don't know why code: ```py
import discord
import subprocess
import os
Your bot token (replace 'YOUR_BOT_TOKEN' with the actual token)
TOKEN = 'd'
Initialize the bot
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user}')
@client.event
async def on_message(message):
# Ignore messages from the bot itself
if message.author == client.user:
return
# Print the last message sent by any user to the console
print(f"Last message from {message.author}: {message.content}")
# Check if the message content is "dodo"
# print("test " , message.content, " toto " , message.author)
# if message.content.strip().lower() == 'dodo':
# # Run the dodo.py script
# try:
# # Run dodo.py using subprocess
# result = subprocess.run(['python', 'dodo.py'], capture_output=True, text=True)
# # Send the output back to the channel
# if result.stdout:
# await message.channel.send(f"Output:\n{result.stdout}")
# if result.stderr:
# await message.channel.send(f"Error:\n{result.stderr}")
# except Exception as e:
# await message.channel.send(f"An error occurred: {e}")
Run the bot
client.run(TOKEN)