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

Make sending buffers easier #1459

Closed
wants to merge 4 commits into from

Conversation

1Computer1
Copy link
Contributor

@1Computer1 1Computer1 commented May 4, 2017

Please describe the changes this PR makes and why it should be merged:

Currently, to send a buffer you have to do send({ files: [{ attachment: buffer }] }) which is honestly just ugly.
This PR makes it so that you can do send({ files: [buffer] }).

Also, I'm fairly sure that this behavior was in v11.0 but was somehow removed in v11.1.

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@amishshah
Copy link
Member

This might be better placed in #1451...

@@ -115,6 +115,7 @@ class Webhook {
for (const i in options.files) {
let file = options.files[i];
if (typeof file === 'string') file = { attachment: file };
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to combine the logic instead since you are setting file to the same thing?

if (typeof file === 'string' || Buffer.isBuffer(file)) file = { attachment: file };

@@ -91,6 +91,7 @@ class TextBasedChannel {
for (const i in options.files) {
let file = options.files[i];
if (typeof file === 'string') file = { attachment: file };
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

Copy link
Contributor

@bdistin bdistin left a comment

Choose a reason for hiding this comment

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

lgtm

@1Computer1
Copy link
Contributor Author

Closed because a lot has changed and it's gonna end up in #1731.

@1Computer1 1Computer1 closed this Jul 31, 2017
@1Computer1 1Computer1 deleted the buffer-sending branch July 31, 2017 03:09
Gawdl3y pushed a commit that referenced this pull request Aug 6, 2017
* Add Attachment structure

* Fix linter issues + @Private

* Fixed array sends, also added embed sends

* fixed proving path to attachment

* fixed incorrect name assumption from path

* linting fix

* ;)

* im really good at this

* changes as requested by gus

and computer from #1459

* am a dum

* update webhook#send

* readonly addition to getters

* i... uh... oops

* farming deez commits

* fix webhook split

* removed some ugly

* removed .every checks
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.

None yet

6 participants