@satorijs/adapter-discord 3.8.6 → 3.8.7
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/index.js +12 -6
- package/lib/index.js.map +2 -2
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1412,11 +1412,19 @@ var types = {
|
|
|
1412
1412
|
channel: ApplicationCommand2.OptionType.STRING,
|
|
1413
1413
|
guild: ApplicationCommand2.OptionType.STRING
|
|
1414
1414
|
};
|
|
1415
|
+
var trimDescription = /* @__PURE__ */ __name((source) => {
|
|
1416
|
+
if (!source || source.length < 96)
|
|
1417
|
+
return source;
|
|
1418
|
+
return source.slice(0, 93) + "...";
|
|
1419
|
+
}, "trimDescription");
|
|
1420
|
+
var encodeDescription = /* @__PURE__ */ __name((object) => ({
|
|
1421
|
+
description: trimDescription(object.description[""] || object.name),
|
|
1422
|
+
description_localizations: (0, import_satori2.valueMap)((0, import_satori2.pick)(object.description, Locale3), trimDescription)
|
|
1423
|
+
}), "encodeDescription");
|
|
1415
1424
|
var encodeCommand = /* @__PURE__ */ __name((cmd) => ({
|
|
1425
|
+
...encodeDescription(cmd),
|
|
1416
1426
|
name: cmd.name,
|
|
1417
1427
|
type: ApplicationCommand2.Type.CHAT_INPUT,
|
|
1418
|
-
description: cmd.description[""] || cmd.name,
|
|
1419
|
-
description_localizations: (0, import_satori2.pick)(cmd.description, Locale3),
|
|
1420
1428
|
options: encodeCommandOptions(cmd)
|
|
1421
1429
|
}), "encodeCommand");
|
|
1422
1430
|
var decodeArgv = /* @__PURE__ */ __name((data, command) => {
|
|
@@ -1448,18 +1456,16 @@ function encodeCommandOptions(cmd) {
|
|
|
1448
1456
|
} else {
|
|
1449
1457
|
for (const arg of cmd.arguments) {
|
|
1450
1458
|
result.push({
|
|
1459
|
+
...encodeDescription(arg),
|
|
1451
1460
|
name: arg.name.toLowerCase().replace(/[^a-z0-9]/g, ""),
|
|
1452
|
-
description: arg.description[""] || arg.name,
|
|
1453
|
-
description_localizations: (0, import_satori2.pick)(arg.description, Locale3),
|
|
1454
1461
|
type: (_a = types[arg.type]) != null ? _a : types.text
|
|
1455
1462
|
// required: arg.required ?? false,
|
|
1456
1463
|
});
|
|
1457
1464
|
}
|
|
1458
1465
|
for (const option of cmd.options) {
|
|
1459
1466
|
result.push({
|
|
1467
|
+
...encodeDescription(option),
|
|
1460
1468
|
name: option.name.toLowerCase(),
|
|
1461
|
-
description: option.description[""] || option.name,
|
|
1462
|
-
description_localizations: (0, import_satori2.pick)(option.description, Locale3),
|
|
1463
1469
|
type: (_b = types[option.type]) != null ? _b : types.text,
|
|
1464
1470
|
// required: option.required ?? false,
|
|
1465
1471
|
min_value: option.type === "posint" ? 1 : void 0
|