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

feat(MessageAttachment): description (alt text) support #6871

Merged
merged 9 commits into from Nov 11, 2021

Conversation

GamingGeek
Copy link
Contributor

@GamingGeek GamingGeek commented Oct 20, 2021

Please describe the changes this PR makes and why it should be merged:
This adds the description property to the MessageAttachment class which is used for alt text added in the client (just added in the latest build but behind an experiment)

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@GamingGeek
Copy link
Contributor Author

Just realized I never testing sending so after quickly checking, I've found the description does not get sent. Will convert to a draft and work on fixing that!

@GamingGeek GamingGeek marked this pull request as draft October 21, 2021 01:57
@GamingGeek GamingGeek marked this pull request as ready for review October 21, 2021 02:06
@GamingGeek
Copy link
Contributor Author

Sending now works, don't know if my method of doing so is great though so I would appreciate any tips on ways I could make it better.

image

Co-authored-by: D Trombett <maxtromb.dt@gmail.com>
for (const file of this.options.files) {
if (file?.file) body.append(file.key ?? file.name, file.file, file.name);
for (const [index, file] of this.options.files.entries()) {
if (file?.file) body.append(`files[${index}]`, file.file, file.name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this break emoji create?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emoji creates seem to work fine but I went to test stickers and can't get sticker creation working even after reverting this.

Would appreciate if someone else who knows how that's meant to work could give it a try to make sure I didn't break it and am just being dumb

Copy link
Contributor

@advaith1 advaith1 Oct 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote sticker uploading and it uses file.key; can you just set the key to files[${index}] in the relevant message posting code instead of modifying this? (you can also remove ?? file.name after doing that if you want)

(emoji create uses a data uri in json)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After taking a look around, it seems adding file.key ?? should work but I'm still unable to get sticker creation working with or without my changes.

@advaith1 could you try with my latest changes and check to make sure sticker creation still works? I've checked sending a message with attachments and that works fine so all that's left to check (to my knowledge) is sticker creation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been resolved?

Copy link
Contributor

@advaith1 advaith1 Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uploading stickers works for me, on this branch and on main (using the example code)

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still prefer that the `files[${index}]` logic is moved to the message code (which would just set that as file.key, for consistency) instead of the request code, but that isn't really necessary

Copy link
Member

@SpaceEEC SpaceEEC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also document and type description for FileOptions? 🙏
It seems to be working right out of the box already.


There is no PR documenting that in discord/discord-api-docs, or did I just not find it?

@GamingGeek
Copy link
Contributor Author

Could you also document and type description for FileOptions? pray It seems to be working right out of the box already.

There is no PR documenting that in discord/discord-api-docs, or did I just not find it?

Added description to the examples and added description to the typings for FileOptions

It was added in discord/discord-api-docs#3860

@iCrawl iCrawl modified the milestones: Version 13.3, Version 13.4 Oct 28, 2021
@iCrawl iCrawl merged commit 5e0a7d5 into discordjs:main Nov 11, 2021
@GamingGeek GamingGeek deleted the feature/alt-text branch November 14, 2021 10:10
ckohen added a commit to ckohen/discord.js-modules that referenced this pull request Dec 7, 2021
Ported from discordjs/discord.js#6871

Co-authored-by: Jake Ward <geek@gaminggeek.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

7 participants