Errors Standardization (#1246)

* errors and stuff

* more errors

* all the errors

* fix build
This commit is contained in:
Gus Caplan
2017-06-25 12:48:05 -05:00
committed by Amish Shah
parent 602fe06f88
commit 63e54982f4
28 changed files with 258 additions and 102 deletions

View File

@@ -14,6 +14,7 @@ const Util = require('../util/Util');
const Snowflake = require('../util/Snowflake');
const Permissions = require('../util/Permissions');
const Shared = require('./shared');
const { Error, TypeError } = require('../errors');
/**
* Represents a guild (or a server) on Discord.
@@ -804,8 +805,7 @@ class Guild {
*/
unban(user, reason) {
const id = this.client.resolver.resolveUserID(user);
if (!id) throw new Error('Couldn\'t resolve the user ID to unban.');
if (!id) throw new Error('BAN_RESOLVE_ID');
return this.client.api.guilds(this.id).bans(id).delete({ reason })
.then(() => user);
}
@@ -828,7 +828,7 @@ class Guild {
* .catch(console.error);
*/
pruneMembers({ days = 7, dry = false, reason } = {}) {
if (typeof days !== 'number') throw new TypeError('Days must be a number.');
if (typeof days !== 'number') throw new TypeError('PRUNE_DAYS_TYPE');
return this.client.api.guilds(this.id).prune[dry ? 'get' : 'post']({ query: { days }, reason })
.then(data => data.pruned);
}