@elara-services/packages 5.1.0 → 5.2.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 +23 -0
- package/package.json +1 -1
- package/packages/Interactions.js +31 -0
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;
|
package/package.json
CHANGED
package/packages/Interactions.js
CHANGED
@@ -41,4 +41,35 @@ module.exports = class Interactions extends null {
|
|
41
41
|
components: options.components
|
42
42
|
};
|
43
43
|
};
|
44
|
+
|
45
|
+
static textInput(options = {}, row = false) {
|
46
|
+
let data = {};
|
47
|
+
|
48
|
+
if (options.type) data.type = options.type;
|
49
|
+
else data.type = 4;
|
50
|
+
|
51
|
+
if (options.id) data.custom_id = options.id;
|
52
|
+
else if (options.custom_id) data.custom_id = options.custom_id;
|
53
|
+
|
54
|
+
if (options.label) data.label = options.label;
|
55
|
+
else if (options.title) data.label = options.title;
|
56
|
+
|
57
|
+
if (options.style) data.style = options.style;
|
58
|
+
else data.style = 1;
|
59
|
+
|
60
|
+
if (options.min) data.min_length = options.min;
|
61
|
+
else if (options.min_length) data.min_length = options.min_length;
|
62
|
+
|
63
|
+
if (options.max) data.max_length = options.max;
|
64
|
+
else if (options.max_length) data.max_length = options.max_length;
|
65
|
+
|
66
|
+
if (options.holder) data.placeholder = options.holder;
|
67
|
+
else if (options.placeholder) data.placeholder = options.placeholder;
|
68
|
+
|
69
|
+
if (typeof options.required === "boolean") data.required = options.required;
|
70
|
+
if (options.value) data.value = options.value;
|
71
|
+
|
72
|
+
if (row) return data;
|
73
|
+
return { type: 1, components: [ data ] };
|
74
|
+
};
|
44
75
|
};
|