From 9ffcd83027f0fc06d69df21475865ad55138de01 Mon Sep 17 00:00:00 2001 From: Papaia <43409674+papaia@users.noreply.github.com> Date: Sun, 24 Jan 2021 12:52:35 +0200 Subject: [PATCH] docs(BitFields): remove string from BitFieldResolvable (#5122) * refactor(BitFields): remove string from BitFieldResolvable * docs(Client#generateInvite): fix indentation in example * chore: resolve conflict * refactor: revert breaking changes Co-authored-by: Papaia <43409674+ItsPapaia@users.noreply.github.com> --- src/client/Client.js | 6 +++++- src/managers/GuildChannelManager.js | 2 +- src/structures/GuildAuditLogs.js | 3 ++- src/structures/GuildChannel.js | 4 ++-- src/structures/Role.js | 2 +- src/util/BitField.js | 5 ++--- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index 79a1f44cc..107abf453 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -385,7 +385,11 @@ class Client extends BaseClient { * @returns {Promise} * @example * client.generateInvite({ - * permissions: ['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE'], + * permissions: [ + * Permissions.FLAGS.SEND_MESSAGES, + * Permissions.FLAGS.MANAGE_GUILD, + * Permissions.FLAGS.MENTION_EVERYONE, + * ], * }) * .then(link => console.log(`Generated bot invite link: ${link}`)) * .catch(console.error); diff --git a/src/managers/GuildChannelManager.js b/src/managers/GuildChannelManager.js index ab4f1f2d7..58d0c73bd 100644 --- a/src/managers/GuildChannelManager.js +++ b/src/managers/GuildChannelManager.js @@ -86,7 +86,7 @@ class GuildChannelManager extends BaseManager { * permissionOverwrites: [ * { * id: message.author.id, - * deny: ['VIEW_CHANNEL'], + * deny: [Permissions.FLAGS.VIEW_CHANNEL], * }, * ], * }) diff --git a/src/structures/GuildAuditLogs.js b/src/structures/GuildAuditLogs.js index 823b0037a..394fdebfc 100644 --- a/src/structures/GuildAuditLogs.js +++ b/src/structures/GuildAuditLogs.js @@ -4,6 +4,7 @@ const Integration = require('./Integration'); const Webhook = require('./Webhook'); const Collection = require('../util/Collection'); const { PartialTypes } = require('../util/Constants'); +const Permissions = require('../util/Permissions'); const Snowflake = require('../util/Snowflake'); const Util = require('../util/Util'); @@ -441,7 +442,7 @@ class GuildAuditLogsEntry { ); } else if (targetType === Targets.INVITE) { this.target = guild.members.fetch(guild.client.user.id).then(me => { - if (me.permissions.has('MANAGE_GUILD')) { + if (me.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) { const change = this.changes.find(c => c.key === 'code'); return guild.fetchInvites().then(invites => { this.target = invites.find(i => i.code === (change.new || change.old)); diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 2a2f91248..6832b6ff6 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -200,7 +200,7 @@ class GuildChannel extends Channel { * channel.overwritePermissions([ * { * id: message.author.id, - * deny: ['VIEW_CHANNEL'], + * deny: [Permissions.FLAGS.VIEW_CHANNEL], * }, * ], 'Needed to change permissions'); */ @@ -284,7 +284,7 @@ class GuildChannel extends Channel { get members() { const members = new Collection(); for (const member of this.guild.members.cache.values()) { - if (this.permissionsFor(member).has('VIEW_CHANNEL', false)) { + if (this.permissionsFor(member).has(Permissions.FLAGS.VIEW_CHANNEL, false)) { members.set(member.id, member); } } diff --git a/src/structures/Role.js b/src/structures/Role.js index d14db3639..04db107ee 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -296,7 +296,7 @@ class Role extends Base { * @returns {Promise} * @example * // Set the permissions of the role - * role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS']) + * role.setPermissions([Permissions.FLAGS.KICK_MEMBERS, Permissions.FLAGS.BAN_MEMBERS]) * .then(updated => console.log(`Updated permissions to ${updated.permissions.bitfield}`)) * .catch(console.error); * @example diff --git a/src/util/BitField.js b/src/util/BitField.js index fabbaf918..070f28db0 100644 --- a/src/util/BitField.js +++ b/src/util/BitField.js @@ -130,11 +130,10 @@ class BitField { /** * Data that can be resolved to give a bitfield. This can be: - * * A string (see {@link BitField.FLAGS}) - * * A bit number + * * A bit number (this can be a number literal or a value taken from {@link BitField.FLAGS}) * * An instance of BitField * * An Array of BitFieldResolvable - * @typedef {string|number|BitField|BitFieldResolvable[]} BitFieldResolvable + * @typedef {number|BitField|BitFieldResolvable[]} BitFieldResolvable */ /**