Added Guild.fetchBans()

This commit is contained in:
Amish Shah
2016-08-27 22:48:43 +01:00
parent 22062f1f86
commit ef0f38930f
3 changed files with 25 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
const Constants = require('../../util/Constants');
const Collection = require('../../util/Collection');
const getStructure = name => require(`../../structures/${name}`);
const User = getStructure('User');
@@ -414,6 +415,21 @@ class RESTMethods {
});
}
getGuildBans(guild) {
return new Promise((resolve, reject) => {
this.rest.makeRequest('get', Constants.Endpoints.guildBans(guild.id), true)
.then(banItems => {
const bannedUsers = new Collection();
for (const banItem of banItems) {
const user = this.rest.client.dataManager.newUser(banItem.user);
bannedUsers.set(user.id, user);
}
resolve(bannedUsers);
})
.catch(reject);
});
}
updateGuildRole(role, _data) {
return new Promise((resolve, reject) => {
/*

View File

@@ -552,6 +552,14 @@ class Guild {
return this.client.rest.methods.unbanGuildMember(this, member);
}
/**
* Fetch a Collection of banned users in this Guild.
* @returns {Promise<String, User>}
*/
fetchBans() {
return this.client.rest.methods.getGuildBans(this);
}
/**
* Gets the URL to this guild's icon (if it has one, otherwise it returns null)
* @type {?String}