seyfert 2.1.1-dev-11318571086.0 → 2.1.1-dev-11388830407.0
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.
- package/lib/api/api.d.ts +3 -1
- package/lib/api/api.js +2 -0
- package/lib/client/client.d.ts +1 -1
- package/lib/client/client.js +1 -2
- package/lib/client/workerclient.d.ts +1 -1
- package/lib/client/workerclient.js +23 -26
- package/lib/commands/applications/chatcontext.d.ts +5 -1
- package/lib/commands/applications/entrycontext.d.ts +5 -1
- package/lib/commands/applications/menucontext.d.ts +5 -1
- package/lib/commands/handler.js +2 -2
- package/lib/components/componentcontext.d.ts +5 -1
- package/lib/components/modalcontext.d.ts +5 -1
- package/lib/structures/extra/BitField.d.ts +1 -1
- package/lib/structures/extra/BitField.js +22 -14
- package/lib/structures/extra/Permissions.d.ts +2 -2
- package/lib/structures/extra/Permissions.js +24 -16
- package/package.json +3 -3
package/lib/api/api.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Logger } from '../common';
|
|
1
|
+
import { type Awaitable, Logger } from '../common';
|
|
2
2
|
import type { APIRoutes } from './Routes';
|
|
3
3
|
import { Bucket } from './bucket';
|
|
4
4
|
import { type ApiHandlerInternalOptions, type ApiHandlerOptions, type ApiRequestOptions, type HttpMethods, type RawFile, type RequestHeaders } from './shared';
|
|
5
5
|
export interface ApiHandler {
|
|
6
6
|
debugger?: Logger;
|
|
7
7
|
}
|
|
8
|
+
export type OnRatelimitCallback = (response: Response, request: ApiRequestOptions) => Awaitable<any>;
|
|
8
9
|
export declare class ApiHandler {
|
|
9
10
|
#private;
|
|
10
11
|
options: ApiHandlerInternalOptions;
|
|
@@ -16,6 +17,7 @@ export declare class ApiHandler {
|
|
|
16
17
|
resolve: (value: any) => any;
|
|
17
18
|
reject: (error: any) => any;
|
|
18
19
|
}>;
|
|
20
|
+
onRatelimit?: OnRatelimitCallback;
|
|
19
21
|
constructor(options: ApiHandlerOptions);
|
|
20
22
|
get proxy(): APIRoutes;
|
|
21
23
|
globalUnblock(): void;
|
package/lib/api/api.js
CHANGED
|
@@ -16,6 +16,7 @@ class ApiHandler {
|
|
|
16
16
|
readyQueue = [];
|
|
17
17
|
cdn = Router_1.CDNRouter.createProxy();
|
|
18
18
|
workerPromises;
|
|
19
|
+
onRatelimit;
|
|
19
20
|
constructor(options) {
|
|
20
21
|
this.options = {
|
|
21
22
|
baseUrl: 'api/v10',
|
|
@@ -198,6 +199,7 @@ class ApiHandler {
|
|
|
198
199
|
});
|
|
199
200
|
}
|
|
200
201
|
async handle429(route, method, url, request, response, result, next, reject, now) {
|
|
202
|
+
await this.onRatelimit?.(response, request);
|
|
201
203
|
const content = `${JSON.stringify(request)} `;
|
|
202
204
|
let retryAfter = Number(response.headers.get('x-ratelimit-reset-after') || response.headers.get('retry-after')) * 1000;
|
|
203
205
|
if (Number.isNaN(retryAfter)) {
|
package/lib/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CommandContext, Message } from '..';
|
|
2
2
|
import { type Awaitable, type DeepPartial, type If } from '../common';
|
|
3
3
|
import { EventHandler } from '../events';
|
|
4
|
-
import {
|
|
4
|
+
import type { GatewayDispatchPayload, GatewayPresenceUpdateData } from '../types';
|
|
5
5
|
import { ShardManager, type ShardManagerOptions } from '../websocket';
|
|
6
6
|
import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
|
|
7
7
|
import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
|
package/lib/client/client.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Client = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const events_1 = require("../events");
|
|
6
|
-
const types_1 = require("../types");
|
|
7
6
|
const websocket_1 = require("../websocket");
|
|
8
7
|
const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
|
|
9
8
|
const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
|
|
@@ -164,7 +163,7 @@ class Client extends base_1.BaseClient {
|
|
|
164
163
|
this.botId = packet.d.user.id;
|
|
165
164
|
this.applicationId = packet.d.application.id;
|
|
166
165
|
this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
|
|
167
|
-
if (!
|
|
166
|
+
if (!this.__handleGuilds.length) {
|
|
168
167
|
if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
169
168
|
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
|
170
169
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DeepPartial, type When } from '../common';
|
|
2
2
|
import { EventHandler } from '../events';
|
|
3
|
-
import {
|
|
3
|
+
import type { GatewayDispatchPayload } from '../types';
|
|
4
4
|
import { Shard, type ShardManagerOptions, type WorkerData } from '../websocket';
|
|
5
5
|
import type { WorkerMessage, WorkerShardInfo } from '../websocket/discord/worker';
|
|
6
6
|
import type { ManagerMessages } from '../websocket/discord/workermanager';
|
|
@@ -7,7 +7,6 @@ const __1 = require("..");
|
|
|
7
7
|
const cache_1 = require("../cache");
|
|
8
8
|
const common_1 = require("../common");
|
|
9
9
|
const events_1 = require("../events");
|
|
10
|
-
const types_1 = require("../types");
|
|
11
10
|
const websocket_1 = require("../websocket");
|
|
12
11
|
const base_1 = require("./base");
|
|
13
12
|
const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
|
|
@@ -34,7 +33,7 @@ catch {
|
|
|
34
33
|
//
|
|
35
34
|
}
|
|
36
35
|
class WorkerClient extends base_1.BaseClient {
|
|
37
|
-
__handleGuilds
|
|
36
|
+
__handleGuilds;
|
|
38
37
|
__handleGuildsResharding;
|
|
39
38
|
memberUpdateHandler = new memberUpdate_1.MemberUpdateHandler();
|
|
40
39
|
presenceUpdateHandler = new presenceUpdate_1.PresenceUpdateHandler();
|
|
@@ -122,7 +121,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
122
121
|
workerId: workerData.workerId,
|
|
123
122
|
});
|
|
124
123
|
if (workerData.resharding) {
|
|
125
|
-
this.__handleGuildsResharding =
|
|
124
|
+
this.__handleGuildsResharding = [];
|
|
126
125
|
}
|
|
127
126
|
await super.start(options);
|
|
128
127
|
await this.loadEvents(options.eventsDir);
|
|
@@ -211,23 +210,24 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
211
210
|
},
|
|
212
211
|
handlePayload(_, payload) {
|
|
213
212
|
if (payload.t === 'GUILD_CREATE' || payload.t === 'GUILD_DELETE') {
|
|
214
|
-
self.__handleGuildsResharding.
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
self.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
const indexOf = self.__handleGuildsResharding.indexOf(payload.d.id);
|
|
214
|
+
if (indexOf !== -1) {
|
|
215
|
+
self.__handleGuildsResharding.splice(indexOf, 1);
|
|
216
|
+
if (!self.__handleGuildsResharding?.length && shardsConnected === workerData.shards.length) {
|
|
217
|
+
delete self.__handleGuildsResharding;
|
|
218
|
+
self.postMessage({
|
|
219
|
+
type: 'WORKER_READY_RESHARDING',
|
|
220
|
+
workerId: workerData.workerId,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
221
223
|
}
|
|
222
224
|
}
|
|
223
225
|
if (payload.t !== 'READY')
|
|
224
226
|
return;
|
|
225
227
|
shardsConnected++;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (shardsConnected === workerData.shards.length &&
|
|
230
|
-
!(0, common_1.hasIntent)(workerData.intents, types_1.GatewayIntentBits.Guilds)) {
|
|
228
|
+
const ids = payload.d.guilds.map(x => x.id);
|
|
229
|
+
self.__handleGuildsResharding = self.__handleGuildsResharding?.concat(ids) ?? ids;
|
|
230
|
+
if (shardsConnected === workerData.shards.length && !self.__handleGuildsResharding.length) {
|
|
231
231
|
delete self.__handleGuildsResharding;
|
|
232
232
|
self.postMessage({
|
|
233
233
|
type: 'WORKER_READY_RESHARDING',
|
|
@@ -357,7 +357,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
357
357
|
break;
|
|
358
358
|
case 'WORKER_ALREADY_EXISTS_RESHARDING':
|
|
359
359
|
{
|
|
360
|
-
this.__handleGuildsResharding =
|
|
360
|
+
this.__handleGuildsResharding = [];
|
|
361
361
|
this.postMessage({
|
|
362
362
|
type: 'WORKER_START_RESHARDING',
|
|
363
363
|
workerId: workerData.workerId,
|
|
@@ -442,9 +442,9 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
442
442
|
break;
|
|
443
443
|
case 'GUILD_DELETE':
|
|
444
444
|
case 'GUILD_CREATE': {
|
|
445
|
-
if (this.__handleGuilds?.
|
|
446
|
-
this.__handleGuilds?.
|
|
447
|
-
if (!this.__handleGuilds?.
|
|
445
|
+
if (this.__handleGuilds?.includes(packet.d.id)) {
|
|
446
|
+
this.__handleGuilds?.splice(this.__handleGuilds.indexOf(packet.d.id), 1);
|
|
447
|
+
if (!this.__handleGuilds?.length && [...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
448
448
|
delete this.__handleGuilds;
|
|
449
449
|
await this.cache.onPacket(packet);
|
|
450
450
|
this.postMessage({
|
|
@@ -453,7 +453,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
453
453
|
});
|
|
454
454
|
return this.events?.runEvent('WORKER_READY', this, this.me, -1);
|
|
455
455
|
}
|
|
456
|
-
if (!this.__handleGuilds?.
|
|
456
|
+
if (!this.__handleGuilds?.length)
|
|
457
457
|
delete this.__handleGuilds;
|
|
458
458
|
return this.cache.onPacket(packet);
|
|
459
459
|
}
|
|
@@ -476,11 +476,8 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
476
476
|
break;
|
|
477
477
|
case 'READY':
|
|
478
478
|
{
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
for (const g of packet.d.guilds) {
|
|
482
|
-
this.__handleGuilds?.add(g.id);
|
|
483
|
-
}
|
|
479
|
+
const ids = packet.d.guilds.map(x => x.id);
|
|
480
|
+
this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
|
|
484
481
|
this.botId = packet.d.user.id;
|
|
485
482
|
this.applicationId = packet.d.application.id;
|
|
486
483
|
this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
|
|
@@ -493,7 +490,7 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
493
490
|
});
|
|
494
491
|
await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1);
|
|
495
492
|
}
|
|
496
|
-
if (!
|
|
493
|
+
if (!this.__handleGuilds.length) {
|
|
497
494
|
if ([...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
498
495
|
this.postMessage({
|
|
499
496
|
type: 'WORKER_READY',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AllChannels, InferWithPrefix, ReturnCache } from '../..';
|
|
2
2
|
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, MessageStructure, OptionResolverStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
3
|
-
import type { If, UnionToTuple, When } from '../../common';
|
|
3
|
+
import type { If, MakeRequired, UnionToTuple, When } from '../../common';
|
|
4
4
|
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write';
|
|
5
5
|
import { ChatInputCommandInteraction } from '../../structures';
|
|
6
6
|
import { BaseContext } from '../basecontext';
|
|
@@ -44,3 +44,7 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
|
|
|
44
44
|
get member(): If<InferWithPrefix, GuildMemberStructure | InteractionGuildMemberStructure | undefined, InteractionGuildMemberStructure | undefined>;
|
|
45
45
|
isChat(): this is CommandContext;
|
|
46
46
|
}
|
|
47
|
+
export interface GuildCommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<CommandContext<T, M>, 'guildId'>, 'guild'> {
|
|
48
|
+
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
49
|
+
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
50
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReturnCache } from '../..';
|
|
2
2
|
import type { GuildMemberStructure, GuildStructure, MessageStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
3
|
-
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, ModalCreateBodyRequest, UnionToTuple, When } from '../../common';
|
|
3
|
+
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, ModalCreateBodyRequest, UnionToTuple, When } from '../../common';
|
|
4
4
|
import type { AllChannels, EntryPointInteraction } from '../../structures';
|
|
5
5
|
import { BaseContext } from '../basecontext';
|
|
6
6
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
@@ -38,3 +38,7 @@ export declare class EntryPointContext<M extends keyof RegisteredMiddlewares = n
|
|
|
38
38
|
get author(): import("../..").User;
|
|
39
39
|
get member(): import("../..").InteractionGuildMember | undefined;
|
|
40
40
|
}
|
|
41
|
+
export interface GuildEntryPointContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<EntryPointContext<M>, 'guildId'>, 'guild'> {
|
|
42
|
+
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
43
|
+
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
44
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContextMenuCommand, ReturnCache } from '../..';
|
|
2
2
|
import { type GuildMemberStructure, type GuildStructure, type MessageStructure, type UserStructure, type WebhookMessageStructure } from '../../client/transformers';
|
|
3
|
-
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type ModalCreateBodyRequest, type UnionToTuple, type When } from '../../common';
|
|
3
|
+
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type MakeRequired, type ModalCreateBodyRequest, type UnionToTuple, type When } from '../../common';
|
|
4
4
|
import type { AllChannels, MessageCommandInteraction, UserCommandInteraction } from '../../structures';
|
|
5
5
|
import { BaseContext } from '../basecontext';
|
|
6
6
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
@@ -42,3 +42,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
|
|
|
42
42
|
isMenuUser(): this is MenuCommandContext<UserCommandInteraction>;
|
|
43
43
|
isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
|
|
44
44
|
}
|
|
45
|
+
export interface GuildMenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<MenuCommandContext<T, M>, 'guildId'>, 'guild'> {
|
|
46
|
+
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
47
|
+
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
48
|
+
}
|
package/lib/commands/handler.js
CHANGED
|
@@ -474,8 +474,8 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
474
474
|
option.onPermissionsFail?.bind(option) ??
|
|
475
475
|
commandInstance.onPermissionsFail?.bind(commandInstance) ??
|
|
476
476
|
this.client.options.commands?.defaults?.onPermissionsFail;
|
|
477
|
-
option.botPermissions =
|
|
478
|
-
option.defaultMemberPermissions ??=
|
|
477
|
+
option.botPermissions = Permissions_1.PermissionsBitField.resolve(option.botPermissions ?? Permissions_1.PermissionsBitField.None, commandInstance.botPermissions ?? Permissions_1.PermissionsBitField.None);
|
|
478
|
+
option.defaultMemberPermissions ??= Permissions_1.PermissionsBitField.resolve(option.defaultMemberPermissions ?? Permissions_1.PermissionsBitField.None, commandInstance.defaultMemberPermissions ?? Permissions_1.PermissionsBitField.None);
|
|
479
479
|
option.contexts ??= commandInstance.contexts;
|
|
480
480
|
option.integrationTypes ??= commandInstance.integrationTypes;
|
|
481
481
|
option.props ??= commandInstance.props;
|
|
@@ -2,7 +2,7 @@ import type { AllChannels, ButtonInteraction, ChannelSelectMenuInteraction, Comp
|
|
|
2
2
|
import type { GuildMemberStructure, GuildStructure, MessageStructure, WebhookMessageStructure } from '../client/transformers';
|
|
3
3
|
import type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands';
|
|
4
4
|
import { BaseContext } from '../commands/basecontext';
|
|
5
|
-
import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, ModalCreateBodyRequest, UnionToTuple, When } from '../common';
|
|
5
|
+
import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, ModalCreateBodyRequest, UnionToTuple, When } from '../common';
|
|
6
6
|
export interface ComponentContext<Type extends keyof ContextComponentCommandInteractionMap = keyof ContextComponentCommandInteractionMap> extends BaseContext, ExtendContext {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
@@ -117,3 +117,7 @@ export interface ContextComponentCommandInteractionMap {
|
|
|
117
117
|
MentionableSelect: MentionableSelectMenuInteraction;
|
|
118
118
|
ChannelSelect: ChannelSelectMenuInteraction;
|
|
119
119
|
}
|
|
120
|
+
export interface GuildComponentContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<ComponentContext<M>, 'guildId'>, 'guild'> {
|
|
121
|
+
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
122
|
+
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
123
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { AllChannels, ModalCommand, ModalSubmitInteraction, ReturnCache } f
|
|
|
2
2
|
import type { GuildMemberStructure, GuildStructure, MessageStructure, WebhookMessageStructure } from '../client/transformers';
|
|
3
3
|
import type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands';
|
|
4
4
|
import { BaseContext } from '../commands/basecontext';
|
|
5
|
-
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, ModalCreateBodyRequest, UnionToTuple, When } from '../common';
|
|
5
|
+
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, ModalCreateBodyRequest, UnionToTuple, When } from '../common';
|
|
6
6
|
export interface ModalContext extends BaseContext, ExtendContext {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
@@ -103,3 +103,7 @@ export declare class ModalContext<M extends keyof RegisteredMiddlewares = never>
|
|
|
103
103
|
get member(): import("..").InteractionGuildMember | undefined;
|
|
104
104
|
isModal(): this is ModalContext;
|
|
105
105
|
}
|
|
106
|
+
export interface GuildModalContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<ModalContext<M>, 'guildId'>, 'guild'> {
|
|
107
|
+
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
108
|
+
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
109
|
+
}
|
|
@@ -13,5 +13,5 @@ export declare class BitField<T extends object> {
|
|
|
13
13
|
values(bits?: BitFieldResolvable<T>[]): bigint[];
|
|
14
14
|
add(...bits: (BitFieldResolvable<T> | undefined)[]): bigint;
|
|
15
15
|
remove(...bits: BitFieldResolvable<T>[]): bigint;
|
|
16
|
-
resolve(bits: BitFieldResolvable<T>): bigint;
|
|
16
|
+
resolve(...bits: BitFieldResolvable<T>[]): bigint;
|
|
17
17
|
}
|
|
@@ -60,23 +60,31 @@ class BitField {
|
|
|
60
60
|
}
|
|
61
61
|
return this.bits;
|
|
62
62
|
}
|
|
63
|
-
resolve(bits) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
resolve(...bits) {
|
|
64
|
+
let bitsResult = 0n;
|
|
65
|
+
for (const bit of bits) {
|
|
66
|
+
switch (typeof bit) {
|
|
67
|
+
case 'string':
|
|
68
|
+
bitsResult |= this.resolve(this.Flags[bit]);
|
|
69
|
+
break;
|
|
70
|
+
case 'number':
|
|
71
|
+
bitsResult |= BigInt(bit);
|
|
72
|
+
break;
|
|
73
|
+
case 'bigint':
|
|
74
|
+
bitsResult |= bit;
|
|
75
|
+
break;
|
|
76
|
+
case 'object': {
|
|
77
|
+
if (!Array.isArray(bit)) {
|
|
78
|
+
throw new TypeError(`Cannot resolve permission: ${bit}`);
|
|
79
|
+
}
|
|
80
|
+
bitsResult |= bits.reduce((acc, val) => this.resolve(val) | acc, BitField.None);
|
|
81
|
+
break;
|
|
74
82
|
}
|
|
75
|
-
|
|
83
|
+
default:
|
|
84
|
+
throw new TypeError(`Cannot resolve permission: ${typeof bit === 'symbol' ? String(bit) : bit}`);
|
|
76
85
|
}
|
|
77
|
-
default:
|
|
78
|
-
throw new TypeError(`Cannot resolve permission: ${typeof bits === 'symbol' ? String(bits) : bits}`);
|
|
79
86
|
}
|
|
87
|
+
return bitsResult;
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
exports.BitField = BitField;
|
|
@@ -59,6 +59,6 @@ export declare class PermissionsBitField extends BitField<typeof PermissionFlags
|
|
|
59
59
|
keys: (bits?: BitFieldResolvable<typeof PermissionFlagsBits>[]) => PermissionStrings;
|
|
60
60
|
has(...bits: BitFieldResolvable<typeof PermissionFlagsBits>[]): boolean;
|
|
61
61
|
strictHas(...bits: BitFieldResolvable<typeof PermissionFlagsBits>[]): boolean;
|
|
62
|
-
resolve<T extends typeof PermissionFlagsBits>(bits: BitFieldResolvable<T>): bigint;
|
|
63
|
-
static resolve<T extends typeof PermissionFlagsBits>(bits: BitFieldResolvable<T>): bigint;
|
|
62
|
+
resolve<T extends typeof PermissionFlagsBits>(...bits: BitFieldResolvable<T>[]): bigint;
|
|
63
|
+
static resolve<T extends typeof PermissionFlagsBits>(...bits: BitFieldResolvable<T>[]): bigint;
|
|
64
64
|
}
|
|
@@ -17,26 +17,34 @@ class PermissionsBitField extends BitField_1.BitField {
|
|
|
17
17
|
strictHas(...bits) {
|
|
18
18
|
return super.has(...bits);
|
|
19
19
|
}
|
|
20
|
-
resolve(bits) {
|
|
21
|
-
return PermissionsBitField.resolve(
|
|
20
|
+
resolve(...bits) {
|
|
21
|
+
return bits.reduce((acc, cur) => acc | PermissionsBitField.resolve(cur), BitField_1.BitField.None);
|
|
22
22
|
}
|
|
23
|
-
static resolve(bits) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
static resolve(...bits) {
|
|
24
|
+
let bitsResult = 0n;
|
|
25
|
+
for (const bit of bits) {
|
|
26
|
+
switch (typeof bit) {
|
|
27
|
+
case 'string':
|
|
28
|
+
bitsResult |= PermissionsBitField.resolve(types_1.PermissionFlagsBits[bit]);
|
|
29
|
+
break;
|
|
30
|
+
case 'number':
|
|
31
|
+
bitsResult |= BigInt(bit);
|
|
32
|
+
break;
|
|
33
|
+
case 'bigint':
|
|
34
|
+
bitsResult |= bit;
|
|
35
|
+
break;
|
|
36
|
+
case 'object': {
|
|
37
|
+
if (!Array.isArray(bit)) {
|
|
38
|
+
throw new TypeError(`Cannot resolve permission: ${bit}`);
|
|
39
|
+
}
|
|
40
|
+
bitsResult |= bit.reduce((acc, val) => PermissionsBitField.resolve(val) | acc, BitField_1.BitField.None);
|
|
41
|
+
break;
|
|
34
42
|
}
|
|
35
|
-
|
|
43
|
+
default:
|
|
44
|
+
throw new TypeError(`Cannot resolve permission: ${typeof bit === 'symbol' ? String(bit) : bit}`);
|
|
36
45
|
}
|
|
37
|
-
default:
|
|
38
|
-
throw new TypeError(`Cannot resolve permission: ${typeof bits === 'symbol' ? String(bits) : bits}`);
|
|
39
46
|
}
|
|
47
|
+
return bitsResult;
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
exports.PermissionsBitField = PermissionsBitField;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seyfert",
|
|
3
|
-
"version": "2.1.1-dev-
|
|
3
|
+
"version": "2.1.1-dev-11388830407.0",
|
|
4
4
|
"description": "The most advanced framework for discord bots",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"@biomejs/biome": "1.9.3",
|
|
25
25
|
"@commitlint/cli": "^19.5.0",
|
|
26
26
|
"@commitlint/config-conventional": "^19.5.0",
|
|
27
|
-
"@types/node": "^22.7.
|
|
27
|
+
"@types/node": "^22.7.6",
|
|
28
28
|
"husky": "^9.1.6",
|
|
29
29
|
"lint-staged": "^15.2.10",
|
|
30
30
|
"typescript": "^5.6.3",
|
|
31
|
-
"vitest": "^2.1.
|
|
31
|
+
"vitest": "^2.1.3"
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://seyfert.dev",
|
|
34
34
|
"repository": {
|