refactor: consistently use permissionOverwrites over overwrites (#2886)

This commit is contained in:
SpaceEEC
2018-10-10 10:25:00 +02:00
committed by GitHub
parent 71c04a303a
commit 6e5f088e44
3 changed files with 19 additions and 16 deletions

View File

@@ -31,7 +31,7 @@ class GuildChannelStore extends DataStore {
* @param {number} [options.bitrate] Bitrate of the new channel in bits (only voice)
* @param {number} [options.userLimit] Maximum amount of users allowed in the new channel (only voice)
* @param {ChannelResolvable} [options.parent] Parent of the new channel
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [options.overwrites]
* @param {OverwriteResolvable[]|Collection<Snowflake, OverwriteResolvable>} [options.permissionOverwrites]
* Permission overwrites of the new channel
* @param {number} [options.rateLimitPerUser] The ratelimit per user for the channel
* @param {string} [options.reason] Reason for creating the channel
@@ -42,10 +42,10 @@ class GuildChannelStore extends DataStore {
* .then(console.log)
* .catch(console.error);
* @example
* // Create a new channel with overwrites
* // Create a new channel with permission overwrites
* guild.channels.create('new-voice', {
* type: 'voice',
* overwrites: [
* permissionOverwrites: [
* {
* id: message.author.id,
* deny: ['VIEW_CHANNEL'],
@@ -53,8 +53,12 @@ class GuildChannelStore extends DataStore {
* ],
* })
*/
async create(name, { type, topic, nsfw, bitrate, userLimit, parent, overwrites, rateLimitPerUser, reason } = {}) {
async create(name, options = {}) {
let { type, topic, nsfw, bitrate, userLimit, parent, permissionOverwrites, rateLimitPerUser, reason } = options;
if (parent) parent = this.client.channels.resolveID(parent);
if (permissionOverwrites) {
permissionOverwrites = permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild));
}
const data = await this.client.api.guilds(this.guild.id).channels.post({
data: {
@@ -65,7 +69,7 @@ class GuildChannelStore extends DataStore {
bitrate,
user_limit: userLimit,
parent_id: parent,
permission_overwrites: overwrites && overwrites.map(o => PermissionOverwrites.resolve(o, this.guild)),
permission_overwrites: permissionOverwrites,
rate_limit_per_user: rateLimitPerUser,
},
reason,