@elara-services/packages 4.6.0 → 4.7.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/CHANGELOG +4 -0
- package/index.d.ts +10 -2
- package/package.json +1 -1
- package/packages/SlashBuilder.js +9 -3
package/CHANGELOG
CHANGED
package/index.d.ts
CHANGED
@@ -56,6 +56,10 @@ declare module "@elara-services/packages" {
|
|
56
56
|
max_value?: number;
|
57
57
|
choices?: { name: string, value: string }[];
|
58
58
|
options?: SlashOptions[];
|
59
|
+
locale?: {
|
60
|
+
names?: object;
|
61
|
+
descriptions?: object;
|
62
|
+
}
|
59
63
|
}
|
60
64
|
|
61
65
|
export type Slash = {
|
@@ -63,6 +67,10 @@ declare module "@elara-services/packages" {
|
|
63
67
|
defaultPermission?: boolean;
|
64
68
|
default_permission?: boolean;
|
65
69
|
options?: SlashOptions[];
|
70
|
+
locale?: {
|
71
|
+
names?: object;
|
72
|
+
descriptions?: object;
|
73
|
+
}
|
66
74
|
}
|
67
75
|
|
68
76
|
export class SlashBuilder {
|
@@ -87,8 +95,8 @@ declare module "@elara-services/packages" {
|
|
87
95
|
};
|
88
96
|
|
89
97
|
public static context: {
|
90
|
-
user(name: string): Slash;
|
91
|
-
message(name: string): Slash;
|
98
|
+
user(name: string, locale?: { names?: object }): Slash;
|
99
|
+
message(name: string, locale?: { names?: object }): Slash;
|
92
100
|
};
|
93
101
|
|
94
102
|
public static choice(name: string, value: string|number): { name: string, value: string|number };
|
package/package.json
CHANGED
package/packages/SlashBuilder.js
CHANGED
@@ -24,8 +24,8 @@ module.exports = class SlashBuilder extends null {
|
|
24
24
|
|
25
25
|
static get context() {
|
26
26
|
return {
|
27
|
-
user: (name) => this.create(name, "", { type: 2 }),
|
28
|
-
message: (name) => this.create(name, "", { type: 3 })
|
27
|
+
user: (name, locale) => this.create(name, "", { type: 2, locale }),
|
28
|
+
message: (name, locale) => this.create(name, "", { type: 3, locale })
|
29
29
|
}
|
30
30
|
};
|
31
31
|
|
@@ -34,11 +34,17 @@ module.exports = class SlashBuilder extends null {
|
|
34
34
|
};
|
35
35
|
|
36
36
|
static option(data) {
|
37
|
-
|
37
|
+
let _data = { ...data };
|
38
|
+
if (_data.locale?.names) _data.name_localizations = _data.locale.names;
|
39
|
+
if (_data.locale?.descriptions) _data.description_localizations = _data.locale.descriptions;
|
40
|
+
if ("locale" in _data) delete _data["locale"];
|
41
|
+
return _data;
|
38
42
|
};
|
39
43
|
|
40
44
|
static create(name, description, options = { }) {
|
41
45
|
let obj = { name, description };
|
46
|
+
if (options.locale?.names) obj.name_localizations = options.locale.names;
|
47
|
+
if (options.locale?.descriptions) obj.description_localizations = options.locale.descriptions;
|
42
48
|
if (options?.options?.length) obj.options = options.options;
|
43
49
|
if (options.type) obj.type = options.type;
|
44
50
|
if (typeof options.defaultPermission === "boolean") obj.default_permission = options.defaultPermission;
|