seyfert 1.4.0 → 1.5.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/README.md +7 -7
- package/lib/api/Router.js +3 -1
- package/lib/api/Routes/guilds.d.ts +4 -1
- package/lib/cache/index.d.ts +6 -2
- package/lib/cache/index.js +18 -0
- package/lib/cache/resources/bans.d.ts +12 -0
- package/lib/cache/resources/bans.js +35 -0
- package/lib/cache/resources/members.js +4 -4
- package/lib/cache/resources/messages.js +8 -6
- package/lib/client/base.d.ts +7 -3
- package/lib/client/base.js +43 -24
- package/lib/client/client.d.ts +17 -5
- package/lib/client/client.js +39 -43
- package/lib/client/collectors.d.ts +36 -0
- package/lib/client/collectors.js +85 -0
- package/lib/client/httpclient.js +6 -6
- package/lib/client/onmessagecreate.d.ts +12 -2
- package/lib/client/onmessagecreate.js +32 -17
- package/lib/client/workerclient.d.ts +4 -1
- package/lib/client/workerclient.js +59 -67
- package/lib/collection.d.ts +2 -2
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +10 -9
- package/lib/commands/applications/chat.js +21 -7
- package/lib/commands/applications/menu.d.ts +8 -7
- package/lib/commands/applications/menu.js +3 -2
- package/lib/commands/applications/shared.d.ts +12 -0
- package/lib/commands/decorators.d.ts +11 -17
- package/lib/commands/decorators.js +7 -14
- package/lib/commands/handler.js +39 -29
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +3 -1
- package/lib/common/it/formatter.d.ts +155 -0
- package/lib/common/it/formatter.js +184 -0
- package/lib/common/it/logger.js +5 -5
- package/lib/common/it/utils.js +2 -4
- package/lib/common/shorters/bans.d.ts +43 -0
- package/lib/common/shorters/bans.js +78 -0
- package/lib/common/shorters/emojis.d.ts +1 -1
- package/lib/common/shorters/emojis.js +4 -3
- package/lib/common/shorters/interaction.js +9 -7
- package/lib/common/shorters/messages.js +2 -2
- package/lib/common/shorters/webhook.js +2 -2
- package/lib/components/componentcommand.d.ts +3 -2
- package/lib/components/componentcommand.js +2 -1
- package/lib/components/componentcontext.d.ts +1 -1
- package/lib/components/handler.d.ts +1 -1
- package/lib/components/handler.js +25 -28
- package/lib/components/modalcommand.d.ts +2 -1
- package/lib/components/modalcommand.js +1 -0
- package/lib/components/modalcontext.d.ts +1 -1
- package/lib/events/event.d.ts +4 -3
- package/lib/events/handler.d.ts +8 -5
- package/lib/events/handler.js +58 -13
- package/lib/events/hooks/guild.d.ts +18 -73
- package/lib/events/hooks/integration.d.ts +57 -0
- package/lib/events/hooks/invite.d.ts +3 -0
- package/lib/events/hooks/message.d.ts +11 -6
- package/lib/events/hooks/presence.d.ts +4 -0
- package/lib/events/hooks/thread.d.ts +14 -3
- package/lib/events/hooks/typing.d.ts +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -2
- package/lib/structures/Guild.d.ts +9 -1
- package/lib/structures/Guild.js +2 -0
- package/lib/structures/GuildBan.d.ts +25 -0
- package/lib/structures/GuildBan.js +36 -0
- package/lib/structures/GuildEmoji.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +7 -2
- package/lib/structures/GuildMember.js +4 -4
- package/lib/structures/Interaction.d.ts +3 -2
- package/lib/structures/Interaction.js +21 -9
- package/lib/structures/Message.d.ts +69 -8
- package/lib/structures/Message.js +59 -17
- package/lib/structures/Sticker.d.ts +3 -3
- package/lib/structures/User.d.ts +1 -0
- package/lib/structures/User.js +4 -1
- package/lib/structures/channels.d.ts +4 -1
- package/lib/structures/channels.js +36 -6
- package/lib/structures/extra/functions.js +1 -1
- package/lib/websocket/discord/basesocket.d.ts +1 -0
- package/lib/websocket/discord/basesocket.js +17 -0
- package/lib/websocket/discord/shard.d.ts +1 -0
- package/lib/websocket/discord/shard.js +6 -0
- package/package.json +8 -8
package/lib/commands/handler.js
CHANGED
|
@@ -54,7 +54,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
54
54
|
if (option.channel_types?.length !== cached.channel_types?.length)
|
|
55
55
|
return true;
|
|
56
56
|
if ('channel_types' in option && 'channel_types' in cached) {
|
|
57
|
-
if (!option.channel_types
|
|
57
|
+
if (!(option.channel_types && cached.channel_types))
|
|
58
58
|
return true;
|
|
59
59
|
return option.channel_types.some(ct => !cached.channel_types.includes(ct));
|
|
60
60
|
}
|
|
@@ -123,7 +123,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
123
123
|
return true;
|
|
124
124
|
//TODO: locales
|
|
125
125
|
if ('contexts' in command && 'contexts' in cached) {
|
|
126
|
-
if (command.contexts
|
|
126
|
+
if (command.contexts.length !== cached.contexts.length)
|
|
127
127
|
return true;
|
|
128
128
|
if (command.contexts && cached.contexts) {
|
|
129
129
|
if (command.contexts.some(ctx => !cached.contexts.includes(ctx)))
|
|
@@ -131,7 +131,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
if ('integration_types' in command && 'integration_types' in cached) {
|
|
134
|
-
if (command.integration_types
|
|
134
|
+
if (command.integration_types.length !== cached.integration_types.length)
|
|
135
135
|
return true;
|
|
136
136
|
if (command.integration_types && cached.integration_types) {
|
|
137
137
|
if (command.integration_types.some(ctx => !cached.integration_types.includes(ctx)))
|
|
@@ -180,20 +180,23 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
180
180
|
if (commandInstance instanceof menu_1.ContextMenuCommand) {
|
|
181
181
|
this.values.push(commandInstance);
|
|
182
182
|
commandInstance.__filePath = command.path;
|
|
183
|
+
this.__parseCommandLocales(commandInstance);
|
|
184
|
+
commandInstance.props ??= client.options.commands?.defaults?.props ?? {};
|
|
183
185
|
continue;
|
|
184
186
|
}
|
|
185
187
|
if (!(commandInstance instanceof chat_1.Command)) {
|
|
186
188
|
continue;
|
|
187
189
|
}
|
|
188
|
-
commandInstance.onAfterRun ??= client.options
|
|
189
|
-
commandInstance.onBotPermissionsFail ??= client.options
|
|
190
|
-
commandInstance.onInternalError ??= client.options
|
|
191
|
-
commandInstance.onMiddlewaresError ??= client.options
|
|
192
|
-
commandInstance.onOptionsError ??= client.options
|
|
193
|
-
commandInstance.onPermissionsFail ??= client.options
|
|
194
|
-
commandInstance.onRunError ??= client.options
|
|
190
|
+
commandInstance.onAfterRun ??= client.options.commands?.defaults?.onAfterRun;
|
|
191
|
+
commandInstance.onBotPermissionsFail ??= client.options.commands?.defaults?.onBotPermissionsFail;
|
|
192
|
+
commandInstance.onInternalError ??= client.options.commands?.defaults?.onInternalError;
|
|
193
|
+
commandInstance.onMiddlewaresError ??= client.options.commands?.defaults?.onMiddlewaresError;
|
|
194
|
+
commandInstance.onOptionsError ??= client.options.commands?.defaults?.onOptionsError;
|
|
195
|
+
commandInstance.onPermissionsFail ??= client.options.commands?.defaults?.onPermissionsFail;
|
|
196
|
+
commandInstance.onRunError ??= client.options.commands?.defaults?.onRunError;
|
|
195
197
|
commandInstance.__filePath = command.path;
|
|
196
198
|
commandInstance.options ??= [];
|
|
199
|
+
commandInstance.props ??= client.options.commands?.defaults?.props ?? {};
|
|
197
200
|
if (commandInstance.__autoload) {
|
|
198
201
|
//@AutoLoad
|
|
199
202
|
const options = await this.getFiles((0, node_path_1.dirname)(command.path));
|
|
@@ -219,86 +222,93 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
219
222
|
option.onMiddlewaresError =
|
|
220
223
|
option.onMiddlewaresError?.bind(option) ??
|
|
221
224
|
commandInstance.onMiddlewaresError?.bind(commandInstance) ??
|
|
222
|
-
this.client.options
|
|
225
|
+
this.client.options.commands?.defaults?.onMiddlewaresError;
|
|
223
226
|
option.onRunError =
|
|
224
227
|
option.onRunError?.bind(option) ??
|
|
225
228
|
commandInstance.onRunError?.bind(commandInstance) ??
|
|
226
|
-
this.client.options
|
|
229
|
+
this.client.options.commands?.defaults?.onRunError;
|
|
227
230
|
option.onOptionsError =
|
|
228
231
|
option.onOptionsError?.bind(option) ??
|
|
229
232
|
commandInstance.onOptionsError?.bind(commandInstance) ??
|
|
230
|
-
this.client.options
|
|
233
|
+
this.client.options.commands?.defaults?.onOptionsError;
|
|
231
234
|
option.onInternalError =
|
|
232
235
|
option.onInternalError?.bind(option) ??
|
|
233
236
|
commandInstance.onInternalError?.bind(commandInstance) ??
|
|
234
|
-
this.client.options
|
|
237
|
+
this.client.options.commands?.defaults?.onInternalError;
|
|
235
238
|
option.onAfterRun =
|
|
236
239
|
option.onAfterRun?.bind(option) ??
|
|
237
240
|
commandInstance.onAfterRun?.bind(commandInstance) ??
|
|
238
|
-
this.client.options
|
|
241
|
+
this.client.options.commands?.defaults?.onAfterRun;
|
|
239
242
|
option.onBotPermissionsFail =
|
|
240
243
|
option.onBotPermissionsFail?.bind(option) ??
|
|
241
244
|
commandInstance.onBotPermissionsFail?.bind(commandInstance) ??
|
|
242
|
-
this.client.options
|
|
245
|
+
this.client.options.commands?.defaults?.onBotPermissionsFail;
|
|
243
246
|
option.onPermissionsFail =
|
|
244
247
|
option.onPermissionsFail?.bind(option) ??
|
|
245
248
|
commandInstance.onPermissionsFail?.bind(commandInstance) ??
|
|
246
|
-
this.client.options
|
|
249
|
+
this.client.options.commands?.defaults?.onPermissionsFail;
|
|
250
|
+
option.botPermissions ??= commandInstance.botPermissions;
|
|
251
|
+
option.defaultMemberPermissions ??= commandInstance.defaultMemberPermissions;
|
|
252
|
+
option.contexts ??= commandInstance.contexts;
|
|
253
|
+
option.integrationTypes ??= commandInstance.integrationTypes;
|
|
254
|
+
option.props ??= commandInstance.props;
|
|
247
255
|
}
|
|
248
256
|
}
|
|
249
257
|
this.values.push(commandInstance);
|
|
250
|
-
this.__parseCommandLocales(commandInstance
|
|
258
|
+
this.__parseCommandLocales(commandInstance);
|
|
251
259
|
for (const i of commandInstance.options ?? []) {
|
|
252
260
|
if (i instanceof chat_1.SubCommand) {
|
|
253
|
-
this.__parseCommandLocales(i
|
|
261
|
+
this.__parseCommandLocales(i);
|
|
254
262
|
}
|
|
255
263
|
}
|
|
256
264
|
}
|
|
257
265
|
return this.values;
|
|
258
266
|
}
|
|
259
|
-
__parseCommandLocales(command
|
|
267
|
+
__parseCommandLocales(command) {
|
|
260
268
|
if (command.__t) {
|
|
261
269
|
command.name_localizations = {};
|
|
262
270
|
command.description_localizations = {};
|
|
263
|
-
for (const locale of Object.keys(client.langs.values)) {
|
|
271
|
+
for (const locale of Object.keys(this.client.langs.values)) {
|
|
264
272
|
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
265
273
|
if (Object.values(v10_1.Locale).includes(locale))
|
|
266
274
|
locales.push(locale);
|
|
267
275
|
if (command.__t.name) {
|
|
268
276
|
for (const i of locales) {
|
|
269
|
-
const valueName = client.langs.getKey(locale, command.__t.name);
|
|
277
|
+
const valueName = this.client.langs.getKey(locale, command.__t.name);
|
|
270
278
|
if (valueName)
|
|
271
279
|
command.name_localizations[i] = valueName;
|
|
272
280
|
}
|
|
273
281
|
}
|
|
274
282
|
if (command.__t.description) {
|
|
275
283
|
for (const i of locales) {
|
|
276
|
-
const valueKey = client.langs.getKey(locale, command.__t.description);
|
|
284
|
+
const valueKey = this.client.langs.getKey(locale, command.__t.description);
|
|
277
285
|
if (valueKey)
|
|
278
286
|
command.description_localizations[i] = valueKey;
|
|
279
287
|
}
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
290
|
}
|
|
291
|
+
if (command instanceof menu_1.ContextMenuCommand)
|
|
292
|
+
return;
|
|
283
293
|
for (const options of command.options ?? []) {
|
|
284
294
|
if (options instanceof chat_1.SubCommand || !options.locales)
|
|
285
295
|
continue;
|
|
286
296
|
options.name_localizations = {};
|
|
287
297
|
options.description_localizations = {};
|
|
288
|
-
for (const locale of Object.keys(client.langs.values)) {
|
|
298
|
+
for (const locale of Object.keys(this.client.langs.values)) {
|
|
289
299
|
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
290
300
|
if (Object.values(v10_1.Locale).includes(locale))
|
|
291
301
|
locales.push(locale);
|
|
292
302
|
if (options.locales.name) {
|
|
293
303
|
for (const i of locales) {
|
|
294
|
-
const valueName = client.langs.getKey(locale, options.locales.name);
|
|
304
|
+
const valueName = this.client.langs.getKey(locale, options.locales.name);
|
|
295
305
|
if (valueName)
|
|
296
306
|
options.name_localizations[i] = valueName;
|
|
297
307
|
}
|
|
298
308
|
}
|
|
299
309
|
if (options.locales.description) {
|
|
300
310
|
for (const i of locales) {
|
|
301
|
-
const valueKey = client.langs.getKey(locale, options.locales.description);
|
|
311
|
+
const valueKey = this.client.langs.getKey(locale, options.locales.description);
|
|
302
312
|
if (valueKey)
|
|
303
313
|
options.description_localizations[i] = valueKey;
|
|
304
314
|
}
|
|
@@ -307,7 +317,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
307
317
|
}
|
|
308
318
|
if (command instanceof chat_1.Command && command.__tGroups) {
|
|
309
319
|
command.groups = {};
|
|
310
|
-
for (const locale of Object.keys(client.langs.values)) {
|
|
320
|
+
for (const locale of Object.keys(this.client.langs.values)) {
|
|
311
321
|
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
312
322
|
if (Object.values(v10_1.Locale).includes(locale))
|
|
313
323
|
locales.push(locale);
|
|
@@ -319,7 +329,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
319
329
|
};
|
|
320
330
|
if (command.__tGroups[group].name) {
|
|
321
331
|
for (const i of locales) {
|
|
322
|
-
const valueName = client.langs.getKey(locale, command.__tGroups[group].name);
|
|
332
|
+
const valueName = this.client.langs.getKey(locale, command.__tGroups[group].name);
|
|
323
333
|
if (valueName) {
|
|
324
334
|
command.groups[group].name.push([i, valueName]);
|
|
325
335
|
}
|
|
@@ -327,7 +337,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
327
337
|
}
|
|
328
338
|
if (command.__tGroups[group].description) {
|
|
329
339
|
for (const i of locales) {
|
|
330
|
-
const valueKey = client.langs.getKey(locale, command.__tGroups[group].description);
|
|
340
|
+
const valueKey = this.client.langs.getKey(locale, command.__tGroups[group].description);
|
|
331
341
|
if (valueKey) {
|
|
332
342
|
command.groups[group].description.push([i, valueKey]);
|
|
333
343
|
}
|
package/lib/common/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './it/constants';
|
|
|
2
2
|
export * from './it/utils';
|
|
3
3
|
export * from './it/colors';
|
|
4
4
|
export * from './it/logger';
|
|
5
|
+
export * from './it/formatter';
|
|
5
6
|
export * from './shorters/channels';
|
|
6
7
|
export * from './shorters/emojis';
|
|
7
8
|
export * from './shorters/guilds';
|
package/lib/common/index.js
CHANGED
|
@@ -16,9 +16,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./it/constants"), exports);
|
|
18
18
|
__exportStar(require("./it/utils"), exports);
|
|
19
|
-
//
|
|
20
19
|
__exportStar(require("./it/colors"), exports);
|
|
21
20
|
__exportStar(require("./it/logger"), exports);
|
|
21
|
+
__exportStar(require("./it/formatter"), exports);
|
|
22
|
+
//
|
|
22
23
|
__exportStar(require("./shorters/channels"), exports);
|
|
23
24
|
__exportStar(require("./shorters/emojis"), exports);
|
|
24
25
|
__exportStar(require("./shorters/guilds"), exports);
|
|
@@ -31,6 +32,7 @@ __exportStar(require("./shorters/users"), exports);
|
|
|
31
32
|
__exportStar(require("./shorters/threads"), exports);
|
|
32
33
|
__exportStar(require("./shorters/webhook"), exports);
|
|
33
34
|
__exportStar(require("./shorters/interaction"), exports);
|
|
35
|
+
//
|
|
34
36
|
__exportStar(require("./types/options"), exports);
|
|
35
37
|
__exportStar(require("./types/resolvables"), exports);
|
|
36
38
|
__exportStar(require("./types/util"), exports);
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents heading levels.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum HeadingLevel {
|
|
5
|
+
/**
|
|
6
|
+
* Represents a level 1 heading. (#)
|
|
7
|
+
*/
|
|
8
|
+
H1 = 1,
|
|
9
|
+
/**
|
|
10
|
+
* Represents a level 2 heading. (##)
|
|
11
|
+
*/
|
|
12
|
+
H2 = 2,
|
|
13
|
+
/**
|
|
14
|
+
* Represents a level 3 heading. (###)
|
|
15
|
+
*/
|
|
16
|
+
H3 = 3
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Represents timestamp styles.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum TimestampStyle {
|
|
22
|
+
/**
|
|
23
|
+
* Represents a short timestamp style.
|
|
24
|
+
*/
|
|
25
|
+
ShortTime = "t",
|
|
26
|
+
/**
|
|
27
|
+
* Represents a long timestamp style.
|
|
28
|
+
*/
|
|
29
|
+
LongTime = "T",
|
|
30
|
+
/**
|
|
31
|
+
* Represents a short date style.
|
|
32
|
+
*/
|
|
33
|
+
ShortDate = "d",
|
|
34
|
+
/**
|
|
35
|
+
* Represents a long date style.
|
|
36
|
+
*/
|
|
37
|
+
LongDate = "D",
|
|
38
|
+
/**
|
|
39
|
+
* Represents a short time style.
|
|
40
|
+
*/
|
|
41
|
+
ShortDateTime = "f",
|
|
42
|
+
/**
|
|
43
|
+
* Represents a long time style.
|
|
44
|
+
*/
|
|
45
|
+
LongDateTime = "F",
|
|
46
|
+
/**
|
|
47
|
+
* Represents a relative time style.
|
|
48
|
+
*/
|
|
49
|
+
RelativeTime = "R"
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents a message link.
|
|
53
|
+
*/
|
|
54
|
+
type MessageLink = `https://discord.com/channels/${string}/${string}/${string}`;
|
|
55
|
+
/**
|
|
56
|
+
* Represents a timestamp.
|
|
57
|
+
*/
|
|
58
|
+
type Timestamp = `<t:${number}:${TimestampStyle}>`;
|
|
59
|
+
/**
|
|
60
|
+
* Represents a formatter utility for formatting content.
|
|
61
|
+
*/
|
|
62
|
+
export declare class Formatter {
|
|
63
|
+
/**
|
|
64
|
+
* Formats a code block.
|
|
65
|
+
* @param content The content of the code block.
|
|
66
|
+
* @param language The language of the code block. Defaults to 'txt'.
|
|
67
|
+
* @returns The formatted code block.
|
|
68
|
+
*/
|
|
69
|
+
static codeBlock(content: string, language?: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Formats content into inline code.
|
|
72
|
+
* @param content The content to format.
|
|
73
|
+
* @returns The formatted content.
|
|
74
|
+
*/
|
|
75
|
+
static inlineCode(content: string): `\`${string}\``;
|
|
76
|
+
/**
|
|
77
|
+
* Formats content into bold text.
|
|
78
|
+
* @param content The content to format.
|
|
79
|
+
* @returns The formatted content.
|
|
80
|
+
*/
|
|
81
|
+
static bold(content: string): `**${string}**`;
|
|
82
|
+
/**
|
|
83
|
+
* Formats content into italic text.
|
|
84
|
+
* @param content The content to format.
|
|
85
|
+
* @returns The formatted content.
|
|
86
|
+
*/
|
|
87
|
+
static italic(content: string): `*${string}*`;
|
|
88
|
+
/**
|
|
89
|
+
* Formats content into underlined text.
|
|
90
|
+
* @param content The content to format.
|
|
91
|
+
* @returns The formatted content.
|
|
92
|
+
*/
|
|
93
|
+
static underline(content: string): `__${string}__`;
|
|
94
|
+
/**
|
|
95
|
+
* Formats content into strikethrough text.
|
|
96
|
+
* @param content The content to format.
|
|
97
|
+
* @returns The formatted content.
|
|
98
|
+
*/
|
|
99
|
+
static strikeThrough(content: string): `~~${string}~~`;
|
|
100
|
+
/**
|
|
101
|
+
* Formats content into a hyperlink.
|
|
102
|
+
* @param content The content to format.
|
|
103
|
+
* @param url The URL to hyperlink to.
|
|
104
|
+
* @returns The formatted content.
|
|
105
|
+
*/
|
|
106
|
+
static hyperlink(content: string, url: string): `[${string}](${string})`;
|
|
107
|
+
/**
|
|
108
|
+
* Formats content into a spoiler.
|
|
109
|
+
* @param content The content to format.
|
|
110
|
+
* @returns The formatted content.
|
|
111
|
+
*/
|
|
112
|
+
static spoiler(content: string): `||${string}||`;
|
|
113
|
+
/**
|
|
114
|
+
* Formats content into a quote.
|
|
115
|
+
* @param content The content to format.
|
|
116
|
+
* @returns The formatted content.
|
|
117
|
+
*/
|
|
118
|
+
static blockQuote(content: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Formats content into a quote.
|
|
121
|
+
* @param content The content to format.
|
|
122
|
+
* @returns The formatted content.
|
|
123
|
+
*/
|
|
124
|
+
static quote(content: string): string;
|
|
125
|
+
/**
|
|
126
|
+
* Formats a message link.
|
|
127
|
+
* @param guildId The ID of the guild.
|
|
128
|
+
* @param channelId The ID of the channel.
|
|
129
|
+
* @param messageId The ID of the message.
|
|
130
|
+
* @returns The formatted message link.
|
|
131
|
+
*/
|
|
132
|
+
static messageLink(guildId: string, channelId: string, messageId: string): MessageLink;
|
|
133
|
+
/**
|
|
134
|
+
* Formats a header.
|
|
135
|
+
* @param content The content of the header.
|
|
136
|
+
* @param level The level of the header. Defaults to 1.
|
|
137
|
+
* @returns The formatted header.
|
|
138
|
+
*/
|
|
139
|
+
static header(content: string, level?: HeadingLevel): string;
|
|
140
|
+
/**
|
|
141
|
+
* Formats a list.
|
|
142
|
+
* @param items The items of the list.
|
|
143
|
+
* @param ordered Whether the list is ordered. Defaults to false.
|
|
144
|
+
* @returns The formatted list.
|
|
145
|
+
*/
|
|
146
|
+
static list(items: string[], ordered?: boolean): string;
|
|
147
|
+
/**
|
|
148
|
+
* Formats the given timestamp into discord unix timestamp format.
|
|
149
|
+
* @param timestamp The timestamp to format.
|
|
150
|
+
* @param style The style of the timestamp. Defaults to 't'.
|
|
151
|
+
* @returns The formatted timestamp.
|
|
152
|
+
*/
|
|
153
|
+
static timestamp(timestamp: Date, style?: TimestampStyle): Timestamp;
|
|
154
|
+
}
|
|
155
|
+
export {};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Formatter = exports.TimestampStyle = exports.HeadingLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents heading levels.
|
|
6
|
+
*/
|
|
7
|
+
var HeadingLevel;
|
|
8
|
+
(function (HeadingLevel) {
|
|
9
|
+
/**
|
|
10
|
+
* Represents a level 1 heading. (#)
|
|
11
|
+
*/
|
|
12
|
+
HeadingLevel[HeadingLevel["H1"] = 1] = "H1";
|
|
13
|
+
/**
|
|
14
|
+
* Represents a level 2 heading. (##)
|
|
15
|
+
*/
|
|
16
|
+
HeadingLevel[HeadingLevel["H2"] = 2] = "H2";
|
|
17
|
+
/**
|
|
18
|
+
* Represents a level 3 heading. (###)
|
|
19
|
+
*/
|
|
20
|
+
HeadingLevel[HeadingLevel["H3"] = 3] = "H3";
|
|
21
|
+
})(HeadingLevel || (exports.HeadingLevel = HeadingLevel = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Represents timestamp styles.
|
|
24
|
+
*/
|
|
25
|
+
var TimestampStyle;
|
|
26
|
+
(function (TimestampStyle) {
|
|
27
|
+
/**
|
|
28
|
+
* Represents a short timestamp style.
|
|
29
|
+
*/
|
|
30
|
+
TimestampStyle["ShortTime"] = "t";
|
|
31
|
+
/**
|
|
32
|
+
* Represents a long timestamp style.
|
|
33
|
+
*/
|
|
34
|
+
TimestampStyle["LongTime"] = "T";
|
|
35
|
+
/**
|
|
36
|
+
* Represents a short date style.
|
|
37
|
+
*/
|
|
38
|
+
TimestampStyle["ShortDate"] = "d";
|
|
39
|
+
/**
|
|
40
|
+
* Represents a long date style.
|
|
41
|
+
*/
|
|
42
|
+
TimestampStyle["LongDate"] = "D";
|
|
43
|
+
/**
|
|
44
|
+
* Represents a short time style.
|
|
45
|
+
*/
|
|
46
|
+
TimestampStyle["ShortDateTime"] = "f";
|
|
47
|
+
/**
|
|
48
|
+
* Represents a long time style.
|
|
49
|
+
*/
|
|
50
|
+
TimestampStyle["LongDateTime"] = "F";
|
|
51
|
+
/**
|
|
52
|
+
* Represents a relative time style.
|
|
53
|
+
*/
|
|
54
|
+
TimestampStyle["RelativeTime"] = "R";
|
|
55
|
+
})(TimestampStyle || (exports.TimestampStyle = TimestampStyle = {}));
|
|
56
|
+
/**
|
|
57
|
+
* Represents a formatter utility for formatting content.
|
|
58
|
+
*/
|
|
59
|
+
class Formatter {
|
|
60
|
+
/**
|
|
61
|
+
* Formats a code block.
|
|
62
|
+
* @param content The content of the code block.
|
|
63
|
+
* @param language The language of the code block. Defaults to 'txt'.
|
|
64
|
+
* @returns The formatted code block.
|
|
65
|
+
*/
|
|
66
|
+
static codeBlock(content, language = 'txt') {
|
|
67
|
+
return `\`\`\`${language}\n${content}\n\`\`\``;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Formats content into inline code.
|
|
71
|
+
* @param content The content to format.
|
|
72
|
+
* @returns The formatted content.
|
|
73
|
+
*/
|
|
74
|
+
static inlineCode(content) {
|
|
75
|
+
return `\`${content}\``;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Formats content into bold text.
|
|
79
|
+
* @param content The content to format.
|
|
80
|
+
* @returns The formatted content.
|
|
81
|
+
*/
|
|
82
|
+
static bold(content) {
|
|
83
|
+
return `**${content}**`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Formats content into italic text.
|
|
87
|
+
* @param content The content to format.
|
|
88
|
+
* @returns The formatted content.
|
|
89
|
+
*/
|
|
90
|
+
static italic(content) {
|
|
91
|
+
return `*${content}*`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Formats content into underlined text.
|
|
95
|
+
* @param content The content to format.
|
|
96
|
+
* @returns The formatted content.
|
|
97
|
+
*/
|
|
98
|
+
static underline(content) {
|
|
99
|
+
return `__${content}__`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Formats content into strikethrough text.
|
|
103
|
+
* @param content The content to format.
|
|
104
|
+
* @returns The formatted content.
|
|
105
|
+
*/
|
|
106
|
+
static strikeThrough(content) {
|
|
107
|
+
return `~~${content}~~`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Formats content into a hyperlink.
|
|
111
|
+
* @param content The content to format.
|
|
112
|
+
* @param url The URL to hyperlink to.
|
|
113
|
+
* @returns The formatted content.
|
|
114
|
+
*/
|
|
115
|
+
static hyperlink(content, url) {
|
|
116
|
+
return `[${content}](${url})`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Formats content into a spoiler.
|
|
120
|
+
* @param content The content to format.
|
|
121
|
+
* @returns The formatted content.
|
|
122
|
+
*/
|
|
123
|
+
static spoiler(content) {
|
|
124
|
+
return `||${content}||`;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Formats content into a quote.
|
|
128
|
+
* @param content The content to format.
|
|
129
|
+
* @returns The formatted content.
|
|
130
|
+
*/
|
|
131
|
+
static blockQuote(content) {
|
|
132
|
+
return `>>> ${content}`;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Formats content into a quote.
|
|
136
|
+
* @param content The content to format.
|
|
137
|
+
* @returns The formatted content.
|
|
138
|
+
*/
|
|
139
|
+
static quote(content) {
|
|
140
|
+
return `> ${content}`;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Formats a message link.
|
|
144
|
+
* @param guildId The ID of the guild.
|
|
145
|
+
* @param channelId The ID of the channel.
|
|
146
|
+
* @param messageId The ID of the message.
|
|
147
|
+
* @returns The formatted message link.
|
|
148
|
+
*/
|
|
149
|
+
static messageLink(guildId, channelId, messageId) {
|
|
150
|
+
return `https://discord.com/channels/${guildId}/${channelId}/${messageId}`;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Formats a header.
|
|
154
|
+
* @param content The content of the header.
|
|
155
|
+
* @param level The level of the header. Defaults to 1.
|
|
156
|
+
* @returns The formatted header.
|
|
157
|
+
*/
|
|
158
|
+
static header(content, level = HeadingLevel.H1) {
|
|
159
|
+
return `${'#'.repeat(level)} ${content}`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Formats a list.
|
|
163
|
+
* @param items The items of the list.
|
|
164
|
+
* @param ordered Whether the list is ordered. Defaults to false.
|
|
165
|
+
* @returns The formatted list.
|
|
166
|
+
*/
|
|
167
|
+
static list(items, ordered = false) {
|
|
168
|
+
return items
|
|
169
|
+
.map((item, index) => {
|
|
170
|
+
return (ordered ? `${index + 1}. ` : '- ') + item;
|
|
171
|
+
})
|
|
172
|
+
.join('\n');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Formats the given timestamp into discord unix timestamp format.
|
|
176
|
+
* @param timestamp The timestamp to format.
|
|
177
|
+
* @param style The style of the timestamp. Defaults to 't'.
|
|
178
|
+
* @returns The formatted timestamp.
|
|
179
|
+
*/
|
|
180
|
+
static timestamp(timestamp, style = TimestampStyle.RelativeTime) {
|
|
181
|
+
return `<t:${Math.floor(timestamp.getTime() / 1000)}:${style}>`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.Formatter = Formatter;
|
package/lib/common/it/logger.js
CHANGED
|
@@ -109,7 +109,10 @@ class Logger {
|
|
|
109
109
|
if (level < this.level)
|
|
110
110
|
return;
|
|
111
111
|
let log;
|
|
112
|
-
if (
|
|
112
|
+
if (Logger.__callback) {
|
|
113
|
+
log = Logger.__callback(this, level, args);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
113
116
|
const color = Logger.colorFunctions.get(level) ?? Logger.noColor;
|
|
114
117
|
const memoryData = process.memoryUsage?.();
|
|
115
118
|
const date = new Date();
|
|
@@ -121,9 +124,6 @@ class Logger {
|
|
|
121
124
|
...args,
|
|
122
125
|
];
|
|
123
126
|
}
|
|
124
|
-
else {
|
|
125
|
-
log = Logger.__callback(this, level, args);
|
|
126
|
-
}
|
|
127
127
|
if (!log)
|
|
128
128
|
return;
|
|
129
129
|
this.__write(log);
|
|
@@ -166,7 +166,7 @@ class Logger {
|
|
|
166
166
|
}
|
|
167
167
|
__write(log) {
|
|
168
168
|
if (this.saveOnFile || Logger.saveOnFile === 'all' || Logger.saveOnFile?.includes(this.name)) {
|
|
169
|
-
if (!Logger.createdDir
|
|
169
|
+
if (!(Logger.createdDir || (0, node_fs_1.existsSync)((0, node_path_1.join)(process.cwd(), Logger.dirname)))) {
|
|
170
170
|
Logger.createdDir = true;
|
|
171
171
|
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(process.cwd(), Logger.dirname), { recursive: true });
|
|
172
172
|
}
|
package/lib/common/it/utils.js
CHANGED
|
@@ -118,10 +118,8 @@ class BaseHandler {
|
|
|
118
118
|
if (i.isDirectory()) {
|
|
119
119
|
files.push(...(await this.getFiles((0, node_path_1.join)(dir, i.name))));
|
|
120
120
|
}
|
|
121
|
-
else {
|
|
122
|
-
|
|
123
|
-
files.push((0, node_path_1.join)(dir, i.name));
|
|
124
|
-
}
|
|
121
|
+
else if (this.filter((0, node_path_1.join)(dir, i.name))) {
|
|
122
|
+
files.push((0, node_path_1.join)(dir, i.name));
|
|
125
123
|
}
|
|
126
124
|
}
|
|
127
125
|
return files;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { RESTGetAPIGuildBansQuery, RESTPostAPIGuildBulkBanJSONBody, RESTPutAPIGuildBanJSONBody } from 'discord-api-types/v10';
|
|
2
|
+
import { BaseShorter } from './base';
|
|
3
|
+
import { GuildBan } from '../../structures/GuildBan';
|
|
4
|
+
export declare class BanShorter extends BaseShorter {
|
|
5
|
+
/**
|
|
6
|
+
* Bulk creates bans in the guild.
|
|
7
|
+
* @param guildId The ID of the guild.
|
|
8
|
+
* @param body The request body for bulk banning members.
|
|
9
|
+
* @param reason The reason for bulk banning members.
|
|
10
|
+
*/
|
|
11
|
+
bulkCreate(guildId: string, body: RESTPostAPIGuildBulkBanJSONBody, reason?: string): Promise<import("discord-api-types/v10").RESTPostAPIGuildBulkBanResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Unbans a member from the guild.
|
|
14
|
+
* @param guildId The ID of the guild.
|
|
15
|
+
* @param memberId The ID of the member to unban.
|
|
16
|
+
* @param reason The reason for unbanning the member.
|
|
17
|
+
*/
|
|
18
|
+
remove(guildId: string, memberId: string, reason?: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Bans a member from the guild.
|
|
21
|
+
* @param guildId The ID of the guild.
|
|
22
|
+
* @param memberId The ID of the member to ban.
|
|
23
|
+
* @param body The request body for banning the member.
|
|
24
|
+
* @param reason The reason for banning the member.
|
|
25
|
+
*/
|
|
26
|
+
create(guildId: string, memberId: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetches a ban from the guild.
|
|
29
|
+
* @param guildId The ID of the guild.
|
|
30
|
+
* @param userId The ID of the user to fetch.
|
|
31
|
+
* @param force Whether to force fetching the ban from the API even if it exists in the cache.
|
|
32
|
+
* @returns A Promise that resolves to the fetched ban.
|
|
33
|
+
*/
|
|
34
|
+
fetch(guildId: string, userId: string, force?: boolean): Promise<GuildBan>;
|
|
35
|
+
/**
|
|
36
|
+
* Lists bans in the guild based on the provided query.
|
|
37
|
+
* @param guildId The ID of the guild.
|
|
38
|
+
* @param query The query parameters for listing bans.
|
|
39
|
+
* @param force Whether to force listing bans from the API even if they exist in the cache.
|
|
40
|
+
* @returns A Promise that resolves to an array of listed bans.
|
|
41
|
+
*/
|
|
42
|
+
list(guildId: string, query?: RESTGetAPIGuildBansQuery, force?: boolean): Promise<GuildBan[]>;
|
|
43
|
+
}
|