gralonium 0.3.0 → 0.4.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/lib/classes/Client.d.ts +9 -3
- package/lib/classes/Client.js +2 -2
- package/lib/classes/Context.d.ts +42 -1
- package/lib/classes/Context.js +276 -13
- package/lib/classes/Cooldowns.d.ts +2 -0
- package/lib/classes/Cooldowns.js +28 -0
- package/lib/classes/HelpCommand.d.ts +55 -13
- package/lib/classes/HelpCommand.js +319 -1
- package/lib/classes/Loader.d.ts +10 -1
- package/lib/classes/Loader.js +143 -58
- package/lib/classes/Plugins.js +3 -2
- package/lib/classes/Utils.d.ts +1 -1
- package/lib/classes/Utils.js +103 -24
- package/lib/classes/builders/CommandBuilder.d.ts +24 -0
- package/lib/classes/builders/CommandBuilder.js +66 -2
- package/lib/classes/builders/ComponentsV2Builder.d.ts +288 -113
- package/lib/classes/builders/ComponentsV2Builder.js +1071 -180
- package/lib/classes/builders/GroupBuilder.d.ts +20 -0
- package/lib/classes/builders/GroupBuilder.js +37 -1
- package/lib/classes/builders/InteractionBuilder.d.ts +86 -25
- package/lib/classes/builders/InteractionBuilder.js +212 -1
- package/lib/classes/builders/ParamsBuilder.d.ts +118 -76
- package/lib/classes/builders/ParamsBuilder.js +167 -1
- package/lib/classes/builders/components/StyleMapper.d.ts +14 -2
- package/lib/classes/builders/components/StyleMapper.js +35 -9
- package/lib/classes/builders/components/helpers.d.ts +68 -4
- package/lib/classes/builders/components/helpers.js +366 -7
- package/lib/classes/builders/components/templates.d.ts +151 -9
- package/lib/classes/builders/components/templates.js +376 -17
- package/lib/classes/builders/components/text.d.ts +24 -0
- package/lib/classes/builders/components/text.js +91 -0
- package/lib/classes/experiments/Confirmator.d.ts +44 -26
- package/lib/classes/experiments/Confirmator.js +37 -21
- package/lib/classes/experiments/Paginator.d.ts +48 -29
- package/lib/classes/experiments/Paginator.js +48 -19
- package/lib/classes/views/V2Paginator.d.ts +91 -0
- package/lib/classes/views/V2Paginator.js +268 -0
- package/lib/classes/views/V2View.d.ts +113 -0
- package/lib/classes/views/V2View.js +438 -0
- package/lib/experiments.d.ts +2 -0
- package/lib/experiments.js +9 -1
- package/lib/main.d.ts +3 -0
- package/lib/main.js +3 -0
- package/package.json +3 -1
package/lib/classes/Utils.js
CHANGED
|
@@ -133,7 +133,7 @@ class Utils {
|
|
|
133
133
|
return paramsBuilder.params.map((param) => ({ ...param, value: undefined }));
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
static async transform(input, param, ctx, seeable = true) {
|
|
136
|
+
static async transform(input, param, ctx, seeable = true, attachmentIndex = 0) {
|
|
137
137
|
if (!input && seeable) {
|
|
138
138
|
return { break: false, value: null };
|
|
139
139
|
}
|
|
@@ -149,27 +149,38 @@ class Utils {
|
|
|
149
149
|
|
|
150
150
|
if (param.type === DJS.ApplicationCommandOptionType.String) {
|
|
151
151
|
const value = String(input ?? "");
|
|
152
|
+
const maxLength = typeof param.max_length === "number" ? param.max_length : param.maxLength;
|
|
153
|
+
const minLength = typeof param.min_length === "number" ? param.min_length : param.minLength;
|
|
152
154
|
|
|
153
|
-
if (typeof
|
|
155
|
+
if (typeof maxLength === "number" && value.length > maxLength) {
|
|
154
156
|
throw new Errors.InvalidParam(ctx, `${param.name} exceeds max length.`, { param });
|
|
155
157
|
}
|
|
156
158
|
|
|
157
|
-
if (typeof
|
|
159
|
+
if (typeof minLength === "number" && value.length < minLength) {
|
|
158
160
|
throw new Errors.InvalidParam(ctx, `${param.name} is under min length.`, { param });
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
return { break: false, value };
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
if (param.type === DJS.ApplicationCommandOptionType.Number) {
|
|
166
|
+
if (param.type === DJS.ApplicationCommandOptionType.Integer || param.type === DJS.ApplicationCommandOptionType.Number) {
|
|
165
167
|
const value = Number(input);
|
|
166
|
-
if (
|
|
168
|
+
if (String(input ?? "").trim() === "" || Number.isNaN(value)) {
|
|
169
|
+
throw new Errors.InvalidParamNumber(ctx, param);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (param.type === DJS.ApplicationCommandOptionType.Integer && !Number.isInteger(value)) {
|
|
173
|
+
throw new Errors.InvalidParamNumber(ctx, param);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const maxValue = typeof param.max_value === "number" ? param.max_value : param.maxValue;
|
|
177
|
+
const minValue = typeof param.min_value === "number" ? param.min_value : param.minValue;
|
|
167
178
|
|
|
168
|
-
if (typeof
|
|
179
|
+
if (typeof maxValue === "number" && value > maxValue) {
|
|
169
180
|
throw new Errors.InvalidParam(ctx, `${param.name} exceeds max value.`, { param });
|
|
170
181
|
}
|
|
171
182
|
|
|
172
|
-
if (typeof
|
|
183
|
+
if (typeof minValue === "number" && value < minValue) {
|
|
173
184
|
throw new Errors.InvalidParam(ctx, `${param.name} is under min value.`, { param });
|
|
174
185
|
}
|
|
175
186
|
|
|
@@ -188,12 +199,33 @@ class Utils {
|
|
|
188
199
|
throw new Errors.InvalidParamMember(ctx, param);
|
|
189
200
|
}
|
|
190
201
|
|
|
202
|
+
if (param.type === DJS.ApplicationCommandOptionType.Mentionable) {
|
|
203
|
+
const rawInput = String(input ?? "").trim();
|
|
204
|
+
if (/^<@&\d+>$/.test(rawInput) && ctx.guild) {
|
|
205
|
+
const role = await Utils.getRole(rawInput, { guild: ctx.guild, force: true });
|
|
206
|
+
if (role) return { break: false, value: role };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const memberOrUser = ctx.guild
|
|
210
|
+
? await Utils.getMember(rawInput, { guild: ctx.guild, force: true })
|
|
211
|
+
: await Utils.getUser(rawInput, ctx.bot);
|
|
212
|
+
if (memberOrUser) return { break: false, value: memberOrUser };
|
|
213
|
+
|
|
214
|
+
if (ctx.guild) {
|
|
215
|
+
const role = await Utils.getRole(rawInput, { guild: ctx.guild, force: true });
|
|
216
|
+
if (role) return { break: false, value: role };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
throw new Errors.InvalidParam(ctx, `${param.name} must resolve to a valid user or role.`, { param });
|
|
220
|
+
}
|
|
221
|
+
|
|
191
222
|
if (param.type === DJS.ApplicationCommandOptionType.Channel) {
|
|
192
223
|
const channel = await Utils.getChannel(String(input), { guild: ctx.guild, force: true });
|
|
193
224
|
if (!channel) throw new Errors.InvalidParamChannel(ctx, param);
|
|
194
225
|
|
|
195
|
-
|
|
196
|
-
|
|
226
|
+
const channelTypes = param.channel_types ?? param.channelTypes;
|
|
227
|
+
if (channelTypes?.length && !channelTypes.includes(channel.type)) {
|
|
228
|
+
throw new Errors.InvalidChannelType(ctx, param, channel.type, channelTypes);
|
|
197
229
|
}
|
|
198
230
|
|
|
199
231
|
return { break: false, value: channel };
|
|
@@ -206,7 +238,18 @@ class Utils {
|
|
|
206
238
|
}
|
|
207
239
|
|
|
208
240
|
if (param.type === DJS.ApplicationCommandOptionType.Attachment) {
|
|
209
|
-
const
|
|
241
|
+
const attachments = ctx.message?.attachments;
|
|
242
|
+
const list = attachments
|
|
243
|
+
? typeof attachments.values === "function"
|
|
244
|
+
? [...attachments.values()]
|
|
245
|
+
: Array.isArray(attachments)
|
|
246
|
+
? attachments
|
|
247
|
+
: []
|
|
248
|
+
: [];
|
|
249
|
+
const attachment =
|
|
250
|
+
list[attachmentIndex] ??
|
|
251
|
+
(attachmentIndex === 0 && typeof attachments?.first === "function" ? attachments.first() : null) ??
|
|
252
|
+
null;
|
|
210
253
|
if (!attachment && param.required) throw new Errors.InvalidParamAttachment(ctx, param);
|
|
211
254
|
return { break: false, value: attachment };
|
|
212
255
|
}
|
|
@@ -223,12 +266,14 @@ class Utils {
|
|
|
223
266
|
}
|
|
224
267
|
|
|
225
268
|
let argIndex = 0;
|
|
269
|
+
let attachmentIndex = 0;
|
|
226
270
|
|
|
227
271
|
for (let paramIndex = 0; paramIndex < params.length; paramIndex += 1) {
|
|
228
272
|
const param = params[paramIndex];
|
|
229
273
|
|
|
230
274
|
if (param.type === DJS.ApplicationCommandOptionType.Attachment) {
|
|
231
|
-
const transformed = await Utils.transform("", param, ctx, false);
|
|
275
|
+
const transformed = await Utils.transform("", param, ctx, false, attachmentIndex);
|
|
276
|
+
attachmentIndex += 1;
|
|
232
277
|
param.value = transformed.value;
|
|
233
278
|
continue;
|
|
234
279
|
}
|
|
@@ -277,12 +322,16 @@ class Utils {
|
|
|
277
322
|
switch (param.type) {
|
|
278
323
|
case DJS.ApplicationCommandOptionType.String:
|
|
279
324
|
return interaction.options.getString(name, required);
|
|
325
|
+
case DJS.ApplicationCommandOptionType.Integer:
|
|
326
|
+
return interaction.options.getInteger(name, required);
|
|
280
327
|
case DJS.ApplicationCommandOptionType.Number:
|
|
281
328
|
return interaction.options.getNumber(name, required);
|
|
282
329
|
case DJS.ApplicationCommandOptionType.Boolean:
|
|
283
330
|
return interaction.options.getBoolean(name, required);
|
|
284
331
|
case DJS.ApplicationCommandOptionType.User:
|
|
285
332
|
return interaction.options.getMember(name) ?? interaction.options.getUser(name, required);
|
|
333
|
+
case DJS.ApplicationCommandOptionType.Mentionable:
|
|
334
|
+
return interaction.options.getMentionable(name, required);
|
|
286
335
|
case DJS.ApplicationCommandOptionType.Channel:
|
|
287
336
|
return interaction.options.getChannel(name, required);
|
|
288
337
|
case DJS.ApplicationCommandOptionType.Role:
|
|
@@ -391,11 +440,12 @@ class Utils {
|
|
|
391
440
|
const bucket = cooldown.bucket || Cooldowns_js_1.Bucket.User;
|
|
392
441
|
const source = Utils.#resolveCooldownSource(ctx, bucket);
|
|
393
442
|
const cooldownMs = cooldown.seconds * 1000;
|
|
443
|
+
const commandKey = Cooldowns_js_1.Cooldowns.resolveKey(command, ctx.parent);
|
|
394
444
|
|
|
395
|
-
const active = await ctx.bot.cooldowns.check(
|
|
445
|
+
const active = await ctx.bot.cooldowns.check(commandKey, source, cooldownMs, bucket);
|
|
396
446
|
if (active) throw new Errors.CommandInCooldown(ctx, active.left);
|
|
397
447
|
|
|
398
|
-
await ctx.bot.cooldowns.setCooldownSource(
|
|
448
|
+
await ctx.bot.cooldowns.setCooldownSource(commandKey, source, bucket, cooldownMs);
|
|
399
449
|
}
|
|
400
450
|
|
|
401
451
|
static #validateContextRestrictions(ctx) {
|
|
@@ -471,7 +521,17 @@ class Utils {
|
|
|
471
521
|
if (!canProceed) return;
|
|
472
522
|
|
|
473
523
|
await Utils.#resolveCommandInput(ctx, command, options);
|
|
524
|
+
|
|
525
|
+
if (typeof ctx.bot?.ops?.beforeExecute === "function") {
|
|
526
|
+
const shouldContinue = await ctx.bot.ops.beforeExecute(ctx, command, options);
|
|
527
|
+
if (shouldContinue === false) return;
|
|
528
|
+
}
|
|
529
|
+
|
|
474
530
|
await command.code(ctx);
|
|
531
|
+
|
|
532
|
+
if (typeof ctx.bot?.ops?.afterExecute === "function") {
|
|
533
|
+
await ctx.bot.ops.afterExecute(ctx, command, options);
|
|
534
|
+
}
|
|
475
535
|
}
|
|
476
536
|
|
|
477
537
|
static async #resolvePrefix(bot, ctx, message) {
|
|
@@ -591,20 +651,39 @@ class Utils {
|
|
|
591
651
|
return { command, group: null };
|
|
592
652
|
}
|
|
593
653
|
|
|
594
|
-
static #
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
654
|
+
static #extractInteractionLookup(interaction) {
|
|
655
|
+
const checks = [
|
|
656
|
+
["isAutocomplete", "autocomplete", "commandName"],
|
|
657
|
+
["isButton", "button", "customId"],
|
|
658
|
+
["isModalSubmit", "modalSubmit", "customId"],
|
|
659
|
+
["isMessageContextMenuCommand", "messageContextMenu", "commandName"],
|
|
660
|
+
["isUserContextMenuCommand", "userContextMenu", "commandName"],
|
|
661
|
+
["isChannelSelectMenu", "channelSelectMenu", "customId"],
|
|
662
|
+
["isMentionableSelectMenu", "mentionableSelectMenu", "customId"],
|
|
663
|
+
["isRoleSelectMenu", "roleSelectMenu", "customId"],
|
|
664
|
+
["isStringSelectMenu", "stringSelectMenu", "customId"],
|
|
665
|
+
["isUserSelectMenu", "userSelectMenu", "customId"],
|
|
666
|
+
];
|
|
667
|
+
|
|
668
|
+
for (const [guard, typeKey, prop] of checks) {
|
|
669
|
+
if (typeof interaction[guard] === "function" && interaction[guard]()) {
|
|
670
|
+
return { typeKey, key: interaction[prop] };
|
|
671
|
+
}
|
|
672
|
+
}
|
|
605
673
|
return null;
|
|
606
674
|
}
|
|
607
675
|
|
|
676
|
+
static #resolveInteractionModule(bot, interaction) {
|
|
677
|
+
const target = Utils.#extractInteractionLookup(interaction);
|
|
678
|
+
if (!target) return null;
|
|
679
|
+
|
|
680
|
+
const bucket = bot.loader.interactions?.[target.typeKey];
|
|
681
|
+
const exact = bucket?.get?.(target.key);
|
|
682
|
+
if (exact) return exact;
|
|
683
|
+
|
|
684
|
+
return bot.loader.resolvePatternInteraction?.(target.typeKey, target.key, interaction) || null;
|
|
685
|
+
}
|
|
686
|
+
|
|
608
687
|
static async #executeInteractionModule(bot, interaction, moduleData) {
|
|
609
688
|
if (!moduleData?.code) return;
|
|
610
689
|
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import type { ApplicationIntegrationType, InteractionContextType } from "discord.js";
|
|
2
|
+
|
|
3
|
+
export type LocalizationMap = Record<string, string>;
|
|
4
|
+
|
|
1
5
|
export declare function validateDefaultMemberPermissions(permissions: unknown): string | null | undefined;
|
|
6
|
+
export declare function normalizeNameLocalizations(map?: LocalizationMap | null): LocalizationMap | undefined;
|
|
7
|
+
export declare function normalizeDescriptionLocalizations(map?: LocalizationMap | null): LocalizationMap | undefined;
|
|
2
8
|
|
|
3
9
|
export interface CommandDataBuilder {
|
|
4
10
|
name: string;
|
|
@@ -14,6 +20,12 @@ export interface CommandDataBuilder {
|
|
|
14
20
|
botPermissions?: string[];
|
|
15
21
|
guards?: Array<(ctx: any) => boolean | Promise<boolean>>;
|
|
16
22
|
cooldown?: { seconds: number; bucket?: string };
|
|
23
|
+
integrationTypes?: Array<ApplicationIntegrationType | number>;
|
|
24
|
+
contexts?: Array<InteractionContextType | number>;
|
|
25
|
+
nameLocalizations?: LocalizationMap;
|
|
26
|
+
name_localizations?: LocalizationMap;
|
|
27
|
+
descriptionLocalizations?: LocalizationMap;
|
|
28
|
+
description_localizations?: LocalizationMap;
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
export declare class CommandBuilder {
|
|
@@ -30,6 +42,10 @@ export declare class CommandBuilder {
|
|
|
30
42
|
botPermissions: string[];
|
|
31
43
|
guards: Array<(ctx: any) => boolean | Promise<boolean>>;
|
|
32
44
|
cooldown?: { seconds: number; bucket?: string };
|
|
45
|
+
integrationTypes?: Array<ApplicationIntegrationType | number>;
|
|
46
|
+
contexts?: Array<InteractionContextType | number>;
|
|
47
|
+
nameLocalizations?: LocalizationMap;
|
|
48
|
+
descriptionLocalizations?: LocalizationMap;
|
|
33
49
|
constructor(options?: CommandDataBuilder);
|
|
34
50
|
setName(name: string): CommandBuilder;
|
|
35
51
|
setDescription(description: string): CommandBuilder;
|
|
@@ -41,10 +57,18 @@ export declare class CommandBuilder {
|
|
|
41
57
|
setUserPermissions(...permissions: string[]): CommandBuilder;
|
|
42
58
|
setBotPermissions(...permissions: string[]): CommandBuilder;
|
|
43
59
|
setCooldown(seconds: number, bucket?: string): CommandBuilder;
|
|
60
|
+
setIntegrationTypes(...types: Array<ApplicationIntegrationType | number | Array<ApplicationIntegrationType | number>>): CommandBuilder;
|
|
61
|
+
setContexts(...contexts: Array<InteractionContextType | number | Array<InteractionContextType | number>>): CommandBuilder;
|
|
62
|
+
setNameLocalizations(locales?: LocalizationMap | null): CommandBuilder;
|
|
63
|
+
setDescriptionLocalizations(locales?: LocalizationMap | null): CommandBuilder;
|
|
44
64
|
toJSON(): {
|
|
45
65
|
name: string;
|
|
46
66
|
description: string;
|
|
47
67
|
default_member_permissions: string | null | undefined;
|
|
48
68
|
dm_permission: boolean | undefined;
|
|
69
|
+
name_localizations?: LocalizationMap;
|
|
70
|
+
description_localizations?: LocalizationMap;
|
|
71
|
+
integration_types?: Array<ApplicationIntegrationType | number>;
|
|
72
|
+
contexts?: Array<InteractionContextType | number>;
|
|
49
73
|
};
|
|
50
74
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandBuilder = exports.validateDefaultMemberPermissions = void 0;
|
|
3
|
+
exports.CommandBuilder = exports.normalizeDescriptionLocalizations = exports.normalizeNameLocalizations = exports.validateDefaultMemberPermissions = void 0;
|
|
4
4
|
|
|
5
5
|
const shapeshift_1 = require("@sapphire/shapeshift");
|
|
6
6
|
|
|
@@ -15,6 +15,36 @@ function validateDefaultMemberPermissions(permissions) {
|
|
|
15
15
|
}
|
|
16
16
|
exports.validateDefaultMemberPermissions = validateDefaultMemberPermissions;
|
|
17
17
|
|
|
18
|
+
function normalizeLocaleMap(map, maxLength) {
|
|
19
|
+
if (!map || typeof map !== "object" || Array.isArray(map)) return undefined;
|
|
20
|
+
const out = {};
|
|
21
|
+
let hasEntries = false;
|
|
22
|
+
for (const [locale, raw] of Object.entries(map)) {
|
|
23
|
+
if (typeof raw !== "string") continue;
|
|
24
|
+
const trimmed = raw.trim();
|
|
25
|
+
if (!trimmed) continue;
|
|
26
|
+
out[locale] = trimmed.slice(0, maxLength);
|
|
27
|
+
hasEntries = true;
|
|
28
|
+
}
|
|
29
|
+
return hasEntries ? out : undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Normalizes a localization map for Discord command/option names (max 32 chars).
|
|
34
|
+
*/
|
|
35
|
+
function normalizeNameLocalizations(map) {
|
|
36
|
+
return normalizeLocaleMap(map, 32);
|
|
37
|
+
}
|
|
38
|
+
exports.normalizeNameLocalizations = normalizeNameLocalizations;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Normalizes a localization map for Discord descriptions (max 100 chars).
|
|
42
|
+
*/
|
|
43
|
+
function normalizeDescriptionLocalizations(map) {
|
|
44
|
+
return normalizeLocaleMap(map, 100);
|
|
45
|
+
}
|
|
46
|
+
exports.normalizeDescriptionLocalizations = normalizeDescriptionLocalizations;
|
|
47
|
+
|
|
18
48
|
class CommandBuilder {
|
|
19
49
|
name;
|
|
20
50
|
aliases;
|
|
@@ -29,6 +59,10 @@ class CommandBuilder {
|
|
|
29
59
|
botPermissions;
|
|
30
60
|
guards;
|
|
31
61
|
cooldown;
|
|
62
|
+
integrationTypes;
|
|
63
|
+
contexts;
|
|
64
|
+
nameLocalizations;
|
|
65
|
+
descriptionLocalizations;
|
|
32
66
|
|
|
33
67
|
constructor(options) {
|
|
34
68
|
this.name = options?.name ?? "";
|
|
@@ -43,6 +77,12 @@ class CommandBuilder {
|
|
|
43
77
|
this.botPermissions = permissionArrayPredicate.parse(options?.botPermissions ?? []);
|
|
44
78
|
this.guards = options?.guards ?? [];
|
|
45
79
|
this.cooldown = options?.cooldown;
|
|
80
|
+
this.integrationTypes = options?.integrationTypes;
|
|
81
|
+
this.contexts = options?.contexts;
|
|
82
|
+
this.nameLocalizations = normalizeNameLocalizations(options?.nameLocalizations ?? options?.name_localizations);
|
|
83
|
+
this.descriptionLocalizations = normalizeDescriptionLocalizations(
|
|
84
|
+
options?.descriptionLocalizations ?? options?.description_localizations
|
|
85
|
+
);
|
|
46
86
|
}
|
|
47
87
|
|
|
48
88
|
setName(name) {
|
|
@@ -95,12 +135,36 @@ class CommandBuilder {
|
|
|
95
135
|
return this;
|
|
96
136
|
}
|
|
97
137
|
|
|
138
|
+
setIntegrationTypes(...types) {
|
|
139
|
+
this.integrationTypes = types.flat();
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
setContexts(...contexts) {
|
|
144
|
+
this.contexts = contexts.flat();
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setNameLocalizations(locales) {
|
|
149
|
+
this.nameLocalizations = normalizeNameLocalizations(locales);
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
setDescriptionLocalizations(locales) {
|
|
154
|
+
this.descriptionLocalizations = normalizeDescriptionLocalizations(locales);
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
98
158
|
toJSON() {
|
|
99
159
|
return {
|
|
100
160
|
name: this.name,
|
|
101
|
-
description: this.description,
|
|
161
|
+
description: String(this.description ?? "...").slice(0, 100),
|
|
102
162
|
default_member_permissions: this.defaultMemberPermissions ? validateDefaultMemberPermissions(this.defaultMemberPermissions) : undefined,
|
|
103
163
|
dm_permission: typeof this.guildOnly === "boolean" ? !this.guildOnly : undefined,
|
|
164
|
+
...(this.nameLocalizations ? { name_localizations: this.nameLocalizations } : {}),
|
|
165
|
+
...(this.descriptionLocalizations ? { description_localizations: this.descriptionLocalizations } : {}),
|
|
166
|
+
...(this.integrationTypes !== undefined ? { integration_types: this.integrationTypes } : {}),
|
|
167
|
+
...(this.contexts !== undefined ? { contexts: this.contexts } : {}),
|
|
104
168
|
};
|
|
105
169
|
}
|
|
106
170
|
}
|