Q:

how to check for file extension in discord.py

i am creating a python discord bot, and i have a function that if a message is sent in a certain channel,
it randomly sends out a response,everything works fine but i want to restrict the bot to react only when the sent message contains a png, jpg or jpeg file
heres the code(look for the bottom if str(message.channel)  statement):
@client.event
async def on_message(message):
    await client.process_commands(message)
    if str(message.channel) not in restr:
            if message.content == ".sabaton":
                random.seed(time.time())
                randnum = random.randint(0, len(songs) - 1)
                await message.channel.send(file=discord.File(songs[randnum]))
            elif message.content == ".time":
                await message.channel.send(f"Current time is {time.localtime()}")
            elif message.content == ".pmsh":
                await message.channel.send(help)
            if client.user.mention in message.content.split():
                await message.channel.send('Дарова гандон(иха),мой префикс "."')
    if str(message.channel) == "творчество":
        random.seed(time.time())
        rn3 = random.randint(1,2)
        if rn3 == 1 and message.author.bot == False:
            await message.channel.send("Заебись творчество")
        elif rn3 == 2 and message.author.bot == False:
            await message.channel.send("Фигня творчество")

A:

You can use the following conditions to restrict it:
if message.attachments[0].url.endswith('PNG') or message.attachments[0].url.endswith('JPG') or message.attachments[0].url.endswith('JPEG'):
    pass
else:
    pass

Change the pass according to your content.

