seyfert 2.1.1-dev-11318571086.0 → 2.1.1-dev-11319654918.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/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 +1 -1
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)) {
|
|
@@ -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;
|