djs-builder 0.6.17 ā 0.6.19
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 -56
- 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,64 +74,61 @@ async function Wait({
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
if (type === "interaction") {
|
|
77
|
-
const message = message_Wait;
|
|
78
|
-
if (!message)
|
|
79
|
-
throw new Error(
|
|
80
|
-
"You must provide messageWithButtons when using type 'button'."
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const collected = await message.awaitMessageComponent({
|
|
85
|
-
filter: (i) => !userId || i.user.id === userId,
|
|
86
|
-
time,
|
|
87
|
-
});
|
|
88
|
-
return collected ?? null;
|
|
89
|
-
} catch {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (type === "both") {
|
|
95
|
-
if (!message_Wait)
|
|
96
|
-
throw new Error(
|
|
97
|
-
"You must provide messageWithButtons when using type 'both'."
|
|
98
|
-
);
|
|
99
77
|
|
|
78
|
+
if (type === "interaction" || type === "both") {
|
|
100
79
|
return new Promise((resolve) => {
|
|
101
80
|
const collectors = [];
|
|
102
81
|
|
|
103
|
-
const msgCollector = channel.createMessageCollector({
|
|
104
|
-
filter: (m) => !userId || m.author.id === userId,
|
|
105
|
-
max: 1,
|
|
106
|
-
time,
|
|
107
|
-
});
|
|
108
82
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
83
|
+
if (type === "both") {
|
|
84
|
+
const msgCollector = channel.createMessageCollector({
|
|
85
|
+
filter: (m) => !userId || m.author.id === userId,
|
|
86
|
+
max: 1,
|
|
87
|
+
time,
|
|
88
|
+
});
|
|
114
89
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
90
|
+
msgCollector.on("collect", (msg) => {
|
|
91
|
+
cleanup();
|
|
92
|
+
resolve(msg);
|
|
93
|
+
});
|
|
120
94
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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) });
|
|
126
124
|
|
|
127
125
|
const timer = setTimeout(() => {
|
|
128
|
-
|
|
126
|
+
cleanup();
|
|
129
127
|
resolve(null);
|
|
130
128
|
}, time);
|
|
131
129
|
|
|
132
|
-
function
|
|
133
|
-
collectors.forEach((c) => c.stop());
|
|
130
|
+
function cleanup() {
|
|
131
|
+
collectors.forEach((c) => c.stop?.());
|
|
134
132
|
clearTimeout(timer);
|
|
135
133
|
}
|
|
136
134
|
});
|
|
@@ -139,6 +137,9 @@ async function Wait({
|
|
|
139
137
|
return null;
|
|
140
138
|
}
|
|
141
139
|
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
142
143
|
//////////////////////////////////* Row creat š©
|
|
143
144
|
|
|
144
145
|
function CreateRow(components) {
|
|
@@ -187,8 +188,7 @@ function CreateRow(components) {
|
|
|
187
188
|
value = false,
|
|
188
189
|
id = false,
|
|
189
190
|
max = false,
|
|
190
|
-
min = false,
|
|
191
|
-
disabled = false
|
|
191
|
+
min = false,
|
|
192
192
|
} = options;
|
|
193
193
|
|
|
194
194
|
const selectOptions = data.map((item, index) => {
|
|
@@ -225,9 +225,9 @@ function CreateRow(components) {
|
|
|
225
225
|
selectMenu.addOptions(selectOptions);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
if (options.hasOwnProperty("disabled")) {
|
|
229
|
+
selectMenu.setDisabled(options.disabled);
|
|
230
|
+
}
|
|
231
231
|
|
|
232
232
|
actionRows.push(new ActionRowBuilder().addComponents(selectMenu));
|
|
233
233
|
} else {
|
|
@@ -245,21 +245,21 @@ async function GetUser(message) {
|
|
|
245
245
|
let user = message.mentions.members.first();
|
|
246
246
|
let new_args = args;
|
|
247
247
|
|
|
248
|
-
|
|
249
248
|
if (!user && args[0]) {
|
|
250
249
|
const userId = args[0];
|
|
251
250
|
user = await message.guild.members.fetch(userId).catch(() => null);
|
|
252
251
|
new_args = args.slice(1);
|
|
253
252
|
}
|
|
254
253
|
|
|
255
|
-
|
|
256
254
|
if (!user && message.reference) {
|
|
257
255
|
const repliedMessage = await message.channel.messages
|
|
258
256
|
.fetch(message.reference.messageId)
|
|
259
257
|
.catch(() => null);
|
|
260
258
|
|
|
261
259
|
if (repliedMessage) {
|
|
262
|
-
user = await message.guild.members
|
|
260
|
+
user = await message.guild.members
|
|
261
|
+
.fetch(repliedMessage.author.id)
|
|
262
|
+
.catch(() => null);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
|
|
@@ -271,5 +271,4 @@ async function GetUser(message) {
|
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
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.19",
|
|
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": {
|