mirror of
https://github.com/discordjs/discord.js.git
synced 2026-06-03 09:30:08 +00:00
Errors Standardization (#1246)
* errors and stuff * more errors * all the errors * fix build
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user