#Attachment from MessageCreate event, no URL?

1 messages · Page 1 of 1 (latest)

thin cloakBOT
#
ManJORN
Warning

@nocturne apex has been warned

Reason

Sent an invite link

Admin

JARVIS#9567 (@thin cloak)

balmy magnetBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

nocturne apex
#

ah yes, an invite link

#
async def on_message_create(self, event:     interactions.events.MessageCreate):
        savedAttachments = [event.message.attachments] if event.message.attachments else None
        print(savedAttachments)```


outputs something like this: 
[Attachment(id=1317366870361247784)], 'detail': 'auto'}}]}]

same thing with event.message.channel.fetch_messages
idle rampart
#

Does Attachment.url return value? As I see, attachment.url isn't in repr

nocturne apex
#

.url does not return value

mortal osprey
#

the attachment url is not shown in Attachment's repr, which is what you're printing here. you need to directly obtain attachment.url

#

try printing that (or in the latter example, item.url) and see if there's a url

nocturne apex
#
    @listen()
    async def on_message_create(self, event: MessageCreate):
        print("test22223")
        savedAttachments = [event.message.attachments] if event.message.attachments else None
        if savedAttachments == None:
            return
        for item in savedAttachments:
            print("test38902q98")
            print(item.url)
  File "c:\Users\ManJORN\Desktop\scripts\Python Scripts\Discord Bots\JORNBot\ext\testing.py", line 23, in on_message_create
    print(item.url)
          ^^^^^^^^
AttributeError: 'list' object has no attribute 'url'
mortal osprey
#

hmm

#

ok the event.message.attachments is already a list so you don't need to [] or None-check them

nocturne apex
#

item returns the same thing as repr(item)

mortal osprey
#

savedAttachments = event.message.attachments

nocturne apex
#

oh.... this worked

#

ty...