@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 CHANGED
@@ -1,3 +1,7 @@
1
+ # v4.7.0
2
+ Added `locale` option for `<SlashBuilder>.create`, `<SlashBuilder>.option`, `<SlashBuilder.context.user/message>`
3
+
4
+
1
5
  # v4.0.3, v4.0.2
2
6
  Added
3
7
  - fetch (useful with `@elara-services/fetch`)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elara-services/packages",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",
@@ -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
- return data;
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;