nexocord 1.2.0 → 1.2.1
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/dist/bin/cli.js +1 -1
- package/dist/core/ui/builders/container.d.ts.map +1 -1
- package/dist/core/ui/builders/select.d.ts +14 -14
- package/dist/core/ui/builders/select.d.ts.map +1 -1
- package/dist/core/ui/index.js +181 -140
- package/dist/core/ui/normalizers/button.d.ts +1 -0
- package/dist/core/ui/normalizers/button.d.ts.map +1 -1
- package/dist/core/ui/normalizers/container.d.ts.map +1 -1
- package/dist/core/ui/normalizers/media.d.ts.map +1 -1
- package/dist/core/ui/normalizers/select.d.ts +1 -1
- package/dist/core/ui/normalizers/select.d.ts.map +1 -1
- package/dist/core/ui/types/button.d.ts +12 -4
- package/dist/core/ui/types/button.d.ts.map +1 -1
- package/dist/core/ui/types/container.d.ts +2 -2
- package/dist/core/ui/types/container.d.ts.map +1 -1
- package/dist/core/ui/utils/formatList.d.ts.map +1 -1
- package/dist/core/ui/utils/splitContainerArgs.d.ts.map +1 -1
- package/dist/core/ui/validators/button.d.ts.map +1 -1
- package/dist/core/ui/validators/container.d.ts.map +1 -1
- package/dist/core/ui/validators/select.d.ts.map +1 -1
- package/dist/index.cjs +181 -140
- package/dist/index.js +185 -144
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -58897,30 +58897,30 @@ function getAttachmentName(attachment) {
|
|
|
58897
58897
|
if (!attachment || typeof attachment !== "object") {
|
|
58898
58898
|
throw new Error("Attachment must be an object with a valid file name.");
|
|
58899
58899
|
}
|
|
58900
|
-
const
|
|
58901
|
-
const name = typeof
|
|
58900
|
+
const file = attachment;
|
|
58901
|
+
const name = typeof file.name === "string" ? file.name : typeof file.data?.name === "string" ? file.data.name : undefined;
|
|
58902
58902
|
if (!name) {
|
|
58903
58903
|
throw new Error("Attachment name was not found. Define a name in AttachmentBuilder options.");
|
|
58904
58904
|
}
|
|
58905
58905
|
return name;
|
|
58906
58906
|
}
|
|
58907
58907
|
// src/core/ui/utils/formatText.ts
|
|
58908
|
-
function
|
|
58908
|
+
function surround(content, marker) {
|
|
58909
58909
|
return `${marker}${content}${marker}`;
|
|
58910
58910
|
}
|
|
58911
|
-
function
|
|
58912
|
-
let
|
|
58913
|
-
let
|
|
58911
|
+
function getCodeFence(content) {
|
|
58912
|
+
let maxRun = 0;
|
|
58913
|
+
let run = 0;
|
|
58914
58914
|
for (const character of content) {
|
|
58915
58915
|
if (character === "`") {
|
|
58916
|
-
|
|
58917
|
-
if (
|
|
58918
|
-
|
|
58916
|
+
run += 1;
|
|
58917
|
+
if (run > maxRun)
|
|
58918
|
+
maxRun = run;
|
|
58919
58919
|
continue;
|
|
58920
58920
|
}
|
|
58921
|
-
|
|
58921
|
+
run = 0;
|
|
58922
58922
|
}
|
|
58923
|
-
return "`".repeat(
|
|
58923
|
+
return "`".repeat(maxRun + 1);
|
|
58924
58924
|
}
|
|
58925
58925
|
function toLines(input) {
|
|
58926
58926
|
return Array.isArray(input) ? input : [input];
|
|
@@ -58930,25 +58930,25 @@ function formatLines(input, formatter) {
|
|
|
58930
58930
|
`);
|
|
58931
58931
|
}
|
|
58932
58932
|
function formatText(content, options = {}) {
|
|
58933
|
-
let
|
|
58933
|
+
let out = toLines(content).join(`
|
|
58934
58934
|
`);
|
|
58935
58935
|
if (options.underline)
|
|
58936
|
-
|
|
58936
|
+
out = surround(out, "__");
|
|
58937
58937
|
if (options.italic)
|
|
58938
|
-
|
|
58938
|
+
out = surround(out, "*");
|
|
58939
58939
|
if (options.bold)
|
|
58940
|
-
|
|
58940
|
+
out = surround(out, "**");
|
|
58941
58941
|
if (typeof options.size === "number") {
|
|
58942
58942
|
const prefix = options.size === 4 ? "-#" : "#".repeat(options.size);
|
|
58943
|
-
return `${prefix} ${
|
|
58943
|
+
return `${prefix} ${out}`;
|
|
58944
58944
|
}
|
|
58945
|
-
return
|
|
58945
|
+
return out;
|
|
58946
58946
|
}
|
|
58947
58947
|
function formatInlineCode(content) {
|
|
58948
58948
|
const text = toLines(content).join(`
|
|
58949
58949
|
`);
|
|
58950
|
-
const
|
|
58951
|
-
return `${
|
|
58950
|
+
const fence = getCodeFence(text);
|
|
58951
|
+
return `${fence}${text}${fence}`;
|
|
58952
58952
|
}
|
|
58953
58953
|
function formatQuote(input) {
|
|
58954
58954
|
return formatLines(input, (line) => `> ${line}`);
|
|
@@ -58959,38 +58959,34 @@ function formatSpoiler(input) {
|
|
|
58959
58959
|
|
|
58960
58960
|
// src/core/ui/utils/formatList.ts
|
|
58961
58961
|
function formatList(items, options = {}) {
|
|
58962
|
-
return formatLines(items, (item, index) => {
|
|
58963
|
-
if (options.ordered) {
|
|
58964
|
-
return `${index + 1}. ${item}`;
|
|
58965
|
-
}
|
|
58966
|
-
return `- ${item}`;
|
|
58967
|
-
});
|
|
58962
|
+
return formatLines(items, (item, index) => options.ordered ? `${index + 1}. ${item}` : `- ${item}`);
|
|
58968
58963
|
}
|
|
58969
58964
|
// src/core/ui/utils/resolveSelectBase.ts
|
|
58970
58965
|
function resolveSelectBase(customIdOrOpts, opts = {}) {
|
|
58971
58966
|
if (typeof customIdOrOpts === "string") {
|
|
58972
58967
|
return { id: customIdOrOpts, ...opts };
|
|
58973
58968
|
}
|
|
58974
|
-
const { customId, ...
|
|
58975
|
-
return { id: customId, ...
|
|
58969
|
+
const { customId, ...select } = customIdOrOpts;
|
|
58970
|
+
return { id: customId, ...select };
|
|
58976
58971
|
}
|
|
58977
58972
|
// src/core/ui/utils/splitContainerArgs.ts
|
|
58978
|
-
function
|
|
58973
|
+
function isOptions(value) {
|
|
58979
58974
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
58980
58975
|
return false;
|
|
58981
58976
|
}
|
|
58982
58977
|
return "color" in value;
|
|
58983
58978
|
}
|
|
58984
58979
|
function splitContainerArgs(args) {
|
|
58985
|
-
|
|
58980
|
+
const head = args[0];
|
|
58981
|
+
if (!isOptions(head)) {
|
|
58986
58982
|
return {
|
|
58987
|
-
options:
|
|
58988
|
-
components: args
|
|
58983
|
+
options: {},
|
|
58984
|
+
components: args
|
|
58989
58985
|
};
|
|
58990
58986
|
}
|
|
58991
58987
|
return {
|
|
58992
|
-
options:
|
|
58993
|
-
components: args
|
|
58988
|
+
options: head,
|
|
58989
|
+
components: args.slice(1)
|
|
58994
58990
|
};
|
|
58995
58991
|
}
|
|
58996
58992
|
// src/core/ui/builders/primitives.ts
|
|
@@ -59041,12 +59037,12 @@ function row(...components) {
|
|
|
59041
59037
|
return { type: "row", components };
|
|
59042
59038
|
}
|
|
59043
59039
|
function buildEasyFile(url, fileOrSpoiler, spoiler = false) {
|
|
59044
|
-
const
|
|
59040
|
+
const hasAttachment = typeof fileOrSpoiler !== "boolean";
|
|
59045
59041
|
return {
|
|
59046
59042
|
type: "file",
|
|
59047
59043
|
url,
|
|
59048
|
-
spoiler:
|
|
59049
|
-
attachment:
|
|
59044
|
+
spoiler: hasAttachment ? spoiler : fileOrSpoiler ?? false,
|
|
59045
|
+
attachment: hasAttachment ? fileOrSpoiler : undefined
|
|
59050
59046
|
};
|
|
59051
59047
|
}
|
|
59052
59048
|
function buildFile(url, fileOrSpoiler, spoiler = false) {
|
|
@@ -59059,65 +59055,59 @@ function fromAttachment(attachment, spoiler = false) {
|
|
|
59059
59055
|
var file = Object.assign(buildFile, { fromAttachment });
|
|
59060
59056
|
|
|
59061
59057
|
// src/core/ui/builders/select.ts
|
|
59062
|
-
function
|
|
59058
|
+
function mkSelect(type, input, opts) {
|
|
59059
|
+
const select = typeof input === "string" ? resolveSelectBase(input, opts) : resolveSelectBase(input);
|
|
59063
59060
|
return {
|
|
59064
59061
|
type,
|
|
59065
|
-
...
|
|
59062
|
+
...select
|
|
59066
59063
|
};
|
|
59067
59064
|
}
|
|
59068
|
-
function
|
|
59069
|
-
|
|
59070
|
-
|
|
59071
|
-
type,
|
|
59072
|
-
...resolveSelectBase({ customId, ...selectOptions })
|
|
59073
|
-
};
|
|
59074
|
-
}
|
|
59075
|
-
function createSimpleSelectBuilder(type) {
|
|
59076
|
-
function build(customIdOrOpts, opts) {
|
|
59077
|
-
return typeof customIdOrOpts === "string" ? createSelect(type, customIdOrOpts, opts) : createSelectFromObject(type, customIdOrOpts);
|
|
59065
|
+
function mkSimpleBuilder(type) {
|
|
59066
|
+
function build(input, opts) {
|
|
59067
|
+
return mkSelect(type, input, opts);
|
|
59078
59068
|
}
|
|
59079
59069
|
return build;
|
|
59080
59070
|
}
|
|
59081
|
-
var userSelect =
|
|
59082
|
-
var roleSelect =
|
|
59083
|
-
var mentionableSelect =
|
|
59084
|
-
function user(
|
|
59085
|
-
return
|
|
59071
|
+
var userSelect = mkSimpleBuilder("select.user");
|
|
59072
|
+
var roleSelect = mkSimpleBuilder("select.role");
|
|
59073
|
+
var mentionableSelect = mkSimpleBuilder("select.mentionable");
|
|
59074
|
+
function user(input, opts) {
|
|
59075
|
+
return userSelect(input, opts);
|
|
59086
59076
|
}
|
|
59087
|
-
function role(
|
|
59088
|
-
return
|
|
59077
|
+
function role(input, opts) {
|
|
59078
|
+
return roleSelect(input, opts);
|
|
59089
59079
|
}
|
|
59090
|
-
function mentionable(
|
|
59091
|
-
return
|
|
59080
|
+
function mentionable(input, opts) {
|
|
59081
|
+
return mentionableSelect(input, opts);
|
|
59092
59082
|
}
|
|
59093
|
-
function channel(
|
|
59094
|
-
if (typeof
|
|
59095
|
-
const { channelTypes:
|
|
59083
|
+
function channel(input, channelTypes, opts = {}) {
|
|
59084
|
+
if (typeof input !== "string") {
|
|
59085
|
+
const { channelTypes: chans, ...select } = input;
|
|
59096
59086
|
return {
|
|
59097
59087
|
type: "select.channel",
|
|
59098
59088
|
...resolveSelectBase(select),
|
|
59099
|
-
channelTypes:
|
|
59089
|
+
channelTypes: chans
|
|
59100
59090
|
};
|
|
59101
59091
|
}
|
|
59102
|
-
const resolvedOpts = Array.isArray(channelTypes) ? opts : channelTypes;
|
|
59103
59092
|
return {
|
|
59104
59093
|
type: "select.channel",
|
|
59105
|
-
...resolveSelectBase(
|
|
59094
|
+
...resolveSelectBase(input, Array.isArray(channelTypes) ? opts : channelTypes),
|
|
59106
59095
|
channelTypes: Array.isArray(channelTypes) ? channelTypes : undefined
|
|
59107
59096
|
};
|
|
59108
59097
|
}
|
|
59109
|
-
function string(
|
|
59110
|
-
if (typeof
|
|
59111
|
-
const { options:
|
|
59098
|
+
function string(input, options, opts = {}) {
|
|
59099
|
+
if (typeof input !== "string") {
|
|
59100
|
+
const { options: items, ...select } = input;
|
|
59112
59101
|
return {
|
|
59113
59102
|
type: "select.string",
|
|
59114
59103
|
...resolveSelectBase(select),
|
|
59115
|
-
options:
|
|
59104
|
+
options: items
|
|
59116
59105
|
};
|
|
59117
59106
|
}
|
|
59107
|
+
const base = Array.isArray(options) ? opts : {};
|
|
59118
59108
|
return {
|
|
59119
59109
|
type: "select.string",
|
|
59120
|
-
...resolveSelectBase(
|
|
59110
|
+
...resolveSelectBase(input, base),
|
|
59121
59111
|
options: Array.isArray(options) ? options : []
|
|
59122
59112
|
};
|
|
59123
59113
|
}
|
|
@@ -59144,6 +59134,9 @@ var ATTACHMENTS = Symbol("ui.display.attachments");
|
|
|
59144
59134
|
var RENDERED = Symbol("ui.display.rendered");
|
|
59145
59135
|
var RENDERED_ATTACHMENTS = Symbol("ui.display.rendered.attachments");
|
|
59146
59136
|
// src/core/ui/validators/container.ts
|
|
59137
|
+
function isSelectComponent(component) {
|
|
59138
|
+
return !("label" in component);
|
|
59139
|
+
}
|
|
59147
59140
|
function validateComponents(components) {
|
|
59148
59141
|
if (components.length > MAX_MESSAGE_COMPONENTS) {
|
|
59149
59142
|
throw new Error("A message cannot contain more than 40 components.");
|
|
@@ -59168,7 +59161,7 @@ function validateRow(components) {
|
|
|
59168
59161
|
if (components.length < 1 || components.length > MAX_ROW_COMPONENTS) {
|
|
59169
59162
|
throw new Error("Action row must contain between 1 and 5 components.");
|
|
59170
59163
|
}
|
|
59171
|
-
const selectCount = components.filter(
|
|
59164
|
+
const selectCount = components.filter(isSelectComponent).length;
|
|
59172
59165
|
if (selectCount > 0 && components.length > 1) {
|
|
59173
59166
|
throw new Error("Select menus must be alone in an action row (max width layout rule).");
|
|
59174
59167
|
}
|
|
@@ -59202,37 +59195,47 @@ function validateGallery(items) {
|
|
|
59202
59195
|
}
|
|
59203
59196
|
|
|
59204
59197
|
// src/core/ui/validators/button.ts
|
|
59205
|
-
function
|
|
59198
|
+
function isLink(button2) {
|
|
59199
|
+
return "url" in button2 && typeof button2.url === "string";
|
|
59200
|
+
}
|
|
59201
|
+
function hasLen(value, min, max) {
|
|
59206
59202
|
if (!value)
|
|
59207
59203
|
return false;
|
|
59208
59204
|
return value.length >= min && value.length <= max;
|
|
59209
59205
|
}
|
|
59210
59206
|
function validateButton(button2) {
|
|
59211
|
-
if (!
|
|
59207
|
+
if (!hasLen(button2.label, 1, MAX_BUTTON_LABEL_LENGTH)) {
|
|
59212
59208
|
throw new Error("Button label must have between 1 and 80 characters.");
|
|
59213
59209
|
}
|
|
59214
|
-
if (
|
|
59210
|
+
if (isLink(button2)) {
|
|
59211
|
+
validateUrl(button2.url);
|
|
59212
|
+
return;
|
|
59213
|
+
}
|
|
59214
|
+
if (!hasLen(button2.customId, 1, MAX_BUTTON_CUSTOM_ID_LENGTH)) {
|
|
59215
59215
|
throw new Error("Button custom id must have between 1 and 100 characters.");
|
|
59216
59216
|
}
|
|
59217
59217
|
}
|
|
59218
59218
|
|
|
59219
59219
|
// src/core/ui/validators/select.ts
|
|
59220
|
-
function
|
|
59221
|
-
if (
|
|
59220
|
+
function hasLen2(value, min, max) {
|
|
59221
|
+
if (typeof value !== "string")
|
|
59222
59222
|
return false;
|
|
59223
59223
|
return value.length >= min && value.length <= max;
|
|
59224
59224
|
}
|
|
59225
|
+
function checkStringSelect(select) {
|
|
59226
|
+
if (select.options.length < 1 || select.options.length > MAX_STRING_SELECT_OPTIONS) {
|
|
59227
|
+
throw new Error("String select must contain between 1 and 25 options.");
|
|
59228
|
+
}
|
|
59229
|
+
}
|
|
59225
59230
|
function validateSelect(select) {
|
|
59226
|
-
if (!
|
|
59231
|
+
if (!hasLen2(select.id, 1, 100)) {
|
|
59227
59232
|
throw new Error("Select custom id must have between 1 and 100 characters.");
|
|
59228
59233
|
}
|
|
59229
|
-
if (select.placeholder && select.placeholder.length > MAX_SELECT_PLACEHOLDER_LENGTH) {
|
|
59234
|
+
if (typeof select.placeholder === "string" && select.placeholder.length > MAX_SELECT_PLACEHOLDER_LENGTH) {
|
|
59230
59235
|
throw new Error("Select placeholder cannot exceed 150 characters.");
|
|
59231
59236
|
}
|
|
59232
59237
|
if (select.type === "select.string") {
|
|
59233
|
-
|
|
59234
|
-
throw new Error("String select must contain between 1 and 25 options.");
|
|
59235
|
-
}
|
|
59238
|
+
checkStringSelect(select);
|
|
59236
59239
|
}
|
|
59237
59240
|
}
|
|
59238
59241
|
|
|
@@ -59252,16 +59255,29 @@ var validate = {
|
|
|
59252
59255
|
|
|
59253
59256
|
// src/core/ui/normalizers/button.ts
|
|
59254
59257
|
var import_discord4 = __toESM(require_src(), 1);
|
|
59258
|
+
function isLink2(button2) {
|
|
59259
|
+
return "url" in button2 && typeof button2.url === "string";
|
|
59260
|
+
}
|
|
59255
59261
|
function normalizeButton(button2) {
|
|
59256
59262
|
validateButton(button2);
|
|
59257
|
-
const
|
|
59263
|
+
const btn = new import_discord4.ButtonBuilder().setLabel(button2.label);
|
|
59264
|
+
if (isLink2(button2)) {
|
|
59265
|
+
btn.setURL(button2.url).setStyle(button2.style ?? import_discord4.ButtonStyle.Link);
|
|
59266
|
+
} else {
|
|
59267
|
+
btn.setCustomId(button2.customId).setStyle(button2.style ?? import_discord4.ButtonStyle.Primary);
|
|
59268
|
+
}
|
|
59258
59269
|
if (button2.emoji) {
|
|
59259
|
-
|
|
59270
|
+
btn.setEmoji({ name: button2.emoji });
|
|
59260
59271
|
}
|
|
59261
|
-
return
|
|
59272
|
+
return btn;
|
|
59262
59273
|
}
|
|
59263
59274
|
function applyButtonData(button2, data) {
|
|
59264
|
-
button2.setLabel(data.label)
|
|
59275
|
+
button2.setLabel(data.label);
|
|
59276
|
+
if (isLink2(data)) {
|
|
59277
|
+
button2.setURL(data.url).setStyle(data.style ?? import_discord4.ButtonStyle.Link);
|
|
59278
|
+
} else {
|
|
59279
|
+
button2.setCustomId(data.customId).setStyle(data.style ?? import_discord4.ButtonStyle.Primary);
|
|
59280
|
+
}
|
|
59265
59281
|
if (data.emoji) {
|
|
59266
59282
|
button2.setEmoji({ name: data.emoji });
|
|
59267
59283
|
}
|
|
@@ -59272,10 +59288,8 @@ var import_discord7 = __toESM(require_src(), 1);
|
|
|
59272
59288
|
|
|
59273
59289
|
// src/core/ui/normalizers/media.ts
|
|
59274
59290
|
var import_discord5 = __toESM(require_src(), 1);
|
|
59275
|
-
function
|
|
59276
|
-
|
|
59277
|
-
const gallery2 = new import_discord5.MediaGalleryBuilder;
|
|
59278
|
-
gallery2.addItems(...items.map((item) => (media) => {
|
|
59291
|
+
function toMediaItem(item) {
|
|
59292
|
+
return (media) => {
|
|
59279
59293
|
validateUrl(item.url);
|
|
59280
59294
|
media.setURL(item.url);
|
|
59281
59295
|
if (item.description)
|
|
@@ -59283,7 +59297,12 @@ function normalizeGallery(items) {
|
|
|
59283
59297
|
if (item.spoiler)
|
|
59284
59298
|
media.setSpoiler(item.spoiler);
|
|
59285
59299
|
return media;
|
|
59286
|
-
}
|
|
59300
|
+
};
|
|
59301
|
+
}
|
|
59302
|
+
function normalizeGallery(items) {
|
|
59303
|
+
validateGallery(items);
|
|
59304
|
+
const gallery2 = new import_discord5.MediaGalleryBuilder;
|
|
59305
|
+
gallery2.addItems(...items.map(toMediaItem));
|
|
59287
59306
|
return gallery2;
|
|
59288
59307
|
}
|
|
59289
59308
|
function normalizeFile(fileInput) {
|
|
@@ -59296,34 +59315,40 @@ function normalizeFile(fileInput) {
|
|
|
59296
59315
|
|
|
59297
59316
|
// src/core/ui/normalizers/select.ts
|
|
59298
59317
|
var import_discord6 = __toESM(require_src(), 1);
|
|
59318
|
+
function baseSelect(type, select, builder) {
|
|
59319
|
+
validateSelect({ type, ...select });
|
|
59320
|
+
return applySelectBase(builder, select);
|
|
59321
|
+
}
|
|
59322
|
+
function withChannelTypes(builder, channelTypes) {
|
|
59323
|
+
if (channelTypes?.length)
|
|
59324
|
+
builder.setChannelTypes(...channelTypes);
|
|
59325
|
+
return builder;
|
|
59326
|
+
}
|
|
59327
|
+
function toStringOptions(select) {
|
|
59328
|
+
return select.options.map((option) => ({
|
|
59329
|
+
label: option.label,
|
|
59330
|
+
value: option.value,
|
|
59331
|
+
description: option.description,
|
|
59332
|
+
default: option.default
|
|
59333
|
+
}));
|
|
59334
|
+
}
|
|
59299
59335
|
function normalizeUserSelect(select) {
|
|
59300
|
-
|
|
59301
|
-
return applySelectBase(new import_discord6.UserSelectMenuBuilder, select);
|
|
59336
|
+
return baseSelect("select.user", select, new import_discord6.UserSelectMenuBuilder);
|
|
59302
59337
|
}
|
|
59303
59338
|
function normalizeRoleSelect(select) {
|
|
59304
|
-
|
|
59305
|
-
return applySelectBase(new import_discord6.RoleSelectMenuBuilder, select);
|
|
59339
|
+
return baseSelect("select.role", select, new import_discord6.RoleSelectMenuBuilder);
|
|
59306
59340
|
}
|
|
59307
59341
|
function normalizeMentionableSelect(select) {
|
|
59308
|
-
|
|
59309
|
-
return applySelectBase(new import_discord6.MentionableSelectMenuBuilder, select);
|
|
59342
|
+
return baseSelect("select.mentionable", select, new import_discord6.MentionableSelectMenuBuilder);
|
|
59310
59343
|
}
|
|
59311
59344
|
function normalizeChannelSelect(select) {
|
|
59312
59345
|
validateSelect(select);
|
|
59313
|
-
|
|
59314
|
-
if (select.channelTypes?.length)
|
|
59315
|
-
builder.setChannelTypes(...select.channelTypes);
|
|
59316
|
-
return builder;
|
|
59346
|
+
return applySelectBase(withChannelTypes(new import_discord6.ChannelSelectMenuBuilder, select.channelTypes), select);
|
|
59317
59347
|
}
|
|
59318
59348
|
function normalizeStringSelect(select) {
|
|
59319
59349
|
validateSelect(select);
|
|
59320
59350
|
const builder = applySelectBase(new import_discord6.StringSelectMenuBuilder, select);
|
|
59321
|
-
builder.setOptions(...select
|
|
59322
|
-
label: option.label,
|
|
59323
|
-
value: option.value,
|
|
59324
|
-
description: option.description,
|
|
59325
|
-
default: option.default
|
|
59326
|
-
})));
|
|
59351
|
+
builder.setOptions(...toStringOptions(select));
|
|
59327
59352
|
return builder;
|
|
59328
59353
|
}
|
|
59329
59354
|
function normalizeSelect(select) {
|
|
@@ -59344,14 +59369,24 @@ function normalizeSelect(select) {
|
|
|
59344
59369
|
}
|
|
59345
59370
|
|
|
59346
59371
|
// src/core/ui/normalizers/container.ts
|
|
59347
|
-
function
|
|
59372
|
+
function isChild(component) {
|
|
59348
59373
|
return component instanceof import_discord7.TextDisplayBuilder || component instanceof import_discord7.SeparatorBuilder || component instanceof import_discord7.SectionBuilder || component instanceof import_discord7.MediaGalleryBuilder || component instanceof import_discord7.FileBuilder || component instanceof import_discord7.ActionRowBuilder;
|
|
59349
59374
|
}
|
|
59350
|
-
function
|
|
59351
|
-
return component instanceof import_discord7.ContainerBuilder ||
|
|
59375
|
+
function isDisplay(component) {
|
|
59376
|
+
return component instanceof import_discord7.ContainerBuilder || isChild(component);
|
|
59377
|
+
}
|
|
59378
|
+
function isObject(value) {
|
|
59379
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
59380
|
+
}
|
|
59381
|
+
function isButton(component) {
|
|
59382
|
+
if (!isObject(component)) {
|
|
59383
|
+
return false;
|
|
59384
|
+
}
|
|
59385
|
+
const candidate = component;
|
|
59386
|
+
return typeof candidate.label === "string" && (("customId" in candidate) || ("url" in candidate));
|
|
59352
59387
|
}
|
|
59353
|
-
function
|
|
59354
|
-
return
|
|
59388
|
+
function toRow(component) {
|
|
59389
|
+
return new import_discord7.ActionRowBuilder().addComponents(normalizeButton(component));
|
|
59355
59390
|
}
|
|
59356
59391
|
function normalizeRowComponent(component) {
|
|
59357
59392
|
return "label" in component ? normalizeButton(component) : normalizeSelect(component);
|
|
@@ -59370,6 +59405,20 @@ function normalizeSeparator(component) {
|
|
|
59370
59405
|
}
|
|
59371
59406
|
return separator2;
|
|
59372
59407
|
}
|
|
59408
|
+
function setSectionButton(section, button2) {
|
|
59409
|
+
section.setButtonAccessory((target) => applyButtonData(target, button2));
|
|
59410
|
+
}
|
|
59411
|
+
function setSectionThumb(section, thumbnail2) {
|
|
59412
|
+
validateUrl(thumbnail2.url);
|
|
59413
|
+
section.setThumbnailAccessory((target) => {
|
|
59414
|
+
target.setURL(thumbnail2.url);
|
|
59415
|
+
if (thumbnail2.description)
|
|
59416
|
+
target.setDescription(thumbnail2.description);
|
|
59417
|
+
if (thumbnail2.spoiler)
|
|
59418
|
+
target.setSpoiler(thumbnail2.spoiler);
|
|
59419
|
+
return target;
|
|
59420
|
+
});
|
|
59421
|
+
}
|
|
59373
59422
|
function normalizeSection(component) {
|
|
59374
59423
|
validateSection(component);
|
|
59375
59424
|
const section = new import_discord7.SectionBuilder;
|
|
@@ -59378,19 +59427,10 @@ function normalizeSection(component) {
|
|
|
59378
59427
|
return (text2) => text2.setContent(content);
|
|
59379
59428
|
}));
|
|
59380
59429
|
if (component.button) {
|
|
59381
|
-
section
|
|
59430
|
+
setSectionButton(section, component.button);
|
|
59382
59431
|
}
|
|
59383
59432
|
if (component.thumbnail) {
|
|
59384
|
-
|
|
59385
|
-
validateUrl(thumbnail2.url);
|
|
59386
|
-
section.setThumbnailAccessory((thumb) => {
|
|
59387
|
-
thumb.setURL(thumbnail2.url);
|
|
59388
|
-
if (thumbnail2.description)
|
|
59389
|
-
thumb.setDescription(thumbnail2.description);
|
|
59390
|
-
if (thumbnail2.spoiler)
|
|
59391
|
-
thumb.setSpoiler(thumbnail2.spoiler);
|
|
59392
|
-
return thumb;
|
|
59393
|
-
});
|
|
59433
|
+
setSectionThumb(section, component.thumbnail);
|
|
59394
59434
|
}
|
|
59395
59435
|
return section;
|
|
59396
59436
|
}
|
|
@@ -59398,7 +59438,7 @@ function normalizeRow(component) {
|
|
|
59398
59438
|
validateRow(component.components);
|
|
59399
59439
|
return new import_discord7.ActionRowBuilder().addComponents(...component.components.map(normalizeRowComponent));
|
|
59400
59440
|
}
|
|
59401
|
-
function
|
|
59441
|
+
function normalizeNode(component) {
|
|
59402
59442
|
switch (component.type) {
|
|
59403
59443
|
case "text":
|
|
59404
59444
|
return normalizeText(component);
|
|
@@ -59417,16 +59457,18 @@ function normalizeContainerNode(component) {
|
|
|
59417
59457
|
}
|
|
59418
59458
|
}
|
|
59419
59459
|
function toContainerChild(component) {
|
|
59420
|
-
if (
|
|
59460
|
+
if (isChild(component))
|
|
59421
59461
|
return component;
|
|
59422
|
-
if (
|
|
59423
|
-
return
|
|
59424
|
-
return component;
|
|
59462
|
+
if (isButton(component))
|
|
59463
|
+
return toRow(component);
|
|
59464
|
+
return normalizeNode(component);
|
|
59425
59465
|
}
|
|
59426
59466
|
function toDisplayComponent(component) {
|
|
59427
|
-
if (
|
|
59467
|
+
if (isDisplay(component))
|
|
59428
59468
|
return component;
|
|
59429
|
-
|
|
59469
|
+
if (isButton(component))
|
|
59470
|
+
return toRow(component);
|
|
59471
|
+
return normalizeNode(component);
|
|
59430
59472
|
}
|
|
59431
59473
|
function toDisplayComponents(...components) {
|
|
59432
59474
|
return components.map(toDisplayComponent);
|
|
@@ -59446,7 +59488,7 @@ function getRenderedComponentsAttachments(components) {
|
|
|
59446
59488
|
return components[RENDERED_ATTACHMENTS] ?? [];
|
|
59447
59489
|
}
|
|
59448
59490
|
function isEasyFileInput(component) {
|
|
59449
|
-
if (!
|
|
59491
|
+
if (!isObject(component)) {
|
|
59450
59492
|
return false;
|
|
59451
59493
|
}
|
|
59452
59494
|
const candidate = component;
|
|
@@ -59483,20 +59525,17 @@ function section(texts, opts = {}) {
|
|
|
59483
59525
|
}
|
|
59484
59526
|
function container(...args) {
|
|
59485
59527
|
const { options, components } = splitContainerArgs(args);
|
|
59486
|
-
const
|
|
59487
|
-
|
|
59528
|
+
const out = new import_discord8.ContainerBuilder;
|
|
59529
|
+
out.components.push(...components.map(toContainerChild));
|
|
59488
59530
|
if (options.color !== undefined) {
|
|
59489
|
-
|
|
59490
|
-
container2.setAccentColor(accentColor);
|
|
59531
|
+
out.setAccentColor(validate.color(options.color));
|
|
59491
59532
|
}
|
|
59492
|
-
|
|
59493
|
-
return attachContainerAttachments(container2, attachments);
|
|
59533
|
+
return attachContainerAttachments(out, collectAttachmentsFromContainerInputs(components));
|
|
59494
59534
|
}
|
|
59495
59535
|
function render(...components) {
|
|
59496
|
-
const
|
|
59497
|
-
validate.components(
|
|
59498
|
-
|
|
59499
|
-
return createRenderedComponents(rendered, files);
|
|
59536
|
+
const out = toDisplayComponents(...components);
|
|
59537
|
+
validate.components(out);
|
|
59538
|
+
return createRenderedComponents(out, collectAttachmentsFromDisplayInputs(components));
|
|
59500
59539
|
}
|
|
59501
59540
|
function send(interaction, payload) {
|
|
59502
59541
|
if (!isRenderedComponents(payload.components)) {
|
|
@@ -59504,8 +59543,10 @@ function send(interaction, payload) {
|
|
|
59504
59543
|
}
|
|
59505
59544
|
validate.components(payload.components);
|
|
59506
59545
|
const flags = payload.ephemeral ? [import_discord8.MessageFlags.IsComponentsV2, import_discord8.MessageFlags.Ephemeral] : [import_discord8.MessageFlags.IsComponentsV2];
|
|
59507
|
-
const
|
|
59508
|
-
|
|
59546
|
+
const files = [
|
|
59547
|
+
...getRenderedComponentsAttachments(payload.components),
|
|
59548
|
+
...payload.files ?? []
|
|
59549
|
+
];
|
|
59509
59550
|
return interaction.reply({
|
|
59510
59551
|
flags,
|
|
59511
59552
|
components: payload.components,
|
|
@@ -63278,7 +63319,7 @@ __export(exports_util, {
|
|
|
63278
63319
|
joinValues: () => joinValues,
|
|
63279
63320
|
issue: () => issue,
|
|
63280
63321
|
isPlainObject: () => isPlainObject,
|
|
63281
|
-
isObject: () =>
|
|
63322
|
+
isObject: () => isObject2,
|
|
63282
63323
|
hexToUint8Array: () => hexToUint8Array,
|
|
63283
63324
|
getSizableOrigin: () => getSizableOrigin,
|
|
63284
63325
|
getParsedType: () => getParsedType,
|
|
@@ -63441,7 +63482,7 @@ function slugify(input) {
|
|
|
63441
63482
|
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
63442
63483
|
}
|
|
63443
63484
|
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
63444
|
-
function
|
|
63485
|
+
function isObject2(data) {
|
|
63445
63486
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
63446
63487
|
}
|
|
63447
63488
|
var allowsEval = /* @__PURE__ */ cached(() => {
|
|
@@ -63460,7 +63501,7 @@ var allowsEval = /* @__PURE__ */ cached(() => {
|
|
|
63460
63501
|
}
|
|
63461
63502
|
});
|
|
63462
63503
|
function isPlainObject(o) {
|
|
63463
|
-
if (
|
|
63504
|
+
if (isObject2(o) === false)
|
|
63464
63505
|
return false;
|
|
63465
63506
|
const ctor = o.constructor;
|
|
63466
63507
|
if (ctor === undefined)
|
|
@@ -63468,7 +63509,7 @@ function isPlainObject(o) {
|
|
|
63468
63509
|
if (typeof ctor !== "function")
|
|
63469
63510
|
return true;
|
|
63470
63511
|
const prot = ctor.prototype;
|
|
63471
|
-
if (
|
|
63512
|
+
if (isObject2(prot) === false)
|
|
63472
63513
|
return false;
|
|
63473
63514
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
63474
63515
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexocord",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Framework TypeScript moderno para criar bots escaláveis do Discord com discord.js v14, apresentando arquitetura modular, cli e utilitários amigáveis para desenvolvedores.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|