Skip to content

PermissionOverwriteManager

classe · Source

Manages API methods for guild channel permission overwrites and stores their cache.

Extends: CachedManager

Properties

channel

channel: GuildChannel

The channel of the permission overwrite this manager belongs to Source

cache

cache: Collection<Snowflake, PermissionOverwrites>

The cache of this Manager Source

_cache

readonly · private

_cache: Collection

The private cache of items for this manager. Source

holds

readonly · private

holds: function

The data structure belonging to this manager. Source

client

readonly

client: Client

The client that instantiated this Manager Source

Methods

set

async

async set(overwrites: Array<OverwriteResolvable> | Collection<Snowflake, OverwriteResolvable>, reason?: string): Promise<GuildChannel>

Replaces the permission overwrites in this channel. Parameters

NameTypeDescription
overwritesArray<OverwriteResolvable> | Collection<Snowflake, OverwriteResolvable>Permission overwrites the channel gets updated with
reason?stringReason for updating the channel overwrites

Returns: Promise<GuildChannel>

js
message.channel.permissionOverwrites.set([
  {
     id: message.author.id,
     deny: [Permissions.FLAGS.VIEW_CHANNEL],
  },
], 'Needed to change permissions');

Source

upsert

async · private

async upsert(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOptions, overwriteOptions?: GuildChannelOverwriteOptions, existing?: PermissionOverwrites): Promise<GuildChannel>

Creates or edits permission overwrites for a user or role in this channel. Parameters

NameTypeDescription
userOrRoleRoleResolvable | UserResolvableThe user or role to update
optionsPermissionOverwriteOptionsThe options for the update
overwriteOptions?GuildChannelOverwriteOptionsThe extra information for the update
existing?PermissionOverwritesThe existing overwrites to merge with this update

Returns: Promise<GuildChannel>Source

create

create(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOptions, overwriteOptions?: GuildChannelOverwriteOptions): Promise<GuildChannel>

Creates permission overwrites for a user or role in this channel, or replaces them if already present. Parameters

NameTypeDescription
userOrRoleRoleResolvable | UserResolvableThe user or role to update
optionsPermissionOverwriteOptionsThe options for the update
overwriteOptions?GuildChannelOverwriteOptionsThe extra information for the update

Returns: Promise<GuildChannel>

js
// Create or Replace permission overwrites for a message author
message.channel.permissionOverwrites.create(message.author, {
  SEND_MESSAGES: false
})
  .then(channel => console.log(channel.permissionOverwrites.cache.get(message.author.id)))
  .catch(console.error);

Source

edit

edit(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOptions, overwriteOptions?: GuildChannelOverwriteOptions): Promise<GuildChannel>

Edits permission overwrites for a user or role in this channel, or creates an entry if not already present. Parameters

NameTypeDescription
userOrRoleRoleResolvable | UserResolvableThe user or role to update
optionsPermissionOverwriteOptionsThe options for the update
overwriteOptions?GuildChannelOverwriteOptionsThe extra information for the update

Returns: Promise<GuildChannel>

js
// Edit or Create permission overwrites for a message author
message.channel.permissionOverwrites.edit(message.author, {
  SEND_MESSAGES: false
})
  .then(channel => console.log(channel.permissionOverwrites.cache.get(message.author.id)))
  .catch(console.error);

Source

delete

async

async delete(userOrRole: UserResolvable | RoleResolvable, reason?: string): Promise<GuildChannel>

Deletes permission overwrites for a user or role in this channel. Parameters

NameTypeDescription
userOrRoleUserResolvable | RoleResolvableThe user or role to delete
reason?stringThe reason for deleting the overwrite

Returns: Promise<GuildChannel>Source

resolve

resolve(idOrInstance: string | Object): Object

Resolves a data entry to a data Object. Parameters

NameTypeDescription
idOrInstancestring | ObjectThe id or instance of something in this Manager

Returns: Object — An instance from this Manager Source

resolveId

resolveId(idOrInstance: string | Object): Snowflake

Resolves a data entry to an instance id. Parameters

NameTypeDescription
idOrInstancestring | ObjectThe id or instance of something in this Manager

Returns: SnowflakeSource

Unofficial software. Not affiliated with or supported by Discord.