Python 3.x 如何在discord.py中删除带有附加.exe文件的邮件

Python 3.x 如何在discord.py中删除带有附加.exe文件的邮件,python-3.x,discord,discord.py,Python 3.x,Discord,Discord.py,我正在用Python编写一个Discord机器人。如果附加文件的扩展名为.exe或.dll,我需要编写一个事件来删除邮件,如何执行此操作?要检查文件的扩展名,首先必须获取带有message.attachments的文件。然后创建一个循环并检查它们的名称 @bot.event async def on_message(message): for file in message.attachments: if file.filename.endswith((".ex

我正在用Python编写一个Discord机器人。如果附加文件的扩展名为.exe或.dll,我需要编写一个事件来删除邮件,如何执行此操作?

要检查文件的扩展名,首先必须获取带有
message.attachments
的文件。然后创建一个循环并检查它们的名称

@bot.event
async def on_message(message):
    for file in message.attachments:
        if file.filename.endswith((".exe", ".dll")):
            await message.delete()

到目前为止你试过什么?