seyfert 2.1.1-dev-11317998653.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/common/index.d.ts +1 -1
- package/lib/common/index.js +4 -1
- package/lib/common/it/logger.d.ts +25 -5
- package/lib/common/it/logger.js +45 -24
- 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;
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './it/constants';
|
|
2
2
|
export * from './it/utils';
|
|
3
3
|
export * from './it/colors';
|
|
4
|
-
export
|
|
4
|
+
export { CustomizeLoggerCallback, AssignFilenameCallback, LogLevels, Logger, LoggerOptions } from './it/logger';
|
|
5
5
|
export * from './it/formatter';
|
|
6
6
|
export * from './shorters/channels';
|
|
7
7
|
export * from './shorters/emojis';
|
package/lib/common/index.js
CHANGED
|
@@ -14,10 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Logger = exports.LogLevels = void 0;
|
|
17
18
|
__exportStar(require("./it/constants"), exports);
|
|
18
19
|
__exportStar(require("./it/utils"), exports);
|
|
19
20
|
__exportStar(require("./it/colors"), exports);
|
|
20
|
-
|
|
21
|
+
var logger_1 = require("./it/logger");
|
|
22
|
+
Object.defineProperty(exports, "LogLevels", { enumerable: true, get: function () { return logger_1.LogLevels; } });
|
|
23
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
21
24
|
__exportStar(require("./it/formatter"), exports);
|
|
22
25
|
//
|
|
23
26
|
__exportStar(require("./shorters/channels"), exports);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type WriteStream } from 'node:fs';
|
|
2
1
|
export declare enum LogLevels {
|
|
3
2
|
Debug = 0,
|
|
4
3
|
Info = 1,
|
|
@@ -12,7 +11,8 @@ export type LoggerOptions = {
|
|
|
12
11
|
active?: boolean;
|
|
13
12
|
saveOnFile?: boolean;
|
|
14
13
|
};
|
|
15
|
-
export type
|
|
14
|
+
export type CustomizeLoggerCallback = (self: Logger, level: LogLevels, args: unknown[]) => unknown[] | undefined;
|
|
15
|
+
export type AssignFilenameCallback = (self: Logger) => string;
|
|
16
16
|
/**
|
|
17
17
|
* Represents a logger utility for logging messages with various log levels.
|
|
18
18
|
*/
|
|
@@ -21,14 +21,16 @@ export declare class Logger {
|
|
|
21
21
|
* The options for configuring the logger.
|
|
22
22
|
*/
|
|
23
23
|
readonly options: Required<LoggerOptions>;
|
|
24
|
-
static streams: Partial<Record<string, WriteStream>>;
|
|
25
24
|
static saveOnFile?: string[] | 'all';
|
|
26
25
|
static dirname: string;
|
|
26
|
+
private static streams;
|
|
27
|
+
private static fileNames;
|
|
27
28
|
private static createdDir?;
|
|
29
|
+
private static __assignFileName;
|
|
28
30
|
/**
|
|
29
31
|
* The custom callback function for logging.
|
|
30
32
|
*/
|
|
31
|
-
private static __callback
|
|
33
|
+
private static __callback;
|
|
32
34
|
/**
|
|
33
35
|
* Allows customization of the logging behavior by providing a custom callback function.
|
|
34
36
|
* @param cb The custom callback function for logging.
|
|
@@ -37,7 +39,19 @@ export declare class Logger {
|
|
|
37
39
|
* // Custom logging implementation
|
|
38
40
|
* });
|
|
39
41
|
*/
|
|
40
|
-
static customize(cb:
|
|
42
|
+
static customize(cb: CustomizeLoggerCallback): void;
|
|
43
|
+
/**
|
|
44
|
+
* Customizes the logging filename by providing a callback function.
|
|
45
|
+
* The callback receives the logger instance and should return the desired filename.
|
|
46
|
+
*
|
|
47
|
+
* @param cb - A function that takes the logger instance and returns a string
|
|
48
|
+
* representing the customized filename for the log.
|
|
49
|
+
* @example
|
|
50
|
+
* Logger.customizeFilename((logger) => {
|
|
51
|
+
* return `${logger.name}-${Date.now()}.log`;
|
|
52
|
+
* });
|
|
53
|
+
*/
|
|
54
|
+
static customizeFilename(cb: AssignFilenameCallback): void;
|
|
41
55
|
static clearLogs(): Promise<void>;
|
|
42
56
|
/**
|
|
43
57
|
* Constructs a new Logger instance with the provided options.
|
|
@@ -122,3 +136,9 @@ export declare class Logger {
|
|
|
122
136
|
*/
|
|
123
137
|
static prefixes: Map<LogLevels, string>;
|
|
124
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Formats memory usage data into a string.
|
|
141
|
+
* @param data The memory usage data.
|
|
142
|
+
* @returns The formatted string representing memory usage.
|
|
143
|
+
*/
|
|
144
|
+
export declare function formatMemoryUsage(bytes: number): string;
|
package/lib/common/it/logger.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Logger = exports.LogLevels = void 0;
|
|
4
|
+
exports.formatMemoryUsage = formatMemoryUsage;
|
|
4
5
|
const node_fs_1 = require("node:fs");
|
|
5
6
|
const node_path_1 = require("node:path");
|
|
6
7
|
const colors_1 = require("./colors");
|
|
@@ -21,14 +22,30 @@ class Logger {
|
|
|
21
22
|
* The options for configuring the logger.
|
|
22
23
|
*/
|
|
23
24
|
options;
|
|
24
|
-
static streams = {};
|
|
25
25
|
static saveOnFile;
|
|
26
26
|
static dirname = 'seyfert-logs';
|
|
27
|
+
static streams = {};
|
|
28
|
+
static fileNames = {};
|
|
27
29
|
static createdDir;
|
|
30
|
+
static __assignFileName = self => {
|
|
31
|
+
const date = new Date();
|
|
32
|
+
return `${self.name}-${date.getMonth() + 1}-${date.getDate()}-${date.getFullYear()}-${date.getTime()}.log`;
|
|
33
|
+
};
|
|
28
34
|
/**
|
|
29
35
|
* The custom callback function for logging.
|
|
30
36
|
*/
|
|
31
|
-
static __callback
|
|
37
|
+
static __callback = (self, level, args) => {
|
|
38
|
+
const color = Logger.colorFunctions.get(level) ?? Logger.noColor;
|
|
39
|
+
const memoryData = process.memoryUsage?.();
|
|
40
|
+
const date = new Date();
|
|
41
|
+
return [
|
|
42
|
+
(0, colors_1.brightBlack)(formatMemoryUsage(memoryData?.rss ?? 0)),
|
|
43
|
+
(0, colors_1.bgBrightWhite)((0, colors_1.black)(`[${date.toLocaleDateString()} ${date.toLocaleTimeString()}]`)),
|
|
44
|
+
color(Logger.prefixes.get(level) ?? 'DEBUG'),
|
|
45
|
+
self.name ? `${self.name} >` : '>',
|
|
46
|
+
...args,
|
|
47
|
+
];
|
|
48
|
+
};
|
|
32
49
|
/**
|
|
33
50
|
* Allows customization of the logging behavior by providing a custom callback function.
|
|
34
51
|
* @param cb The custom callback function for logging.
|
|
@@ -40,10 +57,28 @@ class Logger {
|
|
|
40
57
|
static customize(cb) {
|
|
41
58
|
Logger.__callback = cb;
|
|
42
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Customizes the logging filename by providing a callback function.
|
|
62
|
+
* The callback receives the logger instance and should return the desired filename.
|
|
63
|
+
*
|
|
64
|
+
* @param cb - A function that takes the logger instance and returns a string
|
|
65
|
+
* representing the customized filename for the log.
|
|
66
|
+
* @example
|
|
67
|
+
* Logger.customizeFilename((logger) => {
|
|
68
|
+
* return `${logger.name}-${Date.now()}.log`;
|
|
69
|
+
* });
|
|
70
|
+
*/
|
|
71
|
+
static customizeFilename(cb) {
|
|
72
|
+
Logger.__assignFileName = cb;
|
|
73
|
+
}
|
|
43
74
|
static async clearLogs() {
|
|
44
75
|
for (const i of await node_fs_1.promises.readdir((0, node_path_1.join)(process.cwd(), Logger.dirname), { withFileTypes: true })) {
|
|
45
76
|
if (Logger.streams[i.name])
|
|
46
|
-
await new Promise(res => Logger.streams[i.name].close(
|
|
77
|
+
await new Promise((res, rej) => Logger.streams[i.name].close(err => {
|
|
78
|
+
if (err)
|
|
79
|
+
return rej(err);
|
|
80
|
+
res(err);
|
|
81
|
+
}));
|
|
47
82
|
await node_fs_1.promises.unlink((0, node_path_1.join)(process.cwd(), Logger.dirname, i.name)).catch(() => undefined);
|
|
48
83
|
delete Logger.streams[i.name];
|
|
49
84
|
}
|
|
@@ -108,22 +143,7 @@ class Logger {
|
|
|
108
143
|
return;
|
|
109
144
|
if (level < this.level)
|
|
110
145
|
return;
|
|
111
|
-
|
|
112
|
-
if (Logger.__callback) {
|
|
113
|
-
log = Logger.__callback(this, level, args);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const color = Logger.colorFunctions.get(level) ?? Logger.noColor;
|
|
117
|
-
const memoryData = process.memoryUsage?.();
|
|
118
|
-
const date = new Date();
|
|
119
|
-
log = [
|
|
120
|
-
(0, colors_1.brightBlack)(formatMemoryUsage(memoryData?.rss ?? 0)),
|
|
121
|
-
(0, colors_1.bgBrightWhite)((0, colors_1.black)(`[${date.toLocaleDateString()} ${date.toLocaleTimeString()}]`)),
|
|
122
|
-
color(Logger.prefixes.get(level) ?? 'DEBUG'),
|
|
123
|
-
this.name ? `${this.name} >` : '>',
|
|
124
|
-
...args,
|
|
125
|
-
];
|
|
126
|
-
}
|
|
146
|
+
const log = Logger.__callback(this, level, args);
|
|
127
147
|
if (!log)
|
|
128
148
|
return;
|
|
129
149
|
this.__write(log);
|
|
@@ -170,12 +190,13 @@ class Logger {
|
|
|
170
190
|
Logger.createdDir = true;
|
|
171
191
|
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(process.cwd(), Logger.dirname), { recursive: true });
|
|
172
192
|
}
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
const fileName = (Logger.fileNames[this.name] ??= (() => {
|
|
194
|
+
return (Logger.fileNames[this.name] = Logger.__assignFileName(this));
|
|
195
|
+
})());
|
|
196
|
+
if (!Logger.streams[fileName]) {
|
|
197
|
+
Logger.streams[fileName] = (0, node_fs_1.createWriteStream)((0, node_path_1.join)(process.cwd(), Logger.dirname, fileName));
|
|
177
198
|
}
|
|
178
|
-
Logger.streams[
|
|
199
|
+
Logger.streams[fileName].write(`${(0, colors_1.stripColor)(log.join(' '))}\n`);
|
|
179
200
|
}
|
|
180
201
|
}
|
|
181
202
|
/**
|
|
@@ -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;
|