djs-builder 0.6.18 ā 0.6.20
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/function/function.js +55 -48
- package/package.json +1 -1
package/function/function.js
CHANGED
|
@@ -60,6 +60,7 @@ async function Wait({
|
|
|
60
60
|
const channel = context.channel;
|
|
61
61
|
if (!channel) throw new Error("context must contain a valid channel.");
|
|
62
62
|
|
|
63
|
+
|
|
63
64
|
if (type === "message") {
|
|
64
65
|
try {
|
|
65
66
|
const collected = await channel.awaitMessages({
|
|
@@ -73,56 +74,61 @@ async function Wait({
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
if (type === "interaction") {
|
|
77
|
-
const message = message_Wait;
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
const collected = await message.awaitMessageComponent({
|
|
81
|
-
filter: (i) => !userId || i.user.id === userId,
|
|
82
|
-
time,
|
|
83
|
-
});
|
|
84
|
-
return collected ?? null;
|
|
85
|
-
} catch {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (type === "both") {
|
|
91
77
|
|
|
78
|
+
if (type === "interaction" || type === "both") {
|
|
92
79
|
return new Promise((resolve) => {
|
|
93
80
|
const collectors = [];
|
|
94
81
|
|
|
95
|
-
const msgCollector = channel.createMessageCollector({
|
|
96
|
-
filter: (m) => !userId || m.author.id === userId,
|
|
97
|
-
max: 1,
|
|
98
|
-
time,
|
|
99
|
-
});
|
|
100
82
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
83
|
+
if (type === "both") {
|
|
84
|
+
const msgCollector = channel.createMessageCollector({
|
|
85
|
+
filter: (m) => !userId || m.author.id === userId,
|
|
86
|
+
max: 1,
|
|
87
|
+
time,
|
|
88
|
+
});
|
|
106
89
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
90
|
+
msgCollector.on("collect", (msg) => {
|
|
91
|
+
cleanup();
|
|
92
|
+
resolve(msg);
|
|
93
|
+
});
|
|
112
94
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
95
|
+
collectors.push(msgCollector);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if (message_Wait) {
|
|
100
|
+
const btnCollector = message_Wait.createMessageComponentCollector({
|
|
101
|
+
filter: (i) => !userId || i.user.id === userId,
|
|
102
|
+
max: 1,
|
|
103
|
+
time,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
btnCollector.on("collect", (i) => {
|
|
107
|
+
cleanup();
|
|
108
|
+
resolve(i);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
collectors.push(btnCollector);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const modalListener = (i) => {
|
|
116
|
+
if (!i.isModalSubmit()) return;
|
|
117
|
+
if (userId && i.user.id !== userId) return;
|
|
118
|
+
cleanup();
|
|
119
|
+
resolve(i);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
context.client.on("interactionCreate", modalListener);
|
|
123
|
+
collectors.push({ stop: () => context.client.removeListener("interactionCreate", modalListener) });
|
|
118
124
|
|
|
119
125
|
const timer = setTimeout(() => {
|
|
120
|
-
|
|
126
|
+
cleanup();
|
|
121
127
|
resolve(null);
|
|
122
128
|
}, time);
|
|
123
129
|
|
|
124
|
-
function
|
|
125
|
-
collectors.forEach((c) => c.stop());
|
|
130
|
+
function cleanup() {
|
|
131
|
+
collectors.forEach((c) => c.stop?.());
|
|
126
132
|
clearTimeout(timer);
|
|
127
133
|
}
|
|
128
134
|
});
|
|
@@ -131,6 +137,9 @@ async function Wait({
|
|
|
131
137
|
return null;
|
|
132
138
|
}
|
|
133
139
|
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
134
143
|
//////////////////////////////////* Row creat š©
|
|
135
144
|
|
|
136
145
|
function CreateRow(components) {
|
|
@@ -179,8 +188,7 @@ function CreateRow(components) {
|
|
|
179
188
|
value = false,
|
|
180
189
|
id = false,
|
|
181
190
|
max = false,
|
|
182
|
-
min = false,
|
|
183
|
-
disabled = false
|
|
191
|
+
min = false,
|
|
184
192
|
} = options;
|
|
185
193
|
|
|
186
194
|
const selectOptions = data.map((item, index) => {
|
|
@@ -217,9 +225,9 @@ function CreateRow(components) {
|
|
|
217
225
|
selectMenu.addOptions(selectOptions);
|
|
218
226
|
}
|
|
219
227
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
228
|
+
if (options.hasOwnProperty("disabled")) {
|
|
229
|
+
selectMenu.setDisabled(options.disabled);
|
|
230
|
+
}
|
|
223
231
|
|
|
224
232
|
actionRows.push(new ActionRowBuilder().addComponents(selectMenu));
|
|
225
233
|
} else {
|
|
@@ -237,21 +245,21 @@ async function GetUser(message) {
|
|
|
237
245
|
let user = message.mentions.members.first();
|
|
238
246
|
let new_args = args;
|
|
239
247
|
|
|
240
|
-
|
|
241
248
|
if (!user && args[0]) {
|
|
242
249
|
const userId = args[0];
|
|
243
250
|
user = await message.guild.members.fetch(userId).catch(() => null);
|
|
244
251
|
new_args = args.slice(1);
|
|
245
252
|
}
|
|
246
253
|
|
|
247
|
-
|
|
248
254
|
if (!user && message.reference) {
|
|
249
255
|
const repliedMessage = await message.channel.messages
|
|
250
256
|
.fetch(message.reference.messageId)
|
|
251
257
|
.catch(() => null);
|
|
252
258
|
|
|
253
259
|
if (repliedMessage) {
|
|
254
|
-
user = await message.guild.members
|
|
260
|
+
user = await message.guild.members
|
|
261
|
+
.fetch(repliedMessage.author.id)
|
|
262
|
+
.catch(() => null);
|
|
255
263
|
}
|
|
256
264
|
}
|
|
257
265
|
|
|
@@ -263,5 +271,4 @@ async function GetUser(message) {
|
|
|
263
271
|
};
|
|
264
272
|
}
|
|
265
273
|
|
|
266
|
-
|
|
267
|
-
module.exports = { Wait, CreateBar, CreateRow , GetUser};
|
|
274
|
+
module.exports = { Wait, CreateBar, CreateRow, GetUser };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
{
|
|
3
3
|
"name": "djs-builder",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.20",
|
|
5
5
|
"description": "š Package Update! š„\n- Add option `disabled` to the selectMenu options \nNew features added:\n- `GetUser`: Easily fetch a user from **ID**, **mention**, or even from a **reply**.\n\nš Fixes:\n- Minor bugs fixed\n- Improved stability and error handling\n\nš Learn more on [NPM](https://www.npmjs.com/package/djs-builder)",
|
|
6
6
|
"main": "handler/starter.js",
|
|
7
7
|
"dependencies": {
|