seyfert 2.1.1-dev-11842640994.0 → 2.1.1-dev-11845956119.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/client/base.d.ts +14 -3
- package/lib/client/base.js +44 -14
- package/lib/client/httpclient.d.ts +0 -7
- package/lib/client/httpclient.js +0 -32
- package/lib/client/types.d.ts +2 -2
- package/lib/commands/applications/chatcontext.d.ts +1 -1
- package/lib/commands/applications/entrycontext.d.ts +1 -1
- package/lib/commands/applications/menucontext.d.ts +1 -1
- package/lib/components/componentcontext.d.ts +1 -1
- package/lib/components/modalcontext.d.ts +1 -1
- package/package.json +1 -1
package/lib/client/base.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { ComponentCommand, ModalCommand } from '../components';
|
|
|
13
13
|
import { ComponentHandler } from '../components/handler';
|
|
14
14
|
import { LangsHandler } from '../langs/handler';
|
|
15
15
|
import type { ChatInputCommandInteraction, ComponentInteraction, EntryPointInteraction, MessageCommandInteraction, ModalSubmitInteraction, UserCommandInteraction } from '../structures';
|
|
16
|
-
import type { LocaleString, RESTPostAPIChannelMessageJSONBody } from '../types';
|
|
16
|
+
import type { APIInteraction, APIInteractionResponse, LocaleString, RESTPostAPIChannelMessageJSONBody } from '../types';
|
|
17
17
|
import type { MessageStructure } from './transformers';
|
|
18
18
|
export declare class BaseClient {
|
|
19
19
|
rest: ApiHandler;
|
|
@@ -55,6 +55,17 @@ export declare class BaseClient {
|
|
|
55
55
|
protected execute(..._options: unknown[]): Promise<void>;
|
|
56
56
|
start(options?: Pick<DeepPartial<StartOptions>, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise<void>;
|
|
57
57
|
protected onPacket(..._packet: unknown[]): Promise<any>;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param rawBody body of interaction
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
protected onInteractionRequest(rawBody: APIInteraction): Promise<{
|
|
64
|
+
headers: {
|
|
65
|
+
'Content-Type'?: string;
|
|
66
|
+
};
|
|
67
|
+
response: APIInteractionResponse | FormData;
|
|
68
|
+
}>;
|
|
58
69
|
private shouldUploadCommands;
|
|
59
70
|
private syncCachePath;
|
|
60
71
|
uploadCommands({ applicationId, cachePath }?: {
|
|
@@ -74,7 +85,7 @@ export declare class BaseClient {
|
|
|
74
85
|
}>;
|
|
75
86
|
}
|
|
76
87
|
export interface BaseClientOptions {
|
|
77
|
-
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | ComponentInteraction | ModalSubmitInteraction | EntryPointInteraction<boolean> | When<InferWithPrefix, MessageStructure, never>) =>
|
|
88
|
+
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | ComponentInteraction | ModalSubmitInteraction | EntryPointInteraction<boolean> | When<InferWithPrefix, MessageStructure, never>) => Record<string, unknown>;
|
|
78
89
|
globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
|
|
79
90
|
commands?: {
|
|
80
91
|
defaults?: {
|
|
@@ -147,7 +158,7 @@ export type InternalRuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'por
|
|
|
147
158
|
export type RuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'applicationId'>, 'intents' | 'locations'> & {
|
|
148
159
|
locations: Omit<RC['locations'], 'events'>;
|
|
149
160
|
};
|
|
150
|
-
export type InternalRuntimeConfig =
|
|
161
|
+
export type InternalRuntimeConfig = MakeRequired<RC, 'intents'>;
|
|
151
162
|
export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
|
|
152
163
|
intents?: IntentStrings | number[] | number;
|
|
153
164
|
}>;
|
package/lib/client/base.js
CHANGED
|
@@ -8,6 +8,7 @@ const shared_1 = require("../commands/applications/shared");
|
|
|
8
8
|
const handler_1 = require("../commands/handler");
|
|
9
9
|
const common_1 = require("../common");
|
|
10
10
|
const node_fs_1 = require("node:fs");
|
|
11
|
+
const utils_1 = require("../api/utils/utils");
|
|
11
12
|
const handle_1 = require("../commands/handle");
|
|
12
13
|
const bans_1 = require("../common/shorters/bans");
|
|
13
14
|
const voiceStates_1 = require("../common/shorters/voiceStates");
|
|
@@ -182,18 +183,12 @@ class BaseClient {
|
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
|
-
async start(options = {
|
|
186
|
-
token: undefined,
|
|
187
|
-
langsDir: undefined,
|
|
188
|
-
commandsDir: undefined,
|
|
189
|
-
connection: undefined,
|
|
190
|
-
componentsDir: undefined,
|
|
191
|
-
}) {
|
|
186
|
+
async start(options = {}) {
|
|
192
187
|
await this.loadLangs(options.langsDir);
|
|
193
188
|
await this.loadCommands(options.commandsDir);
|
|
194
189
|
await this.loadComponents(options.componentsDir);
|
|
195
190
|
const { token: tokenRC, debug } = await this.getRC();
|
|
196
|
-
const token = options
|
|
191
|
+
const token = options.token ?? tokenRC;
|
|
197
192
|
BaseClient.assertString(token, 'token is not a string');
|
|
198
193
|
if (this.rest.options.token === 'INVALID')
|
|
199
194
|
this.rest.options.token = token;
|
|
@@ -207,14 +202,49 @@ class BaseClient {
|
|
|
207
202
|
async onPacket(..._packet) {
|
|
208
203
|
throw new Error('Function not implemented');
|
|
209
204
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
/**
|
|
206
|
+
*
|
|
207
|
+
* @param rawBody body of interaction
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
async onInteractionRequest(rawBody) {
|
|
211
|
+
return new Promise(async (r) => {
|
|
212
|
+
await this.handleCommand.interaction(rawBody, -1, async ({ body, files }) => {
|
|
213
|
+
let response;
|
|
214
|
+
const headers = {};
|
|
215
|
+
if (files) {
|
|
216
|
+
response = new FormData();
|
|
217
|
+
for (const [index, file] of files.entries()) {
|
|
218
|
+
const fileKey = file.key ?? `files[${index}]`;
|
|
219
|
+
if ((0, utils_1.isBufferLike)(file.data)) {
|
|
220
|
+
response.append(fileKey, new Blob([file.data], { type: file.contentType }), file.filename);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
response.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.filename);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (body) {
|
|
227
|
+
response.append('payload_json', JSON.stringify(body));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
response = body ?? {};
|
|
232
|
+
headers['Content-Type'] = 'application/json';
|
|
233
|
+
}
|
|
234
|
+
return r({
|
|
235
|
+
headers,
|
|
236
|
+
response,
|
|
237
|
+
});
|
|
238
|
+
});
|
|
216
239
|
});
|
|
217
240
|
}
|
|
241
|
+
async shouldUploadCommands(cachePath, guildId) {
|
|
242
|
+
const should = await this.commands.shouldUpload(cachePath, guildId);
|
|
243
|
+
this.logger.debug(should
|
|
244
|
+
? `[${guildId ?? 'global'}] Change(s) detected, uploading commands`
|
|
245
|
+
: `[${guildId ?? 'global'}] commands seems to be up to date`);
|
|
246
|
+
return should;
|
|
247
|
+
}
|
|
218
248
|
syncCachePath(cachePath) {
|
|
219
249
|
return node_fs_1.promises.writeFile(cachePath, JSON.stringify(this.commands.values.filter(cmd => !('ignore' in cmd) || cmd.ignore !== shared_1.IgnoreCommand.Slash).map(x => x.toJSON())));
|
|
220
250
|
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import type { DeepPartial } from '../common';
|
|
2
|
-
import type { APIInteraction, APIInteractionResponse } from '../types';
|
|
3
2
|
import type { BaseClientOptions, StartOptions } from './base';
|
|
4
3
|
import { BaseClient } from './base';
|
|
5
4
|
export declare class HttpClient extends BaseClient {
|
|
6
5
|
constructor(options?: BaseClientOptions);
|
|
7
6
|
start(options?: DeepPartial<Omit<StartOptions, 'connection' | 'eventsDir'>>): Promise<void>;
|
|
8
|
-
onPacket(rawBody: APIInteraction): Promise<{
|
|
9
|
-
headers: {
|
|
10
|
-
'Content-Type'?: string;
|
|
11
|
-
};
|
|
12
|
-
response: APIInteractionResponse | FormData;
|
|
13
|
-
}>;
|
|
14
7
|
}
|
package/lib/client/httpclient.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpClient = void 0;
|
|
4
|
-
const utils_1 = require("../api/utils/utils");
|
|
5
4
|
const base_1 = require("./base");
|
|
6
5
|
class HttpClient extends base_1.BaseClient {
|
|
7
6
|
constructor(options) {
|
|
@@ -11,36 +10,5 @@ class HttpClient extends base_1.BaseClient {
|
|
|
11
10
|
await super.start(options);
|
|
12
11
|
return this.execute(options.httpConnection ?? {});
|
|
13
12
|
}
|
|
14
|
-
async onPacket(rawBody) {
|
|
15
|
-
return new Promise(async (r) => {
|
|
16
|
-
await this.handleCommand.interaction(rawBody, -1, async ({ body, files }) => {
|
|
17
|
-
let response;
|
|
18
|
-
const headers = {};
|
|
19
|
-
if (files) {
|
|
20
|
-
response = new FormData();
|
|
21
|
-
for (const [index, file] of files.entries()) {
|
|
22
|
-
const fileKey = file.key ?? `files[${index}]`;
|
|
23
|
-
if ((0, utils_1.isBufferLike)(file.data)) {
|
|
24
|
-
response.append(fileKey, new Blob([file.data], { type: file.contentType }), file.filename);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
response.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.filename);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (body) {
|
|
31
|
-
response.append('payload_json', JSON.stringify(body));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
response = body ?? {};
|
|
36
|
-
headers['Content-Type'] = 'application/json';
|
|
37
|
-
}
|
|
38
|
-
return r({
|
|
39
|
-
headers,
|
|
40
|
-
response,
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
13
|
}
|
|
46
14
|
exports.HttpClient = HttpClient;
|
package/lib/client/types.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
|
|
|
45
45
|
isChat(): this is CommandContext<T, M>;
|
|
46
46
|
inGuild(): this is GuildCommandContext<T, M>;
|
|
47
47
|
}
|
|
48
|
-
export interface GuildCommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<CommandContext<T, M>, 'guildId'>, 'guild'> {
|
|
48
|
+
export interface GuildCommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<CommandContext<T, M>, 'guildId' | 'member'>, 'guild'> {
|
|
49
49
|
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
50
50
|
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
51
51
|
}
|
|
@@ -40,7 +40,7 @@ export declare class EntryPointContext<M extends keyof RegisteredMiddlewares = n
|
|
|
40
40
|
isEntryPoint(): this is EntryPointContext<M>;
|
|
41
41
|
inGuild(): this is GuildEntryPointContext<M>;
|
|
42
42
|
}
|
|
43
|
-
export interface GuildEntryPointContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<EntryPointContext<M>, 'guildId'>, 'guild'> {
|
|
43
|
+
export interface GuildEntryPointContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<EntryPointContext<M>, 'guildId' | 'member'>, 'guild'> {
|
|
44
44
|
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
45
45
|
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
46
46
|
}
|
|
@@ -43,7 +43,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
|
|
|
43
43
|
isMenuMessage(): this is MenuCommandContext<MessageCommandInteraction>;
|
|
44
44
|
inGuild(): this is GuildMenuCommandContext<T, M>;
|
|
45
45
|
}
|
|
46
|
-
export interface GuildMenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<MenuCommandContext<T, M>, 'guildId'>, 'guild'> {
|
|
46
|
+
export interface GuildMenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<MenuCommandContext<T, M>, 'guildId' | 'member'>, 'guild'> {
|
|
47
47
|
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
48
48
|
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
49
49
|
}
|
|
@@ -126,7 +126,7 @@ export interface ContextComponentCommandInteractionMap {
|
|
|
126
126
|
MentionableSelect: MentionableSelectMenuInteraction;
|
|
127
127
|
ChannelSelect: ChannelSelectMenuInteraction;
|
|
128
128
|
}
|
|
129
|
-
export interface GuildComponentContext<Type extends keyof ContextComponentCommandInteractionMap, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<ComponentContext<Type, M>, 'guildId'>, 'guild'> {
|
|
129
|
+
export interface GuildComponentContext<Type extends keyof ContextComponentCommandInteractionMap, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<ComponentContext<Type, M>, 'guildId' | 'member'>, 'guild'> {
|
|
130
130
|
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
131
131
|
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
132
132
|
}
|
|
@@ -109,7 +109,7 @@ export declare class ModalContext<M extends keyof RegisteredMiddlewares = never>
|
|
|
109
109
|
isModal(): this is ModalContext<M>;
|
|
110
110
|
inGuild(): this is GuildModalContext<M>;
|
|
111
111
|
}
|
|
112
|
-
export interface GuildModalContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<ModalContext<M>, 'guildId'>, 'guild'> {
|
|
112
|
+
export interface GuildModalContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<ModalContext<M>, 'guildId' | 'member'>, 'guild'> {
|
|
113
113
|
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
114
114
|
guild(mode?: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
115
115
|
}
|