lunibee 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +223 -223
  3. package/dist/builders/commands.d.ts +39 -0
  4. package/dist/builders/components.d.ts +37 -12
  5. package/dist/builders/embed.d.ts +3 -1
  6. package/dist/builders/index.d.ts +2 -2
  7. package/dist/builders/index.js +192 -29
  8. package/dist/builders/index.js.map +9 -7
  9. package/dist/collection/index.d.ts +30 -0
  10. package/dist/collection/index.js +79 -5
  11. package/dist/collection/index.js.map +4 -4
  12. package/dist/core/events.d.ts +88 -2
  13. package/dist/core/index.d.ts +46 -85
  14. package/dist/core/index.js +2395 -789
  15. package/dist/core/index.js.map +44 -22
  16. package/dist/core/permissions.d.ts +112 -53
  17. package/dist/formatters/index.d.ts +43 -3
  18. package/dist/formatters/index.js +64 -1
  19. package/dist/formatters/index.js.map +3 -3
  20. package/dist/handlers/index.js.map +2 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +3783 -1009
  23. package/dist/index.js.map +63 -38
  24. package/dist/managers/emoji.d.ts +38 -0
  25. package/dist/managers/guild-resources.d.ts +109 -0
  26. package/dist/managers/guild.d.ts +117 -1
  27. package/dist/managers/index.d.ts +37 -1
  28. package/dist/managers/index.js +1125 -81
  29. package/dist/managers/index.js.map +25 -20
  30. package/dist/rest/decoder.d.ts +23 -0
  31. package/dist/rest/errors.d.ts +20 -0
  32. package/dist/rest/index.d.ts +119 -25
  33. package/dist/rest/index.js +676 -204
  34. package/dist/rest/index.js.map +14 -6
  35. package/dist/rest/limiter.d.ts +42 -0
  36. package/dist/rest/redis.d.ts +54 -0
  37. package/dist/rest/route.d.ts +31 -0
  38. package/dist/rest/routes.d.ts +24 -0
  39. package/dist/rest/scheduler.d.ts +42 -0
  40. package/dist/rest/store.d.ts +67 -0
  41. package/dist/rest/transport.d.ts +40 -0
  42. package/dist/rest/webhook.d.ts +2 -2
  43. package/dist/sharding/bus.d.ts +31 -0
  44. package/dist/sharding/cluster.d.ts +71 -0
  45. package/dist/sharding/index.d.ts +18 -2
  46. package/dist/sharding/index.js +1202 -317
  47. package/dist/sharding/index.js.map +18 -7
  48. package/dist/structures/audit-log.d.ts +26 -0
  49. package/dist/structures/base.d.ts +40 -0
  50. package/dist/structures/channels.d.ts +56 -0
  51. package/dist/structures/index.d.ts +30 -1
  52. package/dist/structures/index.js +963 -87
  53. package/dist/structures/index.js.map +17 -10
  54. package/dist/structures/interactions.d.ts +12 -52
  55. package/dist/structures/options.d.ts +55 -0
  56. package/dist/structures/resources.d.ts +194 -6
  57. package/dist/types/gateway-events.d.ts +132 -0
  58. package/dist/types/gateway.d.ts +181 -0
  59. package/dist/types/index.d.ts +78 -263
  60. package/dist/types/index.js +44 -2
  61. package/dist/types/index.js.map +5 -4
  62. package/dist/utils/index.js.map +2 -2
  63. package/dist/voice/index.d.ts +116 -0
  64. package/dist/voice/index.js +261 -10
  65. package/dist/voice/index.js.map +3 -3
  66. package/dist/ws/close-codes.d.ts +23 -0
  67. package/dist/ws/decoder.d.ts +58 -0
  68. package/dist/ws/heartbeat.d.ts +87 -0
  69. package/dist/ws/index.d.ts +24 -32
  70. package/dist/ws/index.js +920 -318
  71. package/dist/ws/index.js.map +15 -5
  72. package/dist/ws/opcodes.d.ts +14 -0
  73. package/dist/ws/protocol.d.ts +110 -0
  74. package/dist/ws/reconnect.d.ts +108 -0
  75. package/dist/ws/send-budget.d.ts +17 -0
  76. package/dist/ws/session.d.ts +100 -0
  77. package/dist/ws/state.d.ts +27 -0
  78. package/dist/ws/transport.d.ts +80 -0
  79. package/package.json +23 -22
  80. package/dist/structures/permissions.d.ts +0 -73
@@ -0,0 +1,108 @@
1
+ /** What a closed connection should do next. */
2
+ export type CloseAction =
3
+ /** Reconnect and RESUME the existing session. */
4
+ "resume"
5
+ /** Reconnect, but IDENTIFY afresh: the session cannot be resumed. */
6
+ | "identify"
7
+ /** Do not reconnect; the condition will not fix itself. */
8
+ | "stop";
9
+ /**
10
+ * Close codes that no reconnect can recover from: bad token, bad shard
11
+ * configuration, bad API version, or intents the application is not approved
12
+ * for. Retrying these hammers Discord with a request that cannot succeed.
13
+ */
14
+ export declare const FATAL_CLOSE_CODES: readonly number[];
15
+ /**
16
+ * Close codes that keep the connection recoverable but destroy the session, so
17
+ * the next connection must IDENTIFY rather than RESUME.
18
+ */
19
+ export declare const IDENTIFY_CLOSE_CODES: readonly number[];
20
+ /**
21
+ * Classifies a close code.
22
+ *
23
+ * Any code outside the two tables above is **reconnectable**: transport-level
24
+ * closes (`1006`), server restarts (`1001`), Discord's own `4000`, and the
25
+ * `1000` the Gateway itself sends after a non-resumable `op 9` all belong here.
26
+ * Whether that reconnect resumes or identifies is not a property of the code —
27
+ * it is whether a session survives, which is why `canResume` is a parameter
28
+ * rather than something this module works out for itself.
29
+ *
30
+ * @param code WebSocket close code.
31
+ * @param canResume Whether the session can still be resumed.
32
+ */
33
+ export declare function classifyCloseCode(code: number, canResume: boolean): CloseAction;
34
+ /** Why a reconnect was not scheduled. */
35
+ export type ScheduleRefusal =
36
+ /** Automatic reconnect is disabled for this Gateway. */
37
+ "disabled"
38
+ /** A reconnect is already armed; a second would open a second socket. */
39
+ | "pending"
40
+ /** The attempt budget is spent. */
41
+ | "exhausted";
42
+ /** Outcome of asking for a reconnect. */
43
+ export type ScheduleResult = {
44
+ scheduled: true;
45
+ delayMs: number;
46
+ attempt: number;
47
+ } | {
48
+ scheduled: false;
49
+ reason: ScheduleRefusal;
50
+ };
51
+ /** Configuration for {@link GatewayReconnect}. */
52
+ export interface ReconnectOptions {
53
+ /** Whether automatic reconnect is permitted at all. */
54
+ enabled: boolean;
55
+ /** Maximum consecutive attempts before giving up. */
56
+ maxAttempts: number;
57
+ /** Delay for the first attempt, doubled per attempt. */
58
+ baseDelay: number;
59
+ /** Ceiling for the backoff. */
60
+ maxDelay: number;
61
+ /** Randomness source for jitter; injected in tests. */
62
+ random?: () => number;
63
+ }
64
+ /** Reconnect scheduling, backoff and attempt coordination. */
65
+ export declare class GatewayReconnect {
66
+ #private;
67
+ constructor(options: ReconnectOptions);
68
+ /** Whether automatic reconnect is permitted. */
69
+ get enabled(): boolean;
70
+ /** Consecutive attempts made since the last {@link reset}. */
71
+ get attempts(): number;
72
+ /** Whether a reconnect timer is currently armed. */
73
+ get pending(): boolean;
74
+ /** Whether the attempt budget is spent. */
75
+ get exhausted(): boolean;
76
+ /** Whether a connection attempt is currently in flight. */
77
+ get connecting(): boolean;
78
+ /** The in-flight attempt, or undefined when none is active. */
79
+ get attemptPromise(): Promise<void> | undefined;
80
+ /** Classifies a close code against this Gateway's policy. */
81
+ classifyClose(code: number, canResume: boolean): CloseAction;
82
+ /** Whether another reconnect is currently allowed. */
83
+ canReconnect(): boolean;
84
+ /**
85
+ * Arms a reconnect, unless one is already armed or no attempt is allowed.
86
+ *
87
+ * Refusing while `pending` is what keeps repeated closes from stacking
88
+ * timers: several closes in a row produce one reconnect, not several
89
+ * competing sockets.
90
+ */
91
+ schedule(run: () => void): ScheduleResult;
92
+ /** Cancels an armed reconnect. Safe to call when none is armed. */
93
+ cancel(): void;
94
+ /** Clears the attempt counter after a connection succeeds. */
95
+ reset(): void;
96
+ /**
97
+ * Coordinates one logical connection attempt.
98
+ *
99
+ * Callers that ask while an attempt is in flight join it instead of
100
+ * starting a second: three `connect()` calls produce one socket attempt and
101
+ * one shared promise.
102
+ *
103
+ * @param start Invoked exactly once, when this call begins a new attempt.
104
+ */
105
+ attempt(start: () => void): Promise<void>;
106
+ /** Settles the in-flight attempt, resolving it or rejecting with `error`. */
107
+ settle(error?: Error): void;
108
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Sliding-window budget for outgoing Gateway payloads.
3
+ *
4
+ * Discord allows 120 sends per 60 seconds. Application traffic is capped at
5
+ * 115 so the remaining headroom is reserved for privileged sends (heartbeats),
6
+ * which are still recorded so the true total stays under Discord's limit.
7
+ */
8
+ export declare class SendBudget {
9
+ #private;
10
+ constructor(limit?: number, windowMs?: number);
11
+ /** Sends recorded within the current window. */
12
+ get used(): number;
13
+ /** Whether a send may go out now. Privileged sends always may. */
14
+ allows(privileged: boolean, now?: number): boolean;
15
+ /** Records a send that went out. */
16
+ record(now?: number): void;
17
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Identity of a Discord Gateway session, and the decision of how to open the
3
+ * next connection with it.
4
+ *
5
+ * Deliberately owns nothing else: no socket, no timers, no opcode dispatch, no
6
+ * compression, no event emission. Those belong to the transport, heartbeat,
7
+ * reconnect and protocol seams. Keeping this object small is the point —
8
+ * session confusion is what produced both WS-001 and WS-005.
9
+ */
10
+ /** Everything needed to send a RESUME, or nothing when one is impossible. */
11
+ export interface ResumeInfo {
12
+ /** Discord's session identifier from READY. */ sessionId: string;
13
+ /** Last sequence number observed on this session. */ sequence: number;
14
+ /** Host READY nominated for resuming this session. */ resumeURL: string;
15
+ }
16
+ /**
17
+ * What the next connection must do.
18
+ *
19
+ * A discriminated union rather than a boolean plus three nullable fields: the
20
+ * caller cannot reach for a session id on the identify branch, so "resume with
21
+ * an undefined session" is not a state this codebase can express.
22
+ */
23
+ export type HandshakeIntent = ({
24
+ type: "resume";
25
+ } & ResumeInfo) | {
26
+ type: "identify";
27
+ };
28
+ /** Why a session was discarded. */
29
+ export type InvalidationReason =
30
+ /** Discord sent `op 9` with `d: false`. */
31
+ "invalid-session"
32
+ /** The connection closed with a code that forbids resuming. */
33
+ | "session-timeout"
34
+ /** Discarded by the owner without a protocol cause. */
35
+ | "explicit";
36
+ /**
37
+ * Session state for one Gateway shard.
38
+ *
39
+ * **Generations.** Every connection attempt takes a token from
40
+ * {@link GatewaySession.beginConnection}, and every mutation must present it.
41
+ * A socket that has been superseded still holds the old token, so a late
42
+ * dispatch arriving on it cannot advance the new connection's sequence or
43
+ * overwrite its session id. Ownership is therefore structural rather than a
44
+ * chain of `if (this.#ws === ws)` checks at each call site.
45
+ */
46
+ export declare class GatewaySession {
47
+ #private;
48
+ /** Why the last session was discarded, for diagnostics and reconnect policy. */
49
+ get lastInvalidation(): InvalidationReason | undefined;
50
+ /** Token of the current connection attempt; mutations must match it. */
51
+ get generation(): number;
52
+ /** Discord's session id, or undefined when no session is established. */
53
+ get sessionId(): string | undefined;
54
+ /** Host to reconnect to for a RESUME, or undefined when none is known. */
55
+ get resumeURL(): string | undefined;
56
+ /**
57
+ * Last sequence number seen, or null when none has been observed.
58
+ *
59
+ * Null, never zero, marks "nothing seen": sequence `0` is a legitimate
60
+ * value that must survive into a RESUME.
61
+ */
62
+ get sequence(): number | null;
63
+ /** Whether a RESUME is possible: a session, a resume host, and a sequence. */
64
+ get canResume(): boolean;
65
+ /**
66
+ * Opens a new connection generation and returns its token.
67
+ *
68
+ * The session itself is untouched: reconnecting to resume must keep the
69
+ * session id and sequence. Only ownership moves.
70
+ */
71
+ beginConnection(): number;
72
+ /** Whether `token` still owns this session. */
73
+ owns(token: number): boolean;
74
+ /**
75
+ * Records a sequence number from a payload.
76
+ * @returns Whether the token owned the session and the value was stored.
77
+ */
78
+ recordSequence(sequence: number, token: number): boolean;
79
+ /**
80
+ * Establishes the session from a READY payload.
81
+ * @returns Whether the token owned the session and READY was well-formed.
82
+ */
83
+ activate(payload: unknown, token: number): boolean;
84
+ /**
85
+ * Discards the session so the next connection must IDENTIFY.
86
+ *
87
+ * Resumable invalidation (`op 9` with `d: true`) is *not* an invalidation:
88
+ * the session survives and the caller simply reconnects, so this is only
89
+ * called for the non-resumable cases.
90
+ *
91
+ * @returns Whether the token owned the session and state was discarded.
92
+ */
93
+ invalidate(token: number, reason?: InvalidationReason): boolean;
94
+ /** Resume material, or undefined when a RESUME is not possible. */
95
+ resumeInfo(): ResumeInfo | undefined;
96
+ /** What the next connection must send: RESUME with material, or IDENTIFY. */
97
+ handshake(): HandshakeIntent;
98
+ /** Host the next connection should dial: the resume host, else `fallback`. */
99
+ connectURL(fallback: string): string;
100
+ }
@@ -0,0 +1,27 @@
1
+ /** Gateway connection lifecycle states. */
2
+ export declare enum GatewayState {
3
+ /** Initial connection state. */ Connect = "CONNECT",
4
+ /** Gateway HELLO received state. */ Hello = "HELLO",
5
+ /** IDENTIFY operation in progress. */ Identify = "IDENTIFY",
6
+ /** RESUME operation in progress. */ Resume = "RESUME",
7
+ /** Gateway READY state. */ Ready = "READY",
8
+ /** Gateway dispatch processing state. */ Dispatch = "DISPATCH",
9
+ /** Heartbeat processing state. */ Heartbeat = "HEARTBEAT",
10
+ /** Reconnect in progress. */ Reconnect = "RECONNECT",
11
+ /** Gateway is permanently closed. */ Closed = "CLOSED"
12
+ }
13
+ /**
14
+ * Discord.js-familiar alias for {@link GatewayState}.
15
+ *
16
+ * Discord.js exposes connection status via a `Status` enum. Lunibee's canonical
17
+ * name is {@link GatewayState}; this is an additive alias so `discord.js` users
18
+ * find the expected name. Note the *values* remain Lunibee's string states
19
+ * (e.g. `"READY"`), not Discord.js's numeric `Status` members — an intentional
20
+ * divergence documented in the compatibility matrix.
21
+ */
22
+ export { GatewayState as Status };
23
+ /** Gateway protocol error. */
24
+ export declare class GatewayError extends Error {
25
+ /** Gateway close/error code. */ readonly code?: number;
26
+ /** Creates a Gateway error. @param message Error message. @param code Optional Gateway code. @param options Optional error metadata. */ constructor(message: string, code?: number, options?: ErrorOptions);
27
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The WebSocket a Gateway connection runs on.
3
+ *
4
+ * Owns socket construction, listener wiring, sending, closing, and replacement.
5
+ * It is infrastructure, not Discord semantics: it never inspects an opcode, a
6
+ * session, or a heartbeat. Frames go out as text and come back as text.
7
+ */
8
+ import { type GatewayDecoder } from "./decoder.js";
9
+ /** Creates the underlying socket. Injected to support alternative runtimes. */
10
+ export type SocketFactory = (url: string) => WebSocket;
11
+ /** Callbacks a transport reports to its owner. */
12
+ export interface TransportHandlers {
13
+ /** The socket opened and is ready to send. */
14
+ onOpen: () => void;
15
+ /** A complete frame arrived, already decompressed. */
16
+ onFrame: (raw: string) => void;
17
+ /** The socket closed. */
18
+ onClose: (code: number, reason: string) => void;
19
+ /** A socket or decoding failure. Not a close on its own. */
20
+ onError: (error: Error) => void;
21
+ }
22
+ /** Outcome of opening a connection. */
23
+ export type ConnectResult = {
24
+ ok: true;
25
+ } | {
26
+ ok: false;
27
+ error: Error;
28
+ };
29
+ /** Configuration for {@link WebSocketTransport}. */
30
+ export interface TransportOptions {
31
+ /** Handlers for this transport's lifetime. */
32
+ handlers: TransportHandlers;
33
+ /** Frame decoder. Defaults to plain text, or zlib-stream when compressing. */
34
+ decoder?: GatewayDecoder;
35
+ /** Whether the connection negotiates `zlib-stream` compression. */
36
+ compress?: boolean;
37
+ /** Socket constructor. Defaults to the ambient `WebSocket`. */
38
+ createSocket?: SocketFactory;
39
+ }
40
+ /**
41
+ * A replaceable WebSocket connection.
42
+ *
43
+ * **Generations.** Each {@link connect} takes a generation, and every event is
44
+ * checked against the current one. A socket that has been replaced still holds
45
+ * its listeners and can still fire — especially a frame that finishes
46
+ * decompressing after the swap — and every such event is dropped. The owner
47
+ * therefore never has to ask "is this still my socket?".
48
+ */
49
+ export declare class WebSocketTransport {
50
+ #private;
51
+ constructor(options: TransportOptions);
52
+ /** Whether a socket is open and able to send. */
53
+ get connected(): boolean;
54
+ /** Whether a socket is connecting or open, and therefore still in play. */
55
+ get live(): boolean;
56
+ /** Current connection generation; increments on every {@link connect}. */
57
+ get generation(): number;
58
+ /**
59
+ * Opens a connection, replacing any existing one.
60
+ *
61
+ * A construction failure is returned rather than reported through
62
+ * `onError`: the caller is mid-`connect` and must decide what the failure
63
+ * means for the attempt it is running.
64
+ */
65
+ connect(url: string): ConnectResult;
66
+ /**
67
+ * Writes a frame.
68
+ * @returns Whether it reached the socket.
69
+ */
70
+ send(data: string): boolean;
71
+ /** Closes the current socket, if any. Its `close` event still fires. */
72
+ close(code?: number, reason?: string): void;
73
+ /**
74
+ * Abandons the current socket without reporting its close.
75
+ *
76
+ * Used for a deliberate shutdown, where the owner has already decided the
77
+ * connection is over and must not be woken by the resulting close event.
78
+ */
79
+ destroy(code?: number, reason?: string): void;
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lunibee",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A lightweight, Bun-first Discord API library.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -88,37 +88,38 @@
88
88
  "scripts": {
89
89
  "build": "bun scripts/build.ts",
90
90
  "build:dts": "bun scripts/build-dts.ts",
91
- "format": "npx prettier --write packages/*/src/**/*.ts tests/**/*.ts",
91
+ "format": "prettier --write \"packages/*/src/**/*.ts\" \"tests/**/*.ts\"",
92
+ "format:check": "prettier --check \"packages/*/src/**/*.ts\" \"tests/**/*.ts\"",
92
93
  "check:deps": "bun scripts/check-dependency-graph.ts",
94
+ "audit:api": "bun scripts/api-audit.ts",
93
95
  "typecheck": "bunx tsc --noEmit --project tsconfig.json",
94
96
  "ci:install": "bun install --frozen-lockfile",
95
97
  "ci:deps": "bun run check:deps",
96
98
  "ci:typecheck": "bun run typecheck",
97
- "ci:test": "bun test --coverage",
98
- "ci": "bun run ci:deps && bun run ci:typecheck && bun run ci:test",
99
- "bench": "bun benchmarks/full.ts",
100
- "bench:compare": "bun benchmarks/compare.ts",
101
- "bench:stress": "bun benchmarks/stress.ts",
102
- "prepare": "bun run build && bun run build:dts",
99
+ "ci:test": "bun test --coverage && bun test ./packages/testing/src",
100
+ "ci": "bun run ci:deps && bun run audit:api && bun run format:check && bun run ci:typecheck && bun run ci:test",
101
+ "bench": "bun benchmarks/parity.ts",
102
+ "build:all": "bun run build && bun run build:dts",
103
103
  "publish:all": "bun run scripts/publish.ts"
104
104
  },
105
105
  "dependencies": {
106
- "@lunibee/builders": "^0.1.6",
107
- "@lunibee/collection": "^0.1.6",
108
- "@lunibee/core": "^0.1.6",
109
- "@lunibee/formatters": "^0.1.6",
110
- "@lunibee/handlers": "^0.1.6",
111
- "@lunibee/managers": "^0.1.6",
112
- "@lunibee/rest": "^0.1.6",
113
- "@lunibee/sharding": "^0.1.6",
114
- "@lunibee/structures": "^0.1.6",
115
- "@lunibee/types": "^0.1.6",
116
- "@lunibee/utils": "^0.1.6",
117
- "@lunibee/voice": "^0.1.6",
118
- "@lunibee/ws": "^0.1.6"
106
+ "@lunibee/builders": "^0.1.8",
107
+ "@lunibee/collection": "^0.1.8",
108
+ "@lunibee/core": "^0.1.8",
109
+ "@lunibee/formatters": "^0.1.8",
110
+ "@lunibee/handlers": "^0.1.8",
111
+ "@lunibee/managers": "^0.1.8",
112
+ "@lunibee/rest": "^0.1.8",
113
+ "@lunibee/sharding": "^0.1.8",
114
+ "@lunibee/structures": "^0.1.8",
115
+ "@lunibee/types": "^0.1.8",
116
+ "@lunibee/utils": "^0.1.8",
117
+ "@lunibee/voice": "^0.1.8",
118
+ "@lunibee/ws": "^0.1.8"
119
119
  },
120
120
  "devDependencies": {
121
- "@types/bun": "^1.4.0",
121
+ "@types/bun": "^1.4.1",
122
+ "prettier": "^3.9.9",
122
123
  "typescript": "^7.0.2"
123
124
  },
124
125
  "engines": {
@@ -1,73 +0,0 @@
1
- /** Permission bit values exposed by Discord. */
2
- export declare const Permissions: {
3
- /** Create instant invite permission. */ readonly CreateInstantInvite: bigint;
4
- /** Kick members permission. */ readonly KickMembers: bigint;
5
- /** Ban members permission. */ readonly BanMembers: bigint;
6
- /** Administrator permission. */ readonly Administrator: bigint;
7
- /** Manage channels permission. */ readonly ManageChannels: bigint;
8
- /** Manage guild permission. */ readonly ManageGuild: bigint;
9
- /** Add reactions permission. */ readonly AddReactions: bigint;
10
- /** View audit log permission. */ readonly ViewAuditLog: bigint;
11
- /** Priority speaker permission. */ readonly PrioritySpeaker: bigint;
12
- /** Stream permission. */ readonly Stream: bigint;
13
- /** View channel permission. */ readonly ViewChannel: bigint;
14
- /** Send messages permission. */ readonly SendMessages: bigint;
15
- /** Send TTS messages permission. */ readonly SendTTSMessages: bigint;
16
- /** Manage messages permission. */ readonly ManageMessages: bigint;
17
- /** Embed links permission. */ readonly EmbedLinks: bigint;
18
- /** Attach files permission. */ readonly AttachFiles: bigint;
19
- /** Read message history permission. */ readonly ReadMessageHistory: bigint;
20
- /** Mention everyone permission. */ readonly MentionEveryone: bigint;
21
- /** Use external emojis permission. */ readonly UseExternalEmojis: bigint;
22
- /** View guild insights permission. */ readonly ViewGuildInsights: bigint;
23
- /** Connect permission. */ readonly Connect: bigint;
24
- /** Speak permission. */ readonly Speak: bigint;
25
- /** Mute members permission. */ readonly MuteMembers: bigint;
26
- /** Deafen members permission. */ readonly DeafenMembers: bigint;
27
- /** Move members permission. */ readonly MoveMembers: bigint;
28
- /** Use voice activity detection permission. */ readonly UseVAD: bigint;
29
- /** Change nickname permission. */ readonly ChangeNickname: bigint;
30
- /** Manage nicknames permission. */ readonly ManageNicknames: bigint;
31
- /** Manage roles permission. */ readonly ManageRoles: bigint;
32
- /** Manage webhooks permission. */ readonly ManageWebhooks: bigint;
33
- /** Manage guild expressions permission. */ readonly ManageGuildExpressions: bigint;
34
- /** Use application commands permission. */ readonly UseApplicationCommands: bigint;
35
- /** Request to speak permission. */ readonly RequestToSpeak: bigint;
36
- /** Manage events permission. */ readonly ManageEvents: bigint;
37
- /** Manage threads permission. */ readonly ManageThreads: bigint;
38
- /** Create public threads permission. */ readonly CreatePublicThreads: bigint;
39
- /** Create private threads permission. */ readonly CreatePrivateThreads: bigint;
40
- /** Use external stickers permission. */ readonly UseExternalStickers: bigint;
41
- /** Send messages in threads permission. */ readonly SendMessagesInThreads: bigint;
42
- /** Use embedded activities permission. */ readonly UseEmbeddedActivities: bigint;
43
- /** Moderate members permission. */ readonly ModerateMembers: bigint;
44
- /** View creator monetization analytics permission. */ readonly ViewCreatorMonetizationAnalytics: bigint;
45
- /** Use soundboard permission. */ readonly UseSoundboard: bigint;
46
- /** Create guild expressions permission. */ readonly CreateGuildExpressions: bigint;
47
- /** Create events permission. */ readonly CreateEvents: bigint;
48
- /** Use external sounds permission. */ readonly UseExternalSounds: bigint;
49
- /** Send voice messages permission. */ readonly SendVoiceMessages: bigint;
50
- /** Send polls permission. */ readonly SendPolls: bigint;
51
- /** Use external apps permission. */ readonly UseExternalApps: bigint;
52
- };
53
- /** Public permission resolvable. */
54
- export type PermissionResolvable = bigint | number | string | PermissionName | PermissionSet | PermissionResolvable[];
55
- /** Immutable Discord permission bitfield. */
56
- export declare class PermissionSet {
57
- #private;
58
- /** Permission bitfield. */ readonly bitfield: bigint;
59
- /** Creates a permission set. @param value Initial permission bitfield. @throws {RangeError} If the value is negative. @throws {TypeError} If the value is not a valid integer. */
60
- constructor(value?: PermissionResolvable);
61
- /** Checks whether all supplied permissions are present. @param permissions Permission names or raw bits. @returns True when every requested permission is present. */ has(...permissions: PermissionResolvable[]): boolean;
62
- /** Checks whether any supplied permission is present. @param permissions Permission names or raw bits. @returns True when at least one requested permission is present. */ any(...permissions: PermissionResolvable[]): boolean;
63
- /** Returns a new set with permissions added. @param permissions Permission names or raw bits. @returns A new permission set. */ add(...permissions: PermissionResolvable[]): PermissionSet;
64
- /** Returns a new set with permissions removed. @param permissions Permission names or raw bits. @returns A new permission set. */ remove(...permissions: PermissionResolvable[]): PermissionSet;
65
- /** Checks equality with another permission set or raw bitfield. @param other Permission set or raw bitfield. @returns True when both values are equal. */ equals(other: PermissionSet | bigint | number | string): boolean;
66
- /** Returns the decimal permission representation. @returns Decimal permission bitfield. */ toString(): string;
67
- /** Returns known permission names contained in this set. @returns Names of all enabled known permissions. */ toArray(): PermissionName[];
68
- }
69
- /** Discord.js-compatible permission bitfield. */
70
- export declare class PermissionsBitField extends PermissionSet {
71
- /** Creates a permissions bitfield. @param value Initial permission bitfield. */
72
- constructor(value?: PermissionResolvable);
73
- }