Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add description attribute to Attachment #505

Closed
wants to merge 3 commits into from
Closed

Add description attribute to Attachment #505

wants to merge 3 commits into from

Conversation

plun1331
Copy link
Member

Summary

Adds the description attribute to Attachment

This can also be added to File, but I tried and couldn't get it to work

Resolves #483 (I guess)

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

@Lulalaby
Copy link
Member

Yep that's correct ❤️

@Lulalaby
Copy link
Member

I'm a bit tired rn and on phone. Did you added description to adding files too?
If you send a message with a file you can add the description. The topic is a bit difficult.

@Lulalaby
Copy link
Member

If not, we can merge this so bots can already access the property.

@plun1331
Copy link
Member Author

I'm a bit tired rn and on phone. Did you added description to adding files too? If you send a message with a file you can add the description. The topic is a bit difficult.

i spent a few hours trying but discord seems to dislike me
but no, i didn't

Lulalaby
Lulalaby previously approved these changes Nov 25, 2021
@Lulalaby
Copy link
Member

I'm a bit tired rn and on phone. Did you added description to adding files too? If you send a message with a file you can add the description. The topic is a bit difficult.

i spent a few hours trying but discord seems to dislike me
but no, i didn't

Ok I'm gonna make a new issue for that with additional informations.

@Lulalaby
Copy link
Member

@plun1331 if you're interested how it would work, you could take a look here: Aiko-IT-Systems/DisCatSharp#81

Not many libs has it implemented yet. Discord sneaked it into the docs without any notice :D

@plun1331
Copy link
Member Author

@plun1331 if you're interested how it would work, you could take a look here: Aiko-IT-Systems/DisCatSharp#81

Not many libs has it implemented yet. Discord sneaked it into the docs without any notice :D

I tried to implement it in a fork but discord kept sending me 400s and I couldn't figure out why

@Lulalaby
Copy link
Member

{
   "code":50035,
   "errors":{
      "attachments":{
         "0":{
            "_errors":[
               {
                  "code":"ATTACHMENT_NOT_FOUND",
                  "message":"Attachment data not found"
               }
            ]
         }
      },
      "message":"Invalid Form Body"
   }
}

Is that the error you get

@Lulalaby
Copy link
Member

Lulalaby commented Nov 25, 2021

A correct payload_json would be:

{
   "tts":false,
   "allowed_mentions":{
      "parse":[
         "everyone",
         "users",
         "roles"
      ]
   },
   "attachments":[
      {
         "filename":"cute.jpg",
         "description":"Cute anime girl UwU",
         "size":0,
         "id":0
      }
   ]
}

And the files name in the file form-data has to be files[0] in this case.
files[n] must be mapped to attachments: [{ "id": n }]

@plun1331
Copy link
Member Author

A correct payload_json would be:

{
   "tts":false,
   "allowed_mentions":{
      "parse":[
         "everyone",
         "users",
         "roles"
      ]
   },
   "attachments":[
      {
         "filename":"cute.jpg",
         "description":"Cute anime girl UwU",
         "size":0,
         "id":0
      }
   ]
}

And the files name in the file form-data has to be files[0] in this case. files[n] must be mapped to attachments: [{ "id": n }]

iirc thats what i was sending, but ill check

@Lulalaby
Copy link
Member

Check if the file names are really files[n] and not encoded

@plun1331
Copy link
Member Author

threw in a print and it's claiming this is being sent

[
  (<MultiDict('name': 'payload_json')>, 
  {}, 
  '{"tts":null,"content":"a","message_reference":{"message_id":913294318368862249,"channel_id":889181570932551692,"guild_id":889181570932551690},"attachments":[{"id":0,"description":"Profile banner","filename":"banner.jpg"}]}'), 
  (<MultiDict('name': 'files[0]', 'filename': 'banner.jpg')>, 
  {'Content-Type': 'application/octet-stream'}, 
  <_io.BufferedReader name='banner.jpg'>)
]

@plun1331
Copy link
Member Author

Wrong content type

thats what the lib set it to originally, what should it be set to

@Lulalaby
Copy link
Member

No the media content type is wrong. It should be image/jpeg

@plun1331
Copy link
Member Author

application/form-data

for the file?
also, could we continue this on discord

@Lulalaby
Copy link
Member

The media content type headers are an evil topic

@Lulalaby
Copy link
Member

application/form-data

for the file?
also, could we continue this on discord

Yus let's do that

discord/message.py Outdated Show resolved Hide resolved
discord/message.py Outdated Show resolved Hide resolved
Lulalaby and others added 2 commits November 25, 2021 14:36
Co-authored-by: Izhar Ahmad <54180221+nerdguyahmad@users.noreply.github.com>
Co-authored-by: Izhar Ahmad <54180221+nerdguyahmad@users.noreply.github.com>
@plun1331
Copy link
Member Author

Continued in #509

@plun1331 plun1331 closed this Nov 25, 2021
auto-merge was automatically disabled November 25, 2021 19:53

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add description to attachments
3 participants