mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Add Guild#fetchBan and an error for not resolving the ID
This commit is contained in:
@@ -71,6 +71,7 @@ const Messages = {
|
||||
SPLIT_MAX_LEN: 'Chunk exceeds the max length and contains no split characters.',
|
||||
|
||||
BAN_RESOLVE_ID: (ban = false) => `Couldn't resolve the user ID to ${ban ? 'ban' : 'unban'}.`,
|
||||
FETCH_BAN_RESOLVE_ID: 'Couldn\'t resolve the user ID to fetch.',
|
||||
|
||||
PRUNE_DAYS_TYPE: 'Days must be a number',
|
||||
|
||||
|
||||
@@ -554,6 +554,21 @@ class Guild extends Base {
|
||||
* @property {?string} reason Reason the user was banned
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetches the information of a specific ban.
|
||||
* @param {UserResolvable} user The User ID of the ban to fetch
|
||||
* @returns {Promise<BanInfo>}
|
||||
*/
|
||||
fetchBan(user) {
|
||||
const id = this.client.users.resolveID(user);
|
||||
if (!id) throw new Error('FETCH_BAN_RESOLVE_ID');
|
||||
return this.client.api.guilds(this.id).bans(id).get()
|
||||
.then(ban => ({
|
||||
reason: ban.reason,
|
||||
user: this.client.users.add(ban.user),
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a collection of banned users in this guild.
|
||||
* @returns {Promise<Collection<Snowflake, BanInfo>>}
|
||||
@@ -566,7 +581,7 @@ class Guild extends Base {
|
||||
user: this.client.users.add(ban.user),
|
||||
});
|
||||
return collection;
|
||||
}, new Collection())
|
||||
}, new Collection()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -584,7 +599,7 @@ class Guild extends Base {
|
||||
return this.client.api.guilds(this.id).integrations.get().then(data =>
|
||||
data.reduce((collection, integration) =>
|
||||
collection.set(integration.id, new Integration(this.client, integration, this)),
|
||||
new Collection())
|
||||
new Collection()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1035,7 +1050,7 @@ class Guild extends Base {
|
||||
this.client.actions.GuildChannelsPositionUpdate.handle({
|
||||
guild_id: this.id,
|
||||
channels: updatedChannels,
|
||||
}).guild
|
||||
}).guild,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1069,7 +1084,7 @@ class Guild extends Base {
|
||||
this.client.actions.GuildRolePositionUpdate.handle({
|
||||
guild_id: this.id,
|
||||
roles: rolePositions,
|
||||
}).guild
|
||||
}).guild,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1199,7 +1214,7 @@ class Guild extends Base {
|
||||
_sortedChannels(channel) {
|
||||
const category = channel.type === ChannelTypes.CATEGORY;
|
||||
return Util.discordSort(this.channels.filter(c =>
|
||||
c.type === channel.type && (category || c.parent === channel.parent)
|
||||
c.type === channel.type && (category || c.parent === channel.parent),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user