@elara-services/packages 5.1.0 → 5.3.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
+ # v5.2.0
2
+ - Added `textInput` for `Interactions`
3
+ - Added typings for `textInput` helper function.
4
+
1
5
  # v5.1.0
2
6
  - Added `name_localizations` for `SlashBuilder.choice`
3
7
  - Added typings for `min_length` and `max_length` for `SlashBuilder.option` for STRING options.
package/index.d.ts CHANGED
@@ -41,10 +41,33 @@ declare module "@elara-services/packages" {
41
41
  public static button(options: ButtonOptions): Button;
42
42
  public static select(options: SelectOptions): Select;
43
43
  public static modal(options: ModalOptions): Modal;
44
+ public static textInput(options: TextInputOptions, row?: boolean): TextInput | { type: number, components: [ TextInput ] };
44
45
  }
45
46
 
46
47
  export type ChannelTypes = 'GUILD_TEXT' | 'DM' | 'GUILD_VOICE' | 'GROUP_DM' | 'GUILD_CATEGORY' | 'GUILD_NEWS' | 'GUILD_STORE' | 'GUILD_NEWS_THREAD' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_STAGE_VOICE';
47
48
 
49
+ export type TextInputOptions = {
50
+ id?: string;
51
+ type?: number;
52
+ title?: string;
53
+ style?: number;
54
+ min?: number;
55
+ max?: number;
56
+ holder?: string;
57
+ } & TextInput;
58
+
59
+ export type TextInput = {
60
+ custom_id?: string;
61
+ type?: number;
62
+ label?: string;
63
+ style?: number;
64
+ min_length?: number;
65
+ max_length?: number;
66
+ placeholder?: string;
67
+ value?: string;
68
+ required?: boolean;
69
+ }
70
+
48
71
  export type SlashOptions = {
49
72
  type: number;
50
73
  name: string;
@@ -141,6 +164,7 @@ declare module "@elara-services/packages" {
141
164
  min_values: number;
142
165
  max_values: number;
143
166
  type: number;
167
+ disabled: boolean;
144
168
  options: {
145
169
  label: string;
146
170
  value: string;
@@ -157,7 +181,8 @@ declare module "@elara-services/packages" {
157
181
  min?: Select['min_values'];
158
182
  max?: Select['max_values'];
159
183
  type?: Select['type'];
160
- options: Select['options']
184
+ options: Select['options'];
185
+ disabled?: Select['disabled'];
161
186
  }
162
187
 
163
188
  export type Modal = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elara-services/packages",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",
@@ -30,6 +30,7 @@ module.exports = class Interactions extends null {
30
30
  max_values: options?.max ?? 1,
31
31
  options: options?.options,
32
32
  type: options?.type ?? 3,
33
+ disabled: typeof options?.disabled === "boolean" ? options.disabled : false
33
34
  }
34
35
  }
35
36
 
@@ -41,4 +42,35 @@ module.exports = class Interactions extends null {
41
42
  components: options.components
42
43
  };
43
44
  };
45
+
46
+ static textInput(options = {}, row = false) {
47
+ let data = {};
48
+
49
+ if (options.type) data.type = options.type;
50
+ else data.type = 4;
51
+
52
+ if (options.id) data.custom_id = options.id;
53
+ else if (options.custom_id) data.custom_id = options.custom_id;
54
+
55
+ if (options.label) data.label = options.label;
56
+ else if (options.title) data.label = options.title;
57
+
58
+ if (options.style) data.style = options.style;
59
+ else data.style = 1;
60
+
61
+ if (options.min) data.min_length = options.min;
62
+ else if (options.min_length) data.min_length = options.min_length;
63
+
64
+ if (options.max) data.max_length = options.max;
65
+ else if (options.max_length) data.max_length = options.max_length;
66
+
67
+ if (options.holder) data.placeholder = options.holder;
68
+ else if (options.placeholder) data.placeholder = options.placeholder;
69
+
70
+ if (typeof options.required === "boolean") data.required = options.required;
71
+ if (options.value) data.value = options.value;
72
+
73
+ if (row) return data;
74
+ return { type: 1, components: [ data ] };
75
+ };
44
76
  };