@elara-services/packages 4.8.1 → 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 +16 -0
- package/index.d.ts +30 -7
- package/package.json +1 -1
- package/packages/Interactions.js +32 -1
- package/packages/SlashBuilder.js +4 -8
package/CHANGELOG
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# v5.2.0
|
2
|
+
- Added `textInput` for `Interactions`
|
3
|
+
- Added typings for `textInput` helper function.
|
4
|
+
|
5
|
+
# v5.1.0
|
6
|
+
- Added `name_localizations` for `SlashBuilder.choice`
|
7
|
+
- Added typings for `min_length` and `max_length` for `SlashBuilder.option` for STRING options.
|
8
|
+
- Fixed typings for `Interactions.button` to have `label` and `title`
|
9
|
+
- Fixed `Interactions.button` to allow for `title` and `label`
|
10
|
+
|
11
|
+
|
12
|
+
# v5.0.0
|
13
|
+
### BREAKING CHANGES
|
14
|
+
- `locale` option for `SlashBuilder.context.user` and `SlashBuilder.context.message` was turned into `options` taking in more options (to support both permissions and locale)
|
15
|
+
- `defaultPermission`/`default_permission` was removed, since it's deprecated. (if you want to use it then stay on v4.8.1)
|
16
|
+
|
1
17
|
# v4.8.0/v4.8.1
|
2
18
|
- Added: `dmPermission` (`dm_permission`) for SlashBuilder.create
|
3
19
|
- Added: `defaultMemberPermissions` (`default_member_permissions`) for SlashBuilder.create
|
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;
|
@@ -54,6 +77,8 @@ declare module "@elara-services/packages" {
|
|
54
77
|
autocomplete?: boolean;
|
55
78
|
min_value?: number;
|
56
79
|
max_value?: number;
|
80
|
+
min_length?: number;
|
81
|
+
max_length?: number;
|
57
82
|
choices?: { name: string, value: string }[];
|
58
83
|
options?: SlashOptions[];
|
59
84
|
locale?: {
|
@@ -76,10 +101,6 @@ declare module "@elara-services/packages" {
|
|
76
101
|
names?: object;
|
77
102
|
descriptions?: object;
|
78
103
|
}
|
79
|
-
/** @deprecated - Use defaultMemberPermissions or dmPermission */
|
80
|
-
defaultPermission?: boolean;
|
81
|
-
/** @deprecated - Use defaultMemberPermissions or dmPermission */
|
82
|
-
default_permission?: boolean;
|
83
104
|
}
|
84
105
|
|
85
106
|
export class SlashBuilder {
|
@@ -104,11 +125,11 @@ declare module "@elara-services/packages" {
|
|
104
125
|
};
|
105
126
|
|
106
127
|
public static context: {
|
107
|
-
user(name: string,
|
108
|
-
message(name: string,
|
128
|
+
user(name: string, options?: Omit<Slash, "options"|"type">): Slash;
|
129
|
+
message(name: string, options?: Omit<Slash, "options"|"type">): Slash;
|
109
130
|
};
|
110
131
|
|
111
|
-
public static choice(name: string, value: string|number): { name: string, value: string|number };
|
132
|
+
public static choice(name: string, value: string|number, name_localizations?: object): { name: string, value: string|number, name_localizations: object };
|
112
133
|
public static option(data: SlashOptions): Slash;
|
113
134
|
public static create(name: string, description: string, options: Slash): Slash;
|
114
135
|
}
|
@@ -125,6 +146,8 @@ declare module "@elara-services/packages" {
|
|
125
146
|
|
126
147
|
export type ButtonOptions = {
|
127
148
|
id?: Button['custom_id'];
|
149
|
+
title?: Button['label'];
|
150
|
+
label?: Button['label'];
|
128
151
|
custom_id?: Button['custom_id'];
|
129
152
|
type?: Button['type'];
|
130
153
|
style?: ButtonStyles | Button['style'];
|
package/package.json
CHANGED
package/packages/Interactions.js
CHANGED
@@ -12,7 +12,7 @@ module.exports = class Interactions extends null {
|
|
12
12
|
}
|
13
13
|
return {
|
14
14
|
custom_id: options?.id ?? options?.custom_id ?? "",
|
15
|
-
label: options?.title ?? "",
|
15
|
+
label: options?.title ?? options?.label ?? "",
|
16
16
|
type: options?.type ?? 2,
|
17
17
|
style: options?.style ? options.style : 2,
|
18
18
|
disabled: Boolean(options.disabled),
|
@@ -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
|
};
|
package/packages/SlashBuilder.js
CHANGED
@@ -24,13 +24,13 @@ module.exports = class SlashBuilder extends null {
|
|
24
24
|
|
25
25
|
static get context() {
|
26
26
|
return {
|
27
|
-
user: (name,
|
28
|
-
message: (name,
|
27
|
+
user: (name, options) => this.create(name, "", { type: this.types.context.user, ...options }),
|
28
|
+
message: (name, options) => this.create(name, "", { type: this.types.context.message, ...options })
|
29
29
|
}
|
30
30
|
};
|
31
31
|
|
32
|
-
static choice(name, value) {
|
33
|
-
return { name, value };
|
32
|
+
static choice(name, value, name_localizations) {
|
33
|
+
return { name, value, name_localizations };
|
34
34
|
};
|
35
35
|
|
36
36
|
static option(data) {
|
@@ -48,10 +48,6 @@ module.exports = class SlashBuilder extends null {
|
|
48
48
|
if (options?.options?.length) obj.options = options.options;
|
49
49
|
if (options?.type) obj.type = options.type;
|
50
50
|
|
51
|
-
// TODO: Remove this, as it's deprecated.
|
52
|
-
if ("defaultPermission" in options) obj.default_permission = options.defaultPermission;
|
53
|
-
else if ("default_permission" in options) obj.default_permission = options.default_permission;
|
54
|
-
|
55
51
|
if ("dmPermission" in options) obj.dm_permission = options.dmPermission;
|
56
52
|
else if ("dm_permission" in options) obj.dm_permission = options.dm_permission;
|
57
53
|
|