lunibee 0.2.3 → 0.2.4
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/LICENSE +21 -21
- package/README.md +225 -225
- package/dist/builders/attachment.d.ts +8 -0
- package/dist/builders/commands.d.ts +122 -65
- package/dist/builders/components.d.ts +10 -31
- package/dist/builders/embed.d.ts +66 -33
- package/dist/builders/index.js +97 -131
- package/dist/builders/index.js.map +8 -8
- package/dist/collection/cache.d.ts +13 -6
- package/dist/collection/index.d.ts +90 -17
- package/dist/collection/index.js +442 -266
- package/dist/collection/index.js.map +4 -4
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +607 -352
- package/dist/core/index.js.map +47 -47
- package/dist/core/permissions.d.ts +7 -3
- package/dist/formatters/index.js +9 -5
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js +5 -10
- package/dist/handlers/index.js.map +3 -3
- package/dist/index.js +769 -587
- package/dist/index.js.map +65 -65
- package/dist/managers/base.d.ts +22 -14
- package/dist/managers/index.d.ts +2 -1
- package/dist/managers/index.js +445 -276
- package/dist/managers/index.js.map +26 -26
- package/dist/managers/message.d.ts +7 -3
- package/dist/rest/errors.d.ts +14 -7
- package/dist/rest/index.d.ts +24 -12
- package/dist/rest/index.js +54 -17
- package/dist/rest/index.js.map +14 -14
- package/dist/rest/redis.d.ts +1 -1
- package/dist/rest/route.d.ts +8 -4
- package/dist/rest/routes.d.ts +102 -48
- package/dist/rest/transport.d.ts +10 -5
- package/dist/rest/webhook.d.ts +9 -5
- package/dist/sharding/bus.d.ts +34 -17
- package/dist/sharding/index.d.ts +34 -17
- package/dist/sharding/index.js +64 -32
- package/dist/sharding/index.js.map +17 -17
- package/dist/structures/base.d.ts +19 -10
- package/dist/structures/channels.d.ts +28 -14
- package/dist/structures/index.js +9 -59
- package/dist/structures/index.js.map +19 -18
- package/dist/structures/interactions.d.ts +96 -48
- package/dist/structures/resources.d.ts +88 -44
- package/dist/types/gateway.d.ts +1 -1
- package/dist/types/index.js +20 -22
- package/dist/types/index.js.map +4 -4
- package/dist/utils/index.js.map +2 -2
- package/dist/voice/index.d.ts +12 -4
- package/dist/voice/index.js +14 -18
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/decoder.d.ts +6 -2
- package/dist/ws/index.d.ts +25 -13
- package/dist/ws/index.js +63 -31
- package/dist/ws/index.js.map +14 -14
- package/dist/ws/protocol.d.ts +10 -2
- package/dist/ws/session.d.ts +14 -4
- package/dist/ws/state.d.ts +22 -11
- package/package.json +15 -14
package/dist/builders/index.js
CHANGED
|
@@ -185,16 +185,6 @@ var IntentBits = {
|
|
|
185
185
|
directMessagePolls: 1 << 25
|
|
186
186
|
};
|
|
187
187
|
// packages/types/src/index.ts
|
|
188
|
-
var ButtonType = {
|
|
189
|
-
Primary: 1,
|
|
190
|
-
Secondary: 2,
|
|
191
|
-
Success: 3,
|
|
192
|
-
Danger: 4,
|
|
193
|
-
Link: 5,
|
|
194
|
-
Premium: 6
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// packages/builders/src/components.ts
|
|
198
188
|
var ComponentEnum = {
|
|
199
189
|
ActionRow: 1,
|
|
200
190
|
Button: 2,
|
|
@@ -213,6 +203,16 @@ var ComponentEnum = {
|
|
|
213
203
|
ContentInventoryEntry: 16,
|
|
214
204
|
Container: 17
|
|
215
205
|
};
|
|
206
|
+
var ButtonType = {
|
|
207
|
+
Primary: 1,
|
|
208
|
+
Secondary: 2,
|
|
209
|
+
Success: 3,
|
|
210
|
+
Danger: 4,
|
|
211
|
+
Link: 5,
|
|
212
|
+
Premium: 6
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// packages/builders/src/components.ts
|
|
216
216
|
var TextInputType = { Short: 1, Paragraph: 2 };
|
|
217
217
|
|
|
218
218
|
class CreateActionRow {
|
|
@@ -240,38 +240,50 @@ class CreateActionRow {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
class
|
|
244
|
-
#
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
class CreateSelectMenu {
|
|
244
|
+
#select;
|
|
245
|
+
constructor(data) {
|
|
246
|
+
this.#select = data;
|
|
247
|
+
}
|
|
247
248
|
setCustomId(value) {
|
|
248
249
|
validateText(value, 100, "Component custom ID");
|
|
249
|
-
this.#
|
|
250
|
+
this.#select.custom_id = value;
|
|
250
251
|
return this;
|
|
251
252
|
}
|
|
252
253
|
setPlaceholder(value) {
|
|
253
254
|
validateText(value, 150, "Component placeholder");
|
|
254
|
-
this.#
|
|
255
|
+
this.#select.placeholder = value;
|
|
255
256
|
return this;
|
|
256
257
|
}
|
|
257
258
|
setMinValues(value) {
|
|
258
259
|
validateCount(value, "min_values", 0);
|
|
259
|
-
this.#
|
|
260
|
+
this.#select.min_values = value;
|
|
260
261
|
return this;
|
|
261
262
|
}
|
|
262
263
|
setMaxValues(value) {
|
|
263
264
|
validateCount(value, "max_values", 1);
|
|
264
|
-
this.#
|
|
265
|
+
this.#select.max_values = value;
|
|
265
266
|
return this;
|
|
266
267
|
}
|
|
267
268
|
setRequired(value = true) {
|
|
268
|
-
this.#
|
|
269
|
+
this.#select.required = value;
|
|
269
270
|
return this;
|
|
270
271
|
}
|
|
271
272
|
setDisabled(value = true) {
|
|
272
|
-
this.#
|
|
273
|
+
this.#select.disabled = value;
|
|
273
274
|
return this;
|
|
274
275
|
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
class CreateStringSelect extends CreateSelectMenu {
|
|
279
|
+
#data;
|
|
280
|
+
constructor() {
|
|
281
|
+
const data = {
|
|
282
|
+
type: ComponentEnum.StringSelect
|
|
283
|
+
};
|
|
284
|
+
super(data);
|
|
285
|
+
this.#data = data;
|
|
286
|
+
}
|
|
275
287
|
addOptions(...options) {
|
|
276
288
|
if (!options.length)
|
|
277
289
|
throw new TypeError("At least one select option is required.");
|
|
@@ -387,40 +399,14 @@ class CreateButton {
|
|
|
387
399
|
}
|
|
388
400
|
}
|
|
389
401
|
|
|
390
|
-
class CreateEntitySelect {
|
|
402
|
+
class CreateEntitySelect extends CreateSelectMenu {
|
|
391
403
|
#data;
|
|
392
404
|
constructor(type) {
|
|
393
405
|
if (type !== ComponentEnum.UserSelect && type !== ComponentEnum.RoleSelect && type !== ComponentEnum.MentionableSelect && type !== ComponentEnum.ChannelSelect)
|
|
394
406
|
throw new TypeError("Invalid select component type.");
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
validateText(value, 100, "Component custom ID");
|
|
399
|
-
this.#data.custom_id = value;
|
|
400
|
-
return this;
|
|
401
|
-
}
|
|
402
|
-
setPlaceholder(value) {
|
|
403
|
-
validateText(value, 150, "Component placeholder");
|
|
404
|
-
this.#data.placeholder = value;
|
|
405
|
-
return this;
|
|
406
|
-
}
|
|
407
|
-
setMinValues(value) {
|
|
408
|
-
validateCount(value, "min_values", 0);
|
|
409
|
-
this.#data.min_values = value;
|
|
410
|
-
return this;
|
|
411
|
-
}
|
|
412
|
-
setMaxValues(value) {
|
|
413
|
-
validateCount(value, "max_values", 1);
|
|
414
|
-
this.#data.max_values = value;
|
|
415
|
-
return this;
|
|
416
|
-
}
|
|
417
|
-
setRequired(value = true) {
|
|
418
|
-
this.#data.required = value;
|
|
419
|
-
return this;
|
|
420
|
-
}
|
|
421
|
-
setDisabled(value = true) {
|
|
422
|
-
this.#data.disabled = value;
|
|
423
|
-
return this;
|
|
407
|
+
const data = { type };
|
|
408
|
+
super(data);
|
|
409
|
+
this.#data = data;
|
|
424
410
|
}
|
|
425
411
|
setDefaultValues(...values) {
|
|
426
412
|
this.#data.default_values = values.map((value) => ({ ...value }));
|
|
@@ -878,16 +864,7 @@ class CreateSlashCommand {
|
|
|
878
864
|
return structuredClone(this.#data);
|
|
879
865
|
}
|
|
880
866
|
addOption(option) {
|
|
881
|
-
|
|
882
|
-
if (options.length >= 25)
|
|
883
|
-
throw new RangeError("An application command cannot contain more than 25 options.");
|
|
884
|
-
const payload = option.toJSON();
|
|
885
|
-
if (options.some((existing) => existing.name === payload.name))
|
|
886
|
-
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
887
|
-
if (payload.required === true && options.some((existing) => existing.required !== true))
|
|
888
|
-
throw new RangeError("Required application command options must be placed before optional options.");
|
|
889
|
-
options.push(payload);
|
|
890
|
-
this.#data.options = options;
|
|
867
|
+
this.#data.options = appendOption(this.#data.options, option.toJSON(), "application command");
|
|
891
868
|
return this;
|
|
892
869
|
}
|
|
893
870
|
}
|
|
@@ -925,21 +902,9 @@ class CreateStringOption extends CreateCommandOption {
|
|
|
925
902
|
super(ApplicationCommandOptionEnum.String);
|
|
926
903
|
}
|
|
927
904
|
addChoices(...choices) {
|
|
928
|
-
const
|
|
929
|
-
if (!choices.length)
|
|
930
|
-
throw new TypeError("At least one choice is required.");
|
|
931
|
-
if (this.data.autocomplete === true)
|
|
932
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
933
|
-
if (current.length + choices.length > 25)
|
|
934
|
-
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
935
|
-
for (const choice of choices) {
|
|
936
|
-
validateText2(choice.name, "Choice name", 100);
|
|
905
|
+
for (const choice of choices)
|
|
937
906
|
validateText2(choice.value, "Choice value", 100);
|
|
938
|
-
|
|
939
|
-
this.data.choices = [
|
|
940
|
-
...current,
|
|
941
|
-
...choices.map((choice) => ({ ...choice }))
|
|
942
|
-
];
|
|
907
|
+
appendChoices(this.data, choices);
|
|
943
908
|
return this;
|
|
944
909
|
}
|
|
945
910
|
setMinLength(value) {
|
|
@@ -956,18 +921,21 @@ class CreateStringOption extends CreateCommandOption {
|
|
|
956
921
|
}
|
|
957
922
|
}
|
|
958
923
|
|
|
959
|
-
class
|
|
960
|
-
|
|
961
|
-
|
|
924
|
+
class CreateNumericOption extends CreateCommandOption {
|
|
925
|
+
#integer;
|
|
926
|
+
constructor(type, integer) {
|
|
927
|
+
super(type);
|
|
928
|
+
this.#integer = integer;
|
|
962
929
|
}
|
|
963
930
|
setMinValue(value) {
|
|
964
|
-
validateNumberRange(value, -
|
|
931
|
+
validateNumberRange(value, -MAX_SAFE, MAX_SAFE, "min_value", this.#integer);
|
|
965
932
|
this.data.min_value = value;
|
|
966
933
|
return this;
|
|
967
934
|
}
|
|
968
935
|
setMaxValue(value) {
|
|
969
|
-
validateNumberRange(value, -
|
|
970
|
-
|
|
936
|
+
validateNumberRange(value, -MAX_SAFE, MAX_SAFE, "max_value", this.#integer);
|
|
937
|
+
const min = this.data.min_value;
|
|
938
|
+
if (min !== undefined && min > value)
|
|
971
939
|
throw new RangeError("min_value cannot exceed max_value.");
|
|
972
940
|
this.data.max_value = value;
|
|
973
941
|
return this;
|
|
@@ -979,50 +947,20 @@ class CreateIntegerOption extends CreateCommandOption {
|
|
|
979
947
|
return this;
|
|
980
948
|
}
|
|
981
949
|
addChoices(...choices) {
|
|
982
|
-
|
|
983
|
-
if (!choices.length)
|
|
984
|
-
throw new TypeError("At least one choice is required.");
|
|
985
|
-
if (this.data.autocomplete === true)
|
|
986
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
987
|
-
if (current.length + choices.length > 25)
|
|
988
|
-
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
989
|
-
this.data.choices = [...current, ...choices];
|
|
950
|
+
appendChoices(this.data, choices);
|
|
990
951
|
return this;
|
|
991
952
|
}
|
|
992
953
|
}
|
|
993
954
|
|
|
994
|
-
class
|
|
955
|
+
class CreateIntegerOption extends CreateNumericOption {
|
|
995
956
|
constructor() {
|
|
996
|
-
super(ApplicationCommandOptionEnum.
|
|
997
|
-
}
|
|
998
|
-
setMinValue(value) {
|
|
999
|
-
validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", false);
|
|
1000
|
-
this.data.min_value = value;
|
|
1001
|
-
return this;
|
|
957
|
+
super(ApplicationCommandOptionEnum.Integer, true);
|
|
1002
958
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
return this;
|
|
1009
|
-
}
|
|
1010
|
-
setAutocomplete(enabled = true) {
|
|
1011
|
-
if (enabled && Array.isArray(this.data.choices) && this.data.choices.length)
|
|
1012
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
1013
|
-
this.data.autocomplete = enabled;
|
|
1014
|
-
return this;
|
|
1015
|
-
}
|
|
1016
|
-
addChoices(...choices) {
|
|
1017
|
-
const current = this.data.choices ?? [];
|
|
1018
|
-
if (!choices.length)
|
|
1019
|
-
throw new TypeError("At least one choice is required.");
|
|
1020
|
-
if (this.data.autocomplete === true)
|
|
1021
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
1022
|
-
if (current.length + choices.length > 25)
|
|
1023
|
-
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
1024
|
-
this.data.choices = [...current, ...choices];
|
|
1025
|
-
return this;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
class CreateNumberOption extends CreateNumericOption {
|
|
962
|
+
constructor() {
|
|
963
|
+
super(ApplicationCommandOptionEnum.Number, false);
|
|
1026
964
|
}
|
|
1027
965
|
}
|
|
1028
966
|
|
|
@@ -1101,17 +1039,9 @@ class CreateSubcommand extends CreateCommandOption {
|
|
|
1101
1039
|
}
|
|
1102
1040
|
addChildOption(option) {
|
|
1103
1041
|
const options = this.data.options ?? [];
|
|
1104
|
-
if (options.length >= 25)
|
|
1105
|
-
throw new RangeError("A subcommand cannot contain more than 25 options.");
|
|
1106
|
-
const payload = option.toJSON();
|
|
1107
|
-
if (options.some((existing) => existing.name === payload.name))
|
|
1108
|
-
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
1109
|
-
if (payload.required === true && options.some((existing) => existing.required !== true))
|
|
1110
|
-
throw new RangeError("Required subcommand options must be placed before optional options.");
|
|
1111
1042
|
if (options.some((existing) => existing.type === ApplicationCommandOptionEnum.Subcommand))
|
|
1112
1043
|
throw new RangeError("Subcommands cannot contain nested subcommands.");
|
|
1113
|
-
options.
|
|
1114
|
-
this.data.options = options;
|
|
1044
|
+
this.data.options = appendOption(options, option.toJSON(), "subcommand");
|
|
1115
1045
|
return this;
|
|
1116
1046
|
}
|
|
1117
1047
|
}
|
|
@@ -1134,6 +1064,29 @@ class CreateSubcommandGroup extends CreateCommandOption {
|
|
|
1134
1064
|
return this;
|
|
1135
1065
|
}
|
|
1136
1066
|
}
|
|
1067
|
+
var MAX_SAFE = Number.MAX_SAFE_INTEGER;
|
|
1068
|
+
function appendOption(options, payload, parent) {
|
|
1069
|
+
const list = options ?? [];
|
|
1070
|
+
if (list.length >= 25)
|
|
1071
|
+
throw new RangeError(`${parent === "subcommand" ? "A subcommand" : "An application command"} cannot contain more than 25 options.`);
|
|
1072
|
+
if (list.some((existing) => existing.name === payload.name))
|
|
1073
|
+
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
1074
|
+
if (payload.required === true && list.some((existing) => existing.required !== true))
|
|
1075
|
+
throw new RangeError(`Required ${parent} options must be placed before optional options.`);
|
|
1076
|
+
return [...list, payload];
|
|
1077
|
+
}
|
|
1078
|
+
function appendChoices(data, choices) {
|
|
1079
|
+
const current = data.choices ?? [];
|
|
1080
|
+
if (!choices.length)
|
|
1081
|
+
throw new TypeError("At least one choice is required.");
|
|
1082
|
+
if (data.autocomplete === true)
|
|
1083
|
+
throw new RangeError("Autocomplete options cannot define choices.");
|
|
1084
|
+
if (current.length + choices.length > 25)
|
|
1085
|
+
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
1086
|
+
for (const choice of choices)
|
|
1087
|
+
validateText2(choice.name, "Choice name", 100);
|
|
1088
|
+
data.choices = [...current, ...choices.map((choice) => ({ ...choice }))];
|
|
1089
|
+
}
|
|
1137
1090
|
function validateName(value, field) {
|
|
1138
1091
|
if (!/^[\p{L}\p{N}_-]{1,32}$/u.test(value) || value !== value.toLowerCase())
|
|
1139
1092
|
throw new RangeError(`${field} must contain 1-32 lowercase letters, numbers, underscores, or hyphens.`);
|
|
@@ -1223,13 +1176,14 @@ var UserCommandBuilder = CreateUserCommand;
|
|
|
1223
1176
|
var UserOptionBuilder = CreateUserOption;
|
|
1224
1177
|
var ApplicationCommandOptionType = ApplicationCommandOptionEnum;
|
|
1225
1178
|
// packages/builders/src/attachment.ts
|
|
1226
|
-
import { readFile } from "fs/promises";
|
|
1227
|
-
import { basename } from "path";
|
|
1179
|
+
import { readFile, realpath } from "fs/promises";
|
|
1180
|
+
import { basename, isAbsolute, relative, resolve } from "path";
|
|
1228
1181
|
|
|
1229
1182
|
class CreateAttachment {
|
|
1230
1183
|
name;
|
|
1231
1184
|
description;
|
|
1232
1185
|
file;
|
|
1186
|
+
root;
|
|
1233
1187
|
constructor(file, data) {
|
|
1234
1188
|
this.file = file;
|
|
1235
1189
|
if (typeof data === "string") {
|
|
@@ -1237,6 +1191,7 @@ class CreateAttachment {
|
|
|
1237
1191
|
} else {
|
|
1238
1192
|
this.name = data?.name ?? (typeof file === "string" ? basename(file) : "file.bin");
|
|
1239
1193
|
this.description = data?.description;
|
|
1194
|
+
this.root = data?.root;
|
|
1240
1195
|
}
|
|
1241
1196
|
}
|
|
1242
1197
|
setName(name) {
|
|
@@ -1253,7 +1208,8 @@ class CreateAttachment {
|
|
|
1253
1208
|
}
|
|
1254
1209
|
async toBuffer() {
|
|
1255
1210
|
if (typeof this.file === "string") {
|
|
1256
|
-
const
|
|
1211
|
+
const path = this.root === undefined ? this.file : await insideRoot(this.root, this.file);
|
|
1212
|
+
const buffer = await readFile(path);
|
|
1257
1213
|
return new Uint8Array(buffer);
|
|
1258
1214
|
}
|
|
1259
1215
|
if (this.file instanceof Uint8Array)
|
|
@@ -1271,6 +1227,16 @@ class CreateAttachment {
|
|
|
1271
1227
|
}
|
|
1272
1228
|
}
|
|
1273
1229
|
var AttachmentBuilder = CreateAttachment;
|
|
1230
|
+
async function insideRoot(root, file) {
|
|
1231
|
+
const base = await realpath(root);
|
|
1232
|
+
const target = await realpath(resolve(base, file)).catch(() => {
|
|
1233
|
+
throw new Error("Attachment file was not found inside its root.");
|
|
1234
|
+
});
|
|
1235
|
+
const rel = relative(base, target);
|
|
1236
|
+
if (rel === "" || rel.startsWith("..") || isAbsolute(rel))
|
|
1237
|
+
throw new Error("Attachment file is outside its root folder.");
|
|
1238
|
+
return target;
|
|
1239
|
+
}
|
|
1274
1240
|
export {
|
|
1275
1241
|
ActionRowBuilder,
|
|
1276
1242
|
ApplicationCommandOptionEnum,
|
|
@@ -1357,4 +1323,4 @@ export {
|
|
|
1357
1323
|
componentsV2Message
|
|
1358
1324
|
};
|
|
1359
1325
|
|
|
1360
|
-
//# debugId=
|
|
1326
|
+
//# debugId=AAEFB888B204975D64756E2164756E21
|