@elara-services/packages 1.0.0 → 3.0.2

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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }
package/CHANGELOG ADDED
@@ -0,0 +1,17 @@
1
+ # v3.0.1, v3.0.2
2
+
3
+ Fixed the typings for modal and added the typings for "ButtonStyle"
4
+
5
+
6
+ # v3.0.0
7
+
8
+ __Breaking Changes__
9
+ Removed `UserFlags`, `Permissions` and `BitField`
10
+
11
+
12
+ __Added__
13
+ `Interactions`
14
+ -> button
15
+ -> select
16
+ -> modal
17
+ And the typings.
package/index.d.ts CHANGED
@@ -9,7 +9,7 @@ declare module "@elara-services/packages" {
9
9
  public decrypt(encrypted: string): string;
10
10
  }
11
11
 
12
- export const Languages: object = "" | {};
12
+ export const Languages: object;
13
13
  export class Minesweeper {
14
14
  public constructor(options?: {
15
15
  rows?: number;
@@ -33,6 +33,12 @@ declare module "@elara-services/packages" {
33
33
  public start(): string | array[] | null;
34
34
  }
35
35
 
36
+ export class Interactions extends null {
37
+ public static button(options: ButtonOptions): Button;
38
+ public static select(options: SelectOptions): Select;
39
+ public static modal(options: ModalOptions): Modal;
40
+ }
41
+
36
42
  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';
37
43
 
38
44
  export type SlashOptions = {
@@ -46,14 +52,14 @@ declare module "@elara-services/packages" {
46
52
  max_value?: number;
47
53
  choices?: { name: string, value: string }[];
48
54
  options?: SlashOptions[];
49
- };
55
+ }
50
56
 
51
57
  export type Slash = {
52
58
  type?: number;
53
59
  defaultPermission?: boolean;
54
60
  default_permission?: boolean;
55
61
  options?: SlashOptions[];
56
- };
62
+ }
57
63
 
58
64
  export class SlashBuilder {
59
65
  public constructor();
@@ -80,7 +86,82 @@ declare module "@elara-services/packages" {
80
86
  public create(name: string, description: string, options: Slash): Slash;
81
87
  }
82
88
 
83
- export function randomWeight(objects: object[]): object;
89
+ export type Button = {
90
+ custom_id?: string;
91
+ label?: string;
92
+ type?: number;
93
+ style?: number;
94
+ disabled?: boolean;
95
+ emoji?: { name?: string, id?: string, animated?: boolean };
96
+ url?: string
97
+ }
98
+
99
+ export type ButtonOptions = {
100
+ id?: Button['custom_id'];
101
+ custom_id?: Button['custom_id'];
102
+ type?: Button['type'];
103
+ style?: ButtonStyles | Button['style'];
104
+ disabled?: Button['disabled'];
105
+ emoji?: Button['emoji'];
106
+ url?: Button['url']
107
+ }
108
+
109
+ export type ButtonStyles = 'PRIMARY' | 'BLURPLE' | 'SECONDARY' | 'GREY' | 'SUCCESS' | 'GREEN' | 'DANGER' | 'RED' | 'LINK' | 'URL'
110
+
111
+ export type Select = {
112
+ custom_id: string;
113
+ placeholder: string;
114
+ min_values: number;
115
+ max_values: number;
116
+ type: number;
117
+ options: {
118
+ label: string;
119
+ value: string;
120
+ description?: string;
121
+ emoji?: Button['emoji'],
122
+ default?: boolean;
123
+ }[]
124
+ }
125
+
126
+ export type SelectOptions = {
127
+ id?: Select['custom_id'];
128
+ custom_id?: Select['custom_id'];
129
+ holder?: Select['placeholder'];
130
+ min?: Select['min_values'];
131
+ max?: Select['max_values'];
132
+ type?: Select['type'];
133
+ options: Select['options']
134
+ }
135
+
136
+ export type Modal = {
137
+ title: string;
138
+ custom_id: string;
139
+ components: {
140
+ type: number,
141
+ components: {
142
+ type: number;
143
+ custom_id: string;
144
+ label: string;
145
+ style: 1 | 2 | number;
146
+ min_length?: number;
147
+ max_length?: number;
148
+ required?: boolean;
149
+ value?: string;
150
+ placeholder?: string;
151
+ }[]
152
+ }[]
153
+ }
154
+
155
+ export type ModalOptions = {
156
+ id?: Modal['custom_id'];
157
+ custom_id?: Modal['custom_id'];
158
+ title?: Modal['title'];
159
+ label?: Modal['title'];
160
+ components: Modal['components']
161
+ }
162
+
163
+
164
+ export function randomWeight(objects: object[]): object
84
165
  export function randomWords(options?: {
85
166
  exactly?: boolean;
86
167
  maxLength?: number;
@@ -90,5 +171,5 @@ declare module "@elara-services/packages" {
90
171
  formatter(word: string): void;
91
172
  separator: string;
92
173
  join: string;
93
- }): string | string[];
174
+ }): string | string[]
94
175
  }
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
+
1
2
  exports.AES = require("./packages/aes256");
2
3
  exports.Minesweeper = require("./packages/minesweeper");
3
4
  exports.randomWords = require("./packages/random/words");
4
5
  exports.randomWeight = require("./packages/random/weight");
5
6
  exports.Languages = require("./packages/languages");
6
- exports.SlashBuilder = require("./packages/SlashBuilder");
7
+ exports.SlashBuilder = require("./packages/SlashBuilder");
8
+ exports.Interactions = require("./packages/Interactions");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elara-services/packages",
3
- "version": "1.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",
@@ -0,0 +1,44 @@
1
+ module.exports = class Interactions extends null {
2
+ static button(options = {}) {
3
+ if (typeof options.style === "string") {
4
+ let styles = { PRIMARY: 1, BLURPLE: 1, SECONDARY: 2, GREY: 2, SUCCESS: 3, GREEN: 3, DANGER: 4, RED: 4, LINK: 5, URL: 5 };
5
+ let style = styles[options.style?.toUpperCase()];
6
+ if (!style) options.style = 2;
7
+ else options.style = style;
8
+ };
9
+ if (typeof options.url === "string" && options.url.match(/(https?|discord):\/\//gi)) {
10
+ options.style = 5;
11
+ options.id = "";
12
+ }
13
+ return {
14
+ custom_id: options?.id ?? options?.custom_id ?? "",
15
+ label: options?.title ?? "",
16
+ type: options?.type ?? 2,
17
+ style: options?.style ? options.style : 2,
18
+ disabled: Boolean(options.disabled),
19
+ emoji: options?.emoji ?? undefined,
20
+ url: options?.url ?? undefined
21
+ };
22
+ }
23
+
24
+ static select(options = {}) {
25
+ if (!options.options || !Array.isArray(options.options)) throw new Error(`[Dropdown#options]: isn't an array.`);
26
+ return {
27
+ custom_id: options?.id ?? options?.custom_id ?? "",
28
+ placeholder: options?.holder ?? "",
29
+ min_values: options?.min ?? 1,
30
+ max_values: options?.max ?? 1,
31
+ options: options?.options,
32
+ type: options?.type ?? 3,
33
+ }
34
+ }
35
+
36
+ static modal(options = {}) {
37
+ if (!options.components || !Array.isArray(options.components)) throw new Error(`[Modal#components]: isn't an array!`);
38
+ return {
39
+ custom_id: options?.id ?? options?.custom_id,
40
+ title: options?.title ?? options?.label,
41
+ components: options.components
42
+ };
43
+ };
44
+ };