qeled / discordie

Predictable JavaScript abstractions for Discord API.
https://qeled.github.io/discordie/
BSD 2-Clause "Simplified" License
190 stars 45 forks source link

fetchMessages before/after arguments error #34

Closed brawaru closed 8 years ago

brawaru commented 8 years ago

image

As said in docs, arguments after and before can be set to null. But now if they set to null, library still makes request with after/before parameters set to "" (empty string), Discord no longer allows this and prints error:

{"after": ["Value \"\" is not long."]}
abalabahaha commented 8 years ago

This was fixed in this Github repo with commit 31aeaed. It looks like it hasn't made it to a NPM release, but that shouldn't be far off

brawaru commented 8 years ago

But, if they set to null - error still here. Need some checks :wink:

I think channel.fetchMessages(100, null, "1231337456666111") will be rejected with same error

abalabahaha commented 8 years ago

It works if you leave it as undefined. The issue was that Superagent sends null keys as ?before= (which Discord now hates starting from an update yesterday), whereas undefined keys are not sent at all.

brawaru commented 8 years ago

Then why not check arguments and replace null to undefined?

abalabahaha commented 8 years ago

qeled just committed f628e1a :smile: My PR originally had it, for some reason that was removed, but it's back now.

brawaru commented 8 years ago

Fixed in f628e1a12861006b842594d0ddd93fc1f45fb722 :+1: