mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
feat(Threads): update permissions and fix getters (#6466)
This commit is contained in:
@@ -415,7 +415,9 @@ class ThreadChannel extends Channel {
|
||||
* @readonly
|
||||
*/
|
||||
get editable() {
|
||||
return (this.ownerId === this.client.user.id && (this.type !== 'private_thread' || this.joined)) || this.manageable;
|
||||
return (
|
||||
(this.ownerId === this.client.user.id && (this.type !== 'GUILD_PRIVATE_THREAD' || this.joined)) || this.manageable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,17 +452,10 @@ class ThreadChannel extends Channel {
|
||||
*/
|
||||
get sendable() {
|
||||
return (
|
||||
!this.archived &&
|
||||
(this.type !== 'private_thread' || this.joined || this.manageable) &&
|
||||
this.permissionsFor(this.client.user)?.any(
|
||||
[
|
||||
Permissions.FLAGS.SEND_MESSAGES,
|
||||
this.type === 'GUILD_PRIVATE_THREAD'
|
||||
? Permissions.FLAGS.USE_PRIVATE_THREADS
|
||||
: Permissions.FLAGS.USE_PUBLIC_THREADS,
|
||||
],
|
||||
false,
|
||||
)
|
||||
(!(this.archived && this.locked && !this.manageable) &&
|
||||
(this.type !== 'GUILD_PRIVATE_THREAD' || this.joined || this.manageable) &&
|
||||
this.permissionsFor(this.client.user)?.has(Permissions.FLAGS.SEND_MESSAGES_IN_THREADS, false)) ??
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,12 @@ class Permissions extends BitField {
|
||||
* * `USE_APPLICATION_COMMANDS`
|
||||
* * `REQUEST_TO_SPEAK`
|
||||
* * `MANAGE_THREADS`
|
||||
* * `USE_PUBLIC_THREADS`
|
||||
* * `USE_PRIVATE_THREADS`
|
||||
* * `USE_PUBLIC_THREADS` (deprecated)
|
||||
* * `CREATE_PUBLIC_THREADS`
|
||||
* * `USE_PRIVATE_THREADS` (deprecated)
|
||||
* * `CREATE_PRIVATE_THREADS`
|
||||
* * `USE_EXTERNAL_STICKERS` (use stickers from different guilds)
|
||||
* * `SEND_MESSAGES_IN_THREADS`
|
||||
* * `START_EMBEDDED_ACTIVITIES`
|
||||
* @type {Object<string, bigint>}
|
||||
* @see {@link https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags}
|
||||
@@ -133,9 +136,13 @@ Permissions.FLAGS = {
|
||||
USE_APPLICATION_COMMANDS: 1n << 31n,
|
||||
REQUEST_TO_SPEAK: 1n << 32n,
|
||||
MANAGE_THREADS: 1n << 34n,
|
||||
// TODO: Remove deprecated USE_*_THREADS flags in v14
|
||||
USE_PUBLIC_THREADS: 1n << 35n,
|
||||
CREATE_PUBLIC_THREADS: 1n << 35n,
|
||||
USE_PRIVATE_THREADS: 1n << 36n,
|
||||
CREATE_PRIVATE_THREADS: 1n << 36n,
|
||||
USE_EXTERNAL_STICKERS: 1n << 37n,
|
||||
SEND_MESSAGES_IN_THREADS: 1n << 38n,
|
||||
START_EMBEDDED_ACTIVITIES: 1n << 39n,
|
||||
};
|
||||
|
||||
|
||||
3
typings/index.d.ts
vendored
3
typings/index.d.ts
vendored
@@ -4535,8 +4535,11 @@ export type PermissionString =
|
||||
| 'REQUEST_TO_SPEAK'
|
||||
| 'MANAGE_THREADS'
|
||||
| 'USE_PUBLIC_THREADS'
|
||||
| 'CREATE_PUBLIC_THREADS'
|
||||
| 'USE_PRIVATE_THREADS'
|
||||
| 'CREATE_PRIVATE_THREADS'
|
||||
| 'USE_EXTERNAL_STICKERS'
|
||||
| 'SEND_MESSAGES_IN_THREADS'
|
||||
| 'START_EMBEDDED_ACTIVITIES';
|
||||
|
||||
export type RecursiveArray<T> = ReadonlyArray<T | RecursiveArray<T>>;
|
||||
|
||||
Reference in New Issue
Block a user