Save images from discord Midjourney Bot

HI, I want to automatically save images from the midjourney bot. I have create a macro In Keyboard Maestro where I sent json data and it automatically send the prompt to MJ bot and create images for me now I want to save that all 4 images in my folder can you help guys?
My code for saving images but it only you are logged in, after that nothing

import discord
from discord.ext import commands
import requests
# Configure your bot's intents to handle messages
intents = discord.Intents.default()
intents.messages = True  # Allows reading messages
intents.guilds = True
intents.message_content = True  



# Initialize the bot
bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
    print(f'{bot.user.name} has connected to Discord!')

@bot.event
async def on_message(message):
    print(f'Message from {message.author}: {message.content}')
    print(f"Received message from {message.author.name} in {'DM' if isinstance(message.channel, discord.DMChannel) else 'a channel'}: {message.content[:50]}...")  # Log a preview of the message
    if message.author.bot and "midjourney" in str(message.author.name).lower():
        print(f"Detected message from Midjourney Bot: {message.content}")
        for attachment in message.attachments:
            print(f"Found attachment: {attachment.url}")
            if attachment.url.lower().endswith(('png', 'jpg', 'jpeg', 'gif')):
                try:
                    response = requests.get(attachment.url)
                    if response.status_code == 200:
                        file_path = f'Assets/{attachment.filename}'
                        with open(file_path, 'wb') as file:
                            file.write(response.content)
                        print(f"Downloaded {file_path}")
                    else:
                            print(f"Failed to download the image: HTTP {response.status_code}")
                except Exception as e:
                    print(f"Exception occurred: {str(e)}")

bot.run('bot token')

and the response is I am logged in that’s it

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').