qeled / discordie

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

Unable to unban after banning #37

Closed briantanner closed 8 years ago

briantanner commented 8 years ago

I imagine this has something to do with a user being uncached after banning, but below is the code and error caused by it.

member.ban(7).then(() => {
    member.unban();
}).catch(err => logger.error(err));
{"message":"Cannot read property 'valueOf' of null","stack":"TypeError: Cannot read property 'valueOf' of null\n    at IGuild.unban (/Users/briantanner/GitRepos/Dyno/node_modules/discordie/lib/interfaces/IGuild.js:291:16)\n    at IGuildMember.unban (/Users/briantanner/GitRepos/Dyno/node_modules/discordie/lib/interfaces/IGuildMember.js:132:23)\n    at member.ban.then (/Users/briantanner/GitRepos/Dyno/modules/Moderation.js:311:11)\n    at process._tickCallback (internal/process/next_tick.js:103:7)"}```
qeled commented 8 years ago

Yes, as far as consistency goes this is correct, and member.unban works only in sync code.

Though from usability standpoint I can call this behavior retarded and this will be fixed in the next version.

Initially for that case guild.ban/unban methods were created for use with user object or id:

const uid = user.id;
guild.ban(uid, 7).then(() => {
  // user.id is no longer available in this scope
  guild.unban(uid);
});
briantanner commented 8 years ago

Thanks for the quick response.