seyfert 2.1.1-dev-11527301551.0 → 2.1.1-dev-11535421049.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/shared.d.ts +1 -1
- package/lib/builders/Attachment.d.ts +1 -1
- package/lib/builders/Attachment.js +2 -1
- package/lib/cache/adapters/limited.js +2 -4
- package/lib/cache/resources/bans.js +2 -2
- package/lib/cache/resources/default/base.d.ts +1 -0
- package/lib/cache/resources/default/base.js +7 -0
- package/lib/cache/resources/default/guild-based.d.ts +1 -0
- package/lib/cache/resources/default/guild-based.js +12 -0
- package/lib/cache/resources/default/guild-related.d.ts +1 -0
- package/lib/cache/resources/default/guild-related.js +7 -0
- package/lib/cache/resources/guilds.js +1 -1
- package/lib/cache/resources/members.js +2 -2
- package/lib/cache/resources/messages.js +3 -3
- package/lib/cache/resources/voice-states.js +1 -1
- package/lib/commands/applications/shared.d.ts +2 -2
- package/lib/commands/handle.d.ts +1 -1
- package/lib/commands/handle.js +95 -100
- package/lib/common/it/constants.d.ts +1 -0
- package/lib/common/it/constants.js +2 -1
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +0 -1
- package/lib/types/utils/index.js +1 -6
- package/package.json +1 -1
package/lib/api/shared.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface ApiHandlerInternalOptions extends MakeRequired<ApiHandlerOption
|
|
|
18
18
|
}
|
|
19
19
|
export interface RawFile {
|
|
20
20
|
contentType?: string;
|
|
21
|
-
data: ArrayBuffer | Buffer | Uint8Array | boolean | number | string;
|
|
21
|
+
data: ArrayBuffer | Buffer | Uint8Array | Uint8ClampedArray | boolean | number | string;
|
|
22
22
|
key?: string;
|
|
23
23
|
filename: string;
|
|
24
24
|
}
|
|
@@ -4,7 +4,7 @@ import { Base } from '../structures/extra/Base';
|
|
|
4
4
|
import type { APIAttachment, RESTAPIAttachment } from '../types';
|
|
5
5
|
export interface AttachmentResolvableMap {
|
|
6
6
|
url: string;
|
|
7
|
-
buffer: Buffer | ArrayBuffer;
|
|
7
|
+
buffer: Buffer | ArrayBuffer | Uint8Array | Uint8ClampedArray;
|
|
8
8
|
path: string;
|
|
9
9
|
}
|
|
10
10
|
export type AttachmentResolvable = AttachmentResolvableMap[keyof AttachmentResolvableMap] | AttachmentBuilder | Attachment;
|
|
@@ -12,6 +12,7 @@ exports.resolveImage = resolveImage;
|
|
|
12
12
|
const node_crypto_1 = require("node:crypto");
|
|
13
13
|
const node_fs_1 = require("node:fs");
|
|
14
14
|
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
+
const utils_1 = require("../api/utils/utils");
|
|
15
16
|
const Base_1 = require("../structures/extra/Base");
|
|
16
17
|
class Attachment extends Base_1.Base {
|
|
17
18
|
data;
|
|
@@ -171,7 +172,7 @@ async function resolveAttachmentData(data, type) {
|
|
|
171
172
|
return { data: await node_fs_1.promises.readFile(file) };
|
|
172
173
|
}
|
|
173
174
|
case 'buffer': {
|
|
174
|
-
if (
|
|
175
|
+
if ((0, utils_1.isBufferLike)(data))
|
|
175
176
|
return { data };
|
|
176
177
|
// @ts-expect-error
|
|
177
178
|
if (typeof data[Symbol.asyncIterator] === 'function') {
|
|
@@ -35,12 +35,10 @@ class LimitedMemoryAdapter {
|
|
|
35
35
|
bulkGet(keys) {
|
|
36
36
|
const storageArray = Array.from(this.storage.values());
|
|
37
37
|
const keySet = new Set(keys);
|
|
38
|
-
return storageArray
|
|
39
|
-
.flatMap(storageEntry => {
|
|
38
|
+
return storageArray.flatMap(storageEntry => {
|
|
40
39
|
const entries = Array.from(storageEntry.entries());
|
|
41
40
|
return entries.filter(([key]) => keySet.has(key)).map(([, value]) => this.options.decode(value.value));
|
|
42
|
-
})
|
|
43
|
-
.filter(Boolean);
|
|
41
|
+
});
|
|
44
42
|
}
|
|
45
43
|
get(key) {
|
|
46
44
|
for (const storageEntry of this.storage.values()) {
|
|
@@ -25,7 +25,7 @@ class Bans extends guild_based_1.GuildBasedResource {
|
|
|
25
25
|
.map(rawBan => {
|
|
26
26
|
return rawBan ? transformers_1.Transformers.GuildBan(this.client, rawBan, guild) : undefined;
|
|
27
27
|
})
|
|
28
|
-
.filter(
|
|
28
|
+
.filter(x => x !== undefined));
|
|
29
29
|
}
|
|
30
30
|
bulkRaw(ids, guild) {
|
|
31
31
|
return super.bulk(ids, guild);
|
|
@@ -35,7 +35,7 @@ class Bans extends guild_based_1.GuildBasedResource {
|
|
|
35
35
|
.map(rawBan => {
|
|
36
36
|
return rawBan ? transformers_1.Transformers.GuildBan(this.client, rawBan, guild) : undefined;
|
|
37
37
|
})
|
|
38
|
-
.filter(
|
|
38
|
+
.filter(x => x !== undefined));
|
|
39
39
|
}
|
|
40
40
|
valuesRaw(guild) {
|
|
41
41
|
return super.values(guild);
|
|
@@ -22,5 +22,6 @@ export declare class BaseResource<T = any, S = any> {
|
|
|
22
22
|
getToRelationship(): import("../../../common").Awaitable<string[]>;
|
|
23
23
|
addToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
24
24
|
removeToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
25
|
+
flush(): import("../../../common").Awaitable<void>;
|
|
25
26
|
hashId(id: string): string;
|
|
26
27
|
}
|
|
@@ -74,6 +74,13 @@ class BaseResource {
|
|
|
74
74
|
removeToRelationship(id) {
|
|
75
75
|
return this.adapter.removeToRelationship(this.namespace, id);
|
|
76
76
|
}
|
|
77
|
+
flush() {
|
|
78
|
+
return (0, common_1.fakePromise)(this.adapter.keys(this.namespace)).then(keys => {
|
|
79
|
+
return (0, common_1.fakePromise)(this.adapter.bulkRemove(keys)).then(() => {
|
|
80
|
+
return this.adapter.removeRelationship(this.namespace);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
77
84
|
hashId(id) {
|
|
78
85
|
return id.startsWith(this.namespace) ? id : `${this.namespace}.${id}`;
|
|
79
86
|
}
|
|
@@ -34,4 +34,5 @@ export declare class GuildBasedResource<T = any, S = any> {
|
|
|
34
34
|
removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
35
35
|
hashId(id: string): string;
|
|
36
36
|
hashGuildId(guild: string, id: string): string;
|
|
37
|
+
flush(guild?: '*' | (string & {})): unknown[] | Promise<unknown[]>;
|
|
37
38
|
}
|
|
@@ -93,5 +93,17 @@ class GuildBasedResource {
|
|
|
93
93
|
hashGuildId(guild, id) {
|
|
94
94
|
return id.startsWith(this.namespace) ? id : `${this.namespace}.${guild}.${id}`;
|
|
95
95
|
}
|
|
96
|
+
flush(guild = '*') {
|
|
97
|
+
return (0, common_1.fakePromise)(this.keys(guild)).then(keys => {
|
|
98
|
+
return (0, common_1.fakePromise)(this.adapter.bulkRemove(keys)).then(() => {
|
|
99
|
+
const maybePromises = [];
|
|
100
|
+
for (const i of keys) {
|
|
101
|
+
const guildId = i.split('.').at(-2);
|
|
102
|
+
maybePromises.push(this.removeRelationship(guildId));
|
|
103
|
+
}
|
|
104
|
+
return this.adapter.isAsync ? Promise.all(maybePromises) : maybePromises;
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
96
108
|
}
|
|
97
109
|
exports.GuildBasedResource = GuildBasedResource;
|
|
@@ -33,4 +33,5 @@ export declare class GuildRelatedResource<T = any, S = any> {
|
|
|
33
33
|
removeToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
34
34
|
removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
35
35
|
hashId(id: string): string;
|
|
36
|
+
flush(guild: string): import("../../../common").Awaitable<void>;
|
|
36
37
|
}
|
|
@@ -99,5 +99,12 @@ class GuildRelatedResource {
|
|
|
99
99
|
hashId(id) {
|
|
100
100
|
return id.startsWith(this.namespace) ? id : `${this.namespace}.${id}`;
|
|
101
101
|
}
|
|
102
|
+
flush(guild) {
|
|
103
|
+
return (0, common_1.fakePromise)(this.keys(guild)).then(keys => {
|
|
104
|
+
return (0, common_1.fakePromise)(this.adapter.bulkRemove(keys)).then(() => {
|
|
105
|
+
return this.removeRelationship(guild);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
exports.GuildRelatedResource = GuildRelatedResource;
|
|
@@ -60,7 +60,7 @@ class Guilds extends base_1.BaseResource {
|
|
|
60
60
|
this.cache.voiceStates?.hashId(id),
|
|
61
61
|
this.cache.presences?.hashId(id),
|
|
62
62
|
this.cache.stageInstances?.hashId(id),
|
|
63
|
-
].filter(
|
|
63
|
+
].filter(x => x !== undefined));
|
|
64
64
|
await super.remove(id);
|
|
65
65
|
}
|
|
66
66
|
async set(id, data) {
|
|
@@ -33,7 +33,7 @@ class Members extends guild_based_1.GuildBasedResource {
|
|
|
33
33
|
const user = users?.find(x => x.id === rawMember.id);
|
|
34
34
|
return user ? transformers_1.Transformers.GuildMember(this.client, rawMember, user, guild) : undefined;
|
|
35
35
|
})
|
|
36
|
-
.filter(
|
|
36
|
+
.filter(x => x !== undefined)));
|
|
37
37
|
}
|
|
38
38
|
bulkRaw(ids, guild) {
|
|
39
39
|
return super.bulk(ids, guild);
|
|
@@ -44,7 +44,7 @@ class Members extends guild_based_1.GuildBasedResource {
|
|
|
44
44
|
const user = users?.find(x => x.id === rawMember.id);
|
|
45
45
|
return user ? transformers_1.Transformers.GuildMember(this.client, rawMember, user, rawMember.guild_id) : undefined;
|
|
46
46
|
})
|
|
47
|
-
.filter(
|
|
47
|
+
.filter(x => x !== undefined)));
|
|
48
48
|
}
|
|
49
49
|
valuesRaw(guild) {
|
|
50
50
|
return super.values(guild);
|
|
@@ -37,7 +37,7 @@ class Messages extends guild_related_1.GuildRelatedResource {
|
|
|
37
37
|
})
|
|
38
38
|
: undefined;
|
|
39
39
|
})
|
|
40
|
-
.filter(
|
|
40
|
+
.filter(x => x !== undefined));
|
|
41
41
|
}
|
|
42
42
|
bulkRaw(ids) {
|
|
43
43
|
return super.bulk(ids);
|
|
@@ -47,13 +47,13 @@ class Messages extends guild_related_1.GuildRelatedResource {
|
|
|
47
47
|
const hashes = this.cache.users
|
|
48
48
|
? messages.map(x => (x.user_id ? this.cache.users?.hashId(x.user_id) : undefined))
|
|
49
49
|
: [];
|
|
50
|
-
return (0, common_1.fakePromise)(this.cache.adapter.bulkGet(hashes.filter(
|
|
50
|
+
return (0, common_1.fakePromise)(this.cache.adapter.bulkGet(hashes.filter(x => x !== undefined))).then(users => {
|
|
51
51
|
return messages
|
|
52
52
|
.map(message => {
|
|
53
53
|
const user = users.find(user => user.id === message.user_id);
|
|
54
54
|
return user ? transformers_1.Transformers.Message(this.client, { ...message, author: user }) : undefined;
|
|
55
55
|
})
|
|
56
|
-
.filter(
|
|
56
|
+
.filter(x => x !== undefined);
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -23,7 +23,7 @@ class VoiceStates extends guild_based_1.GuildBasedResource {
|
|
|
23
23
|
bulk(ids, guild) {
|
|
24
24
|
return (0, common_1.fakePromise)(super.bulk(ids, guild)).then(states => states
|
|
25
25
|
.map(state => (state ? transformers_1.Transformers.VoiceState(this.client, state) : undefined))
|
|
26
|
-
.filter(
|
|
26
|
+
.filter(x => x !== undefined));
|
|
27
27
|
}
|
|
28
28
|
bulkRaw(ids, guild) {
|
|
29
29
|
return super.bulk(ids, guild);
|
|
@@ -47,10 +47,10 @@ export type CommandMetadata<T extends readonly (keyof RegisteredMiddlewares)[]>
|
|
|
47
47
|
export type MessageCommandOptionErrors = ['CHANNEL_TYPES', type: ChannelType[]] | ['STRING_MIN_LENGTH', min: number] | ['STRING_MAX_LENGTH', max: number] | ['STRING_INVALID_CHOICE', choices: readonly {
|
|
48
48
|
name: string;
|
|
49
49
|
value: string;
|
|
50
|
-
}[]] | ['NUMBER_NAN', value: string
|
|
50
|
+
}[]] | ['NUMBER_NAN', value: string] | ['NUMBER_MIN_VALUE', min: number] | ['NUMBER_MAX_VALUE', max: number] | ['NUMBER_INVALID_CHOICE', choices: readonly {
|
|
51
51
|
name: string;
|
|
52
52
|
value: number;
|
|
53
|
-
}[]] | ['OPTION_REQUIRED'] | ['UNKNOWN', error: unknown];
|
|
53
|
+
}[]] | ['NUMBER_OUT_OF_BOUNDS', value: number] | ['OPTION_REQUIRED'] | ['UNKNOWN', error: unknown];
|
|
54
54
|
export type OnOptionsReturnObject = Record<string, {
|
|
55
55
|
failed: false;
|
|
56
56
|
value: unknown;
|
package/lib/commands/handle.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare class HandleCommand {
|
|
|
54
54
|
context: MenuCommandContext<UserCommandInteraction<boolean> | MessageCommandInteraction<boolean>, never>;
|
|
55
55
|
};
|
|
56
56
|
runOptions(command: Command | SubCommand, context: CommandContext, resolver: OptionResolverStructure): Promise<boolean>;
|
|
57
|
-
argsOptionsParser(command: Command | SubCommand, message: GatewayMessageCreateDispatchData, args:
|
|
57
|
+
argsOptionsParser(command: Command | SubCommand, message: GatewayMessageCreateDispatchData, args: Record<string, string>, resolved: MakeRequired<ContextOptionsResolved>): Promise<{
|
|
58
58
|
errors: {
|
|
59
59
|
name: string;
|
|
60
60
|
error: string;
|
package/lib/commands/handle.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HandleCommand = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const transformers_1 = require("../client/transformers");
|
|
6
|
+
const constants_1 = require("../common/it/constants");
|
|
6
7
|
const components_1 = require("../components");
|
|
7
8
|
const structures_1 = require("../structures");
|
|
8
9
|
const types_1 = require("../types");
|
|
@@ -508,6 +509,8 @@ class HandleCommand {
|
|
|
508
509
|
let indexAttachment = -1;
|
|
509
510
|
for (const i of (command.options ?? [])) {
|
|
510
511
|
try {
|
|
512
|
+
if (!args[i.name] && i.type !== types_1.ApplicationCommandOptionType.Attachment)
|
|
513
|
+
continue;
|
|
511
514
|
let value;
|
|
512
515
|
switch (i.type) {
|
|
513
516
|
case types_1.ApplicationCommandOptionType.Attachment:
|
|
@@ -517,9 +520,7 @@ class HandleCommand {
|
|
|
517
520
|
}
|
|
518
521
|
break;
|
|
519
522
|
case types_1.ApplicationCommandOptionType.Boolean:
|
|
520
|
-
|
|
521
|
-
value = ['yes', 'y', 'true', 'treu'].includes(args[i.name].toLowerCase());
|
|
522
|
-
}
|
|
523
|
+
value = ['yes', 'y', 'true', 'treu'].includes(args[i.name].toLowerCase());
|
|
523
524
|
break;
|
|
524
525
|
case types_1.ApplicationCommandOptionType.Channel:
|
|
525
526
|
{
|
|
@@ -528,24 +529,23 @@ class HandleCommand {
|
|
|
528
529
|
if (!rawQuery)
|
|
529
530
|
continue;
|
|
530
531
|
const channel = (await this.client.cache.channels?.raw(rawQuery)) ?? (await this.fetchChannel(i, rawQuery));
|
|
531
|
-
if (channel)
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
532
|
+
if (!channel)
|
|
533
|
+
break;
|
|
534
|
+
if ('channel_types' in i) {
|
|
535
|
+
if (!i.channel_types.includes(channel.type)) {
|
|
536
|
+
errors.push({
|
|
537
|
+
name: i.name,
|
|
538
|
+
error: `The entered channel type is not one of ${i
|
|
539
|
+
.channel_types.map(t => types_1.ChannelType[t])
|
|
540
|
+
.join(', ')}`,
|
|
541
|
+
fullError: ['CHANNEL_TYPES', i.channel_types],
|
|
542
|
+
});
|
|
543
|
+
break;
|
|
544
544
|
}
|
|
545
|
-
value = channel.id;
|
|
546
|
-
//discord funny memoentnt!!!!!!!!
|
|
547
|
-
resolved.channels[channel.id] = channel;
|
|
548
545
|
}
|
|
546
|
+
value = channel.id;
|
|
547
|
+
//discord funny memoentnt!!!!!!!!
|
|
548
|
+
resolved.channels[channel.id] = channel;
|
|
549
549
|
}
|
|
550
550
|
break;
|
|
551
551
|
case types_1.ApplicationCommandOptionType.Mentionable:
|
|
@@ -613,116 +613,111 @@ class HandleCommand {
|
|
|
613
613
|
break;
|
|
614
614
|
case types_1.ApplicationCommandOptionType.String:
|
|
615
615
|
{
|
|
616
|
-
value = args[i.name];
|
|
617
616
|
const option = i;
|
|
618
|
-
if (
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
});
|
|
617
|
+
if (option.choices?.length) {
|
|
618
|
+
const choice = option.choices.find(x => x.name === args[i.name]);
|
|
619
|
+
if (!choice) {
|
|
620
|
+
errors.push({
|
|
621
|
+
name: i.name,
|
|
622
|
+
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
|
623
|
+
.map(x => x.name)
|
|
624
|
+
.join(', ')}`,
|
|
625
|
+
fullError: ['STRING_INVALID_CHOICE', option.choices],
|
|
626
|
+
});
|
|
629
627
|
break;
|
|
630
628
|
}
|
|
629
|
+
value = choice.value;
|
|
630
|
+
break;
|
|
631
631
|
}
|
|
632
|
-
if (option.
|
|
633
|
-
if (
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
fullError: ['STRING_MAX_LENGTH', option.max_length],
|
|
640
|
-
});
|
|
632
|
+
if (option.min_length !== undefined) {
|
|
633
|
+
if (args[i.name].length < option.min_length) {
|
|
634
|
+
errors.push({
|
|
635
|
+
name: i.name,
|
|
636
|
+
error: `The entered string has less than ${option.min_length} characters. The minimum required is ${option.min_length} characters`,
|
|
637
|
+
fullError: ['STRING_MIN_LENGTH', option.min_length],
|
|
638
|
+
});
|
|
641
639
|
break;
|
|
642
640
|
}
|
|
643
641
|
}
|
|
644
|
-
if (option.
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
|
652
|
-
.map(x => x.name)
|
|
653
|
-
.join(', ')}.`,
|
|
654
|
-
fullError: ['STRING_INVALID_CHOICE', option.choices],
|
|
655
|
-
});
|
|
642
|
+
if (option.max_length !== undefined) {
|
|
643
|
+
if (args[i.name].length > option.max_length) {
|
|
644
|
+
errors.push({
|
|
645
|
+
name: i.name,
|
|
646
|
+
error: `The entered string has more than ${option.max_length} characters. The maximum required is ${option.max_length} characters`,
|
|
647
|
+
fullError: ['STRING_MAX_LENGTH', option.max_length],
|
|
648
|
+
});
|
|
656
649
|
break;
|
|
657
650
|
}
|
|
658
|
-
value = choice.value;
|
|
659
651
|
}
|
|
652
|
+
value = args[i.name];
|
|
660
653
|
}
|
|
661
654
|
break;
|
|
662
655
|
case types_1.ApplicationCommandOptionType.Number:
|
|
663
656
|
case types_1.ApplicationCommandOptionType.Integer:
|
|
664
657
|
{
|
|
665
658
|
const option = i;
|
|
666
|
-
if (
|
|
667
|
-
|
|
668
|
-
if (
|
|
669
|
-
|
|
659
|
+
if (option.choices?.length) {
|
|
660
|
+
const choice = option.choices.find(x => x.name === args[i.name]);
|
|
661
|
+
if (!choice) {
|
|
662
|
+
errors.push({
|
|
663
|
+
name: i.name,
|
|
664
|
+
error: `The entered choice is invalid. Please choose one of the following options: ${option.choices
|
|
665
|
+
.map(x => x.name)
|
|
666
|
+
.join(', ')}`,
|
|
667
|
+
fullError: ['NUMBER_INVALID_CHOICE', option.choices],
|
|
668
|
+
});
|
|
670
669
|
break;
|
|
671
670
|
}
|
|
672
|
-
|
|
671
|
+
value = choice.value;
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
value =
|
|
675
|
+
i.type === types_1.ApplicationCommandOptionType.Integer
|
|
676
|
+
? Math.trunc(Number(args[i.name]))
|
|
677
|
+
: Number(args[i.name]);
|
|
678
|
+
if (Number.isNaN(value)) {
|
|
679
|
+
value = undefined;
|
|
680
|
+
errors.push({
|
|
681
|
+
name: i.name,
|
|
682
|
+
error: 'The entered choice is an invalid number',
|
|
683
|
+
fullError: ['NUMBER_NAN', args[i.name]],
|
|
684
|
+
});
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
if (value <= -constants_1.INTEGER_OPTION_VALUE_LIMIT || value >= constants_1.INTEGER_OPTION_VALUE_LIMIT) {
|
|
688
|
+
value = undefined;
|
|
689
|
+
errors.push({
|
|
690
|
+
name: i.name,
|
|
691
|
+
error: 'The entered number must be between -2^53 and 2^53',
|
|
692
|
+
fullError: ['NUMBER_OUT_OF_BOUNDS', constants_1.INTEGER_OPTION_VALUE_LIMIT],
|
|
693
|
+
});
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
if (option.min_value !== undefined) {
|
|
697
|
+
if (value < option.min_value) {
|
|
673
698
|
value = undefined;
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
});
|
|
699
|
+
errors.push({
|
|
700
|
+
name: i.name,
|
|
701
|
+
error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
|
|
702
|
+
fullError: ['NUMBER_MIN_VALUE', option.min_value],
|
|
703
|
+
});
|
|
680
704
|
break;
|
|
681
705
|
}
|
|
682
|
-
if (option.min_value) {
|
|
683
|
-
if (value < option.min_value) {
|
|
684
|
-
value = undefined;
|
|
685
|
-
if (i.required)
|
|
686
|
-
errors.push({
|
|
687
|
-
name: i.name,
|
|
688
|
-
error: `The entered number is less than ${option.min_value}. The minimum allowed is ${option.min_value}`,
|
|
689
|
-
fullError: ['NUMBER_MIN_VALUE', option.min_value],
|
|
690
|
-
});
|
|
691
|
-
break;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
if (option.max_value) {
|
|
695
|
-
if (value > option.max_value) {
|
|
696
|
-
value = undefined;
|
|
697
|
-
if (i.required)
|
|
698
|
-
errors.push({
|
|
699
|
-
name: i.name,
|
|
700
|
-
error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
|
|
701
|
-
fullError: ['NUMBER_MAX_VALUE', option.max_value],
|
|
702
|
-
});
|
|
703
|
-
break;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
break;
|
|
707
706
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
if (i.required)
|
|
707
|
+
if (option.max_value !== undefined) {
|
|
708
|
+
if (value > option.max_value) {
|
|
709
|
+
value = undefined;
|
|
712
710
|
errors.push({
|
|
713
711
|
name: i.name,
|
|
714
|
-
error: `The entered
|
|
715
|
-
|
|
716
|
-
.join(', ')}.`,
|
|
717
|
-
fullError: ['NUMBER_INVALID_CHOICE', option.choices],
|
|
712
|
+
error: `The entered number is greater than ${option.max_value}. The maximum allowed is ${option.max_value}`,
|
|
713
|
+
fullError: ['NUMBER_MAX_VALUE', option.max_value],
|
|
718
714
|
});
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
719
717
|
break;
|
|
720
718
|
}
|
|
721
|
-
value = choice.value;
|
|
722
719
|
}
|
|
723
720
|
break;
|
|
724
|
-
default:
|
|
725
|
-
break;
|
|
726
721
|
}
|
|
727
722
|
if (value !== undefined) {
|
|
728
723
|
options.push({
|
|
@@ -36,3 +36,4 @@ export declare const DiscordEpoch = 1420070400000n;
|
|
|
36
36
|
export declare const BASE_HOST = "https://discord.com";
|
|
37
37
|
export declare const BASE_URL = "https://discord.com/api";
|
|
38
38
|
export declare const CDN_URL = "https://cdn.discordapp.com";
|
|
39
|
+
export declare const INTEGER_OPTION_VALUE_LIMIT: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CDN_URL = exports.BASE_URL = exports.BASE_HOST = exports.DiscordEpoch = exports.EmbedColors = void 0;
|
|
3
|
+
exports.INTEGER_OPTION_VALUE_LIMIT = exports.CDN_URL = exports.BASE_URL = exports.BASE_HOST = exports.DiscordEpoch = exports.EmbedColors = void 0;
|
|
4
4
|
var EmbedColors;
|
|
5
5
|
(function (EmbedColors) {
|
|
6
6
|
EmbedColors[EmbedColors["Default"] = 0] = "Default";
|
|
@@ -40,3 +40,4 @@ exports.DiscordEpoch = 1420070400000n;
|
|
|
40
40
|
exports.BASE_HOST = 'https://discord.com';
|
|
41
41
|
exports.BASE_URL = `${exports.BASE_HOST}/api`;
|
|
42
42
|
exports.CDN_URL = 'https://cdn.discordapp.com';
|
|
43
|
+
exports.INTEGER_OPTION_VALUE_LIMIT = 2 ** 53;
|
|
@@ -14,7 +14,6 @@ var ApplicationCommandPermissionType;
|
|
|
14
14
|
* https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants
|
|
15
15
|
*/
|
|
16
16
|
exports.APIApplicationCommandPermissionsConstant = {
|
|
17
|
-
// eslint-disable-next-line unicorn/prefer-native-coercion-functions
|
|
18
17
|
Everyone: (guildId) => String(guildId),
|
|
19
18
|
AllChannels: (guildId) => String(BigInt(guildId) - 1n),
|
|
20
19
|
};
|
package/lib/types/utils/index.js
CHANGED
|
@@ -55,9 +55,7 @@ exports.FormattingPatterns = {
|
|
|
55
55
|
*
|
|
56
56
|
* The `fullName` (possibly including `name`, `subcommandOrGroup` and `subcommand`) and `id` group properties are present on the `exec` result of this expression
|
|
57
57
|
*/
|
|
58
|
-
SlashCommand:
|
|
59
|
-
// eslint-disable-next-line unicorn/no-unsafe-regex
|
|
60
|
-
/<\/(?<fullName>(?<name>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32})(?: (?<subcommandOrGroup>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32}))?(?: (?<subcommand>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32}))?):(?<id>\d{17,20})>/u,
|
|
58
|
+
SlashCommand: /<\/(?<fullName>(?<name>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32})(?: (?<subcommandOrGroup>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32}))?(?: (?<subcommand>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32}))?):(?<id>\d{17,20})>/u,
|
|
61
59
|
/**
|
|
62
60
|
* Regular expression for matching a custom emoji, either static or animated
|
|
63
61
|
*
|
|
@@ -81,7 +79,6 @@ exports.FormattingPatterns = {
|
|
|
81
79
|
*
|
|
82
80
|
* The `timestamp` and `style` group properties are present on the `exec` result of this expression
|
|
83
81
|
*/
|
|
84
|
-
// eslint-disable-next-line prefer-named-capture-group
|
|
85
82
|
Timestamp: /<t:(?<timestamp>-?\d{1,13})(:(?<style>[DFRTdft]))?>/,
|
|
86
83
|
/**
|
|
87
84
|
* Regular expression for matching strictly default styled timestamps
|
|
@@ -370,7 +367,6 @@ exports.PermissionFlagsBits = {
|
|
|
370
367
|
/**
|
|
371
368
|
* Allows kicking members
|
|
372
369
|
*/
|
|
373
|
-
// eslint-disable-next-line sonarjs/no-identical-expressions
|
|
374
370
|
KickMembers: 1n << 1n,
|
|
375
371
|
/**
|
|
376
372
|
* Allows banning members
|
|
@@ -729,7 +725,6 @@ var ChannelType;
|
|
|
729
725
|
*
|
|
730
726
|
* @deprecated This is the old name for {@apilink ChannelType#AnnouncementThread}
|
|
731
727
|
*/
|
|
732
|
-
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
733
728
|
ChannelType[ChannelType["GuildNewsThread"] = 10] = "GuildNewsThread";
|
|
734
729
|
/**
|
|
735
730
|
* A temporary sub-channel within a Guild Text channel
|