djs-builder 0.6.9 β 0.6.11
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/README.md +56 -12
- package/function/function.js +59 -25
- package/handler/helper.js +70 -18
- package/handler/starter.js +24 -23
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -127,8 +127,8 @@ const actionRow = new CreateRow([
|
|
|
127
127
|
{ name: 'Option 3', id: 'option3', about: 'Description for Option 3', icon: 'π' },
|
|
128
128
|
], //// is should not look like this ,you selecit it in next step
|
|
129
129
|
value: "id", // here you can set the value of the selected option ( defult the value is will be index (0,1,2 .....) )
|
|
130
|
-
description: "about" // here you can set the description of the selected option ( defult the description not work )
|
|
131
|
-
label: "name" // here you can set the label of the selected option ( defult the label is (Option 1 , Option 2 , Option 3) )
|
|
130
|
+
description: "about", // here you can set the description of the selected option ( defult the description not work )
|
|
131
|
+
label: "name", // here you can set the label of the selected option ( defult the label is (Option 1 , Option 2 , Option 3) )
|
|
132
132
|
emoji: "icon" // here you can set the emoji of the selected option ( defult the emoji not work )
|
|
133
133
|
|
|
134
134
|
}
|
|
@@ -230,24 +230,68 @@ module.exports = {
|
|
|
230
230
|
|
|
231
231
|
</details>
|
|
232
232
|
|
|
233
|
-
## π§ Commands
|
|
234
233
|
|
|
235
|
-
- **Slash π§** and **Prefix π¨** Have Same Options
|
|
236
234
|
<details>
|
|
237
|
-
<summary>
|
|
235
|
+
<summary>GetUser π€</summary>
|
|
236
|
+
|
|
237
|
+
**π€ Utility function to get a member from a message β¨.**
|
|
238
|
+
|
|
239
|
+
```js
|
|
240
|
+
const data = await GetUser(message);
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
### π¦ What does it return?
|
|
246
|
+
|
|
247
|
+
```js
|
|
248
|
+
{
|
|
249
|
+
user: <GuildMember>, // π― The targeted member
|
|
250
|
+
args: [ "word1", "word2" ] // βοΈ Remaining args after mention/ID
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### π How does it detect the user?
|
|
257
|
+
|
|
258
|
+
1. **Mention** inside the message
|
|
259
|
+
|
|
260
|
+
> Example: `!ban @Ahmed Breaking rules`.
|
|
261
|
+
|
|
262
|
+
2. **User ID** directly
|
|
263
|
+
|
|
264
|
+
> Example: `!ban 123456789012345678 Spamming`.
|
|
265
|
+
|
|
266
|
+
3. **Reply** to someoneβs message
|
|
267
|
+
|
|
268
|
+
> Reply to a userβs message with: `!ban`.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### π οΈ Example usage (ban command) π«
|
|
238
273
|
|
|
239
274
|
```js
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
275
|
+
client.on("messageCreate", async (message) => {
|
|
276
|
+
if (!message.content.startsWith("!ban")) return;
|
|
277
|
+
|
|
278
|
+
const data = await GetUser(message);
|
|
279
|
+
if (!data) return message.reply("β Couldn't find this user.");
|
|
280
|
+
|
|
281
|
+
const member = data.user;
|
|
282
|
+
const reason = data.args.join(" ") || "No reason provided";
|
|
283
|
+
|
|
284
|
+
await member.ban({ reason });
|
|
285
|
+
message.reply(`π« ${member.user.tag} has been banned for: ${reason}`);
|
|
286
|
+
});
|
|
247
287
|
```
|
|
248
288
|
|
|
289
|
+
---
|
|
290
|
+
|
|
249
291
|
</details>
|
|
250
292
|
|
|
293
|
+
|
|
294
|
+
|
|
251
295
|
## Contributions
|
|
252
296
|
|
|
253
297
|
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, feel free to contact us on discord.
|
package/function/function.js
CHANGED
|
@@ -61,12 +61,16 @@ async function Wait({
|
|
|
61
61
|
if (!channel) throw new Error("context must contain a valid channel.");
|
|
62
62
|
|
|
63
63
|
if (type === "message") {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
try {
|
|
65
|
+
const collected = await channel.awaitMessages({
|
|
66
|
+
filter: (m) => !userId || m.author.id === userId,
|
|
67
|
+
time,
|
|
68
|
+
max: 1,
|
|
69
|
+
});
|
|
70
|
+
return collected.first() || null;
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
if (type === "button") {
|
|
@@ -76,13 +80,15 @@ async function Wait({
|
|
|
76
80
|
"You must provide messageWithButtons when using type 'button'."
|
|
77
81
|
);
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
+
}
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
if (type === "both") {
|
|
@@ -106,13 +112,13 @@ async function Wait({
|
|
|
106
112
|
});
|
|
107
113
|
collectors.push(msgCollector);
|
|
108
114
|
|
|
109
|
-
const btnCollector =
|
|
115
|
+
const btnCollector = message_Wait.createMessageComponentCollector({
|
|
110
116
|
filter: (i) => !userId || i.user.id === userId,
|
|
111
117
|
max: 1,
|
|
112
118
|
time,
|
|
113
119
|
});
|
|
114
120
|
|
|
115
|
-
btnCollector.on("collect",
|
|
121
|
+
btnCollector.on("collect", (i) => {
|
|
116
122
|
stop();
|
|
117
123
|
resolve({ type: "button", data: i });
|
|
118
124
|
});
|
|
@@ -163,7 +169,7 @@ function CreateRow(components) {
|
|
|
163
169
|
but.setDisabled(buttonConfig.disabled);
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
if(buttonConfig.style === 5 && buttonConfig.url) {
|
|
172
|
+
if (buttonConfig.style === 5 && buttonConfig.url) {
|
|
167
173
|
but.setURL(buttonConfig.url);
|
|
168
174
|
}
|
|
169
175
|
|
|
@@ -204,17 +210,15 @@ function CreateRow(components) {
|
|
|
204
210
|
selectMenu = new ChannelSelectMenuBuilder();
|
|
205
211
|
}
|
|
206
212
|
|
|
207
|
-
|
|
208
213
|
selectMenu.setCustomId(id || "selectMenu");
|
|
209
214
|
selectMenu.setPlaceholder(placeholder);
|
|
210
|
-
if (min) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
+
if (min) {
|
|
216
|
+
const minValue = Math.min(min, data.length);
|
|
217
|
+
selectMenu.setMinValues(minValue);
|
|
218
|
+
selectMenu.setMaxValues(data.length);
|
|
219
|
+
}
|
|
215
220
|
|
|
216
|
-
if(max) selectMenu.setMaxValues(max);
|
|
217
|
-
|
|
221
|
+
if (max) selectMenu.setMaxValues(max);
|
|
218
222
|
|
|
219
223
|
if (type === "string") {
|
|
220
224
|
selectMenu.addOptions(selectOptions);
|
|
@@ -229,8 +233,38 @@ if(max) selectMenu.setMaxValues(max);
|
|
|
229
233
|
return actionRows;
|
|
230
234
|
}
|
|
231
235
|
|
|
236
|
+
//////////////////////////////////* Get User π
|
|
237
|
+
|
|
238
|
+
async function GetUser(message) {
|
|
239
|
+
const args = message.content.split(/\s+/).slice(1);
|
|
240
|
+
let user = message.mentions.members.first();
|
|
241
|
+
let new_args = args;
|
|
242
|
+
|
|
243
|
+
// Ψ₯Ψ°Ψ§ Ω
Ψ§ΩΩ Ω
ΩΨ΄Ω β Ψ¬Ψ±Ψ¨ Ψ§ΩΩ ID
|
|
244
|
+
if (!user && args[0]) {
|
|
245
|
+
const userId = args[0];
|
|
246
|
+
user = await message.guild.members.fetch(userId).catch(() => null);
|
|
247
|
+
new_args = args.slice(1);
|
|
248
|
+
}
|
|
232
249
|
|
|
250
|
+
// Ψ₯Ψ°Ψ§ Ω
Ψ§ΩΩ Ω
ΩΨ΄Ω ΩΩΨ§ ID β Ψ¬Ψ±Ψ¨ Ψ§ΩΨ±Ψ―
|
|
251
|
+
if (!user && message.reference) {
|
|
252
|
+
const repliedMessage = await message.channel.messages
|
|
253
|
+
.fetch(message.reference.messageId)
|
|
254
|
+
.catch(() => null);
|
|
233
255
|
|
|
256
|
+
if (repliedMessage) {
|
|
257
|
+
user = await message.guild.members.fetch(repliedMessage.author.id).catch(() => null);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (!user) return null;
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
user,
|
|
265
|
+
args: new_args,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
234
268
|
|
|
235
269
|
|
|
236
|
-
module.exports = { Wait, CreateBar, CreateRow };
|
|
270
|
+
module.exports = { Wait, CreateBar, CreateRow , GetUser};
|
package/handler/helper.js
CHANGED
|
@@ -194,38 +194,90 @@ async function set_anticrash(data) {
|
|
|
194
194
|
async function cmd_log(client, data, commandName, channelId) {
|
|
195
195
|
const isSlash = !!data.user;
|
|
196
196
|
const user = isSlash ? data.user : data.author;
|
|
197
|
-
const channel = data.guild ? `Channel: ${data.channel.name} | ${data.channel} (${data.channel.id})\n Guild: ${data.guild.name} | (${data.guild.id})` : "DM";
|
|
198
|
-
const messageUrl = data.message?.url || "`not found`";
|
|
199
197
|
|
|
200
198
|
const logChannel = client.channels.cache.get(channelId);
|
|
201
199
|
if (!logChannel) return;
|
|
202
200
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
201
|
+
let messageLink;
|
|
202
|
+
if (interaction.channel) {
|
|
203
|
+
messageLink = `https://discord.com/channels/${interaction.guild.id}/${interaction.channel.id}/${interaction.id}`;
|
|
204
|
+
} else {
|
|
205
|
+
messageLink = "Unknown";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
const field = [
|
|
210
|
+
{
|
|
211
|
+
name: "π§ Cmd:",
|
|
212
|
+
value: `- ${commandName}`,
|
|
213
|
+
inline: true,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "π€ User:",
|
|
217
|
+
value: `- ${user?.tag ?? "Unknown user"} | (\`${
|
|
218
|
+
user?.id ?? "Unknown ID"
|
|
219
|
+
}\`)`,
|
|
220
|
+
inline: true,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "\u200B",
|
|
224
|
+
value: "\u200B",
|
|
225
|
+
inline: true,
|
|
226
|
+
},
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
if (data.guild && data.channel) {
|
|
230
|
+
field.push(
|
|
208
231
|
{
|
|
209
|
-
name: "
|
|
210
|
-
value:
|
|
211
|
-
|
|
232
|
+
name: "π Server:",
|
|
233
|
+
value: `- ${data.guild.name} | (\`${data.guild.id}\`)`,
|
|
234
|
+
inline: true,
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "π¬ Channel",
|
|
238
|
+
value: `- ${data.channel.name} | (\`${data.channel.id}\`)`,
|
|
239
|
+
inline: true,
|
|
212
240
|
},
|
|
213
|
-
{ name: "π¬ Channel", value: `${channel}` },
|
|
214
|
-
{ name: "π Message", value: `[Link](${messageUrl})` },
|
|
215
241
|
{
|
|
216
|
-
name: "
|
|
217
|
-
value:
|
|
242
|
+
name: "\u200B",
|
|
243
|
+
value: "\u200B",
|
|
244
|
+
inline: true,
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "π Message",
|
|
248
|
+
value: messageLink ? `- [Link](${messageLink})` : "not found",
|
|
218
249
|
inline: true,
|
|
219
250
|
}
|
|
220
|
-
)
|
|
251
|
+
);
|
|
252
|
+
} else if (!data.guild) {
|
|
253
|
+
field.push({
|
|
254
|
+
name: "π DM Message",
|
|
255
|
+
value: `${user?.tag ?? "Unknown user"}`,
|
|
256
|
+
inline: true,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
field.push({
|
|
261
|
+
name: "β³ Date:",
|
|
262
|
+
value: `<t:${Math.floor(Date.now() / 1000)}:F>`,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const embed = new EmbedBuilder()
|
|
266
|
+
.setTitle(isSlash ? "π Slash Command Log" : "π Prefix Command Log")
|
|
267
|
+
.setColor(isSlash ? "Green" : "Blue")
|
|
268
|
+
.addFields(...field)
|
|
221
269
|
.setThumbnail(client.user.displayAvatarURL({ dynamic: true }))
|
|
222
270
|
.setAuthor({
|
|
223
|
-
name
|
|
224
|
-
iconURL: user
|
|
271
|
+
name: `${user?.tag ?? "Unknown user"} || ${user?.username ?? "Unknown"}`,
|
|
272
|
+
iconURL: user?.displayAvatarURL({ dynamic: true }),
|
|
225
273
|
})
|
|
226
274
|
.setTimestamp();
|
|
227
275
|
|
|
228
|
-
|
|
276
|
+
try {
|
|
277
|
+
await logChannel.send({ embeds: [embed] });
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.error("Error sending log embed:", error);
|
|
280
|
+
}
|
|
229
281
|
}
|
|
230
282
|
|
|
231
283
|
//////////////////////////////////* Check update πΌ
|
package/handler/starter.js
CHANGED
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
terminalInfo,
|
|
5
5
|
set_anticrash,
|
|
6
6
|
cmd_log,
|
|
7
|
-
update
|
|
7
|
+
update,
|
|
8
8
|
} = require("./helper");
|
|
9
9
|
let termenal = {
|
|
10
10
|
prefix: 0,
|
|
@@ -103,14 +103,16 @@ async function starter(client, options) {
|
|
|
103
103
|
const slash_files = await readFile(slash.path);
|
|
104
104
|
const validSlashCommands = slash_files
|
|
105
105
|
.map((f) => require(f.path))
|
|
106
|
-
.filter(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
.filter(
|
|
107
|
+
(cmd) =>
|
|
108
|
+
cmd.data &&
|
|
109
|
+
(typeof cmd.run === "function" || typeof cmd.execute === "function")
|
|
110
|
+
);
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
client.slashCommands = new Map(
|
|
113
|
+
validSlashCommands.map((cmd) => [cmd.data.name, cmd])
|
|
114
|
+
);
|
|
115
|
+
client.slashData = validSlashCommands.map((cmd) => cmd.data.toJSON());
|
|
114
116
|
|
|
115
117
|
termenal.slash = validSlashCommands.length;
|
|
116
118
|
}
|
|
@@ -149,7 +151,6 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
|
|
|
149
151
|
//////////////////////////////////////////* prefix run !////////////////////////////////////////////////////////
|
|
150
152
|
|
|
151
153
|
client.on("messageCreate", async (message) => {
|
|
152
|
-
|
|
153
154
|
if (message.author.bot) return;
|
|
154
155
|
|
|
155
156
|
const content = message.content.trim();
|
|
@@ -209,7 +210,7 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
|
|
|
209
210
|
|
|
210
211
|
try {
|
|
211
212
|
if (typeof command.run === "function") {
|
|
212
|
-
await command.run(client
|
|
213
|
+
await command.run(client, message, args);
|
|
213
214
|
} else if (typeof command.execute === "function") {
|
|
214
215
|
await command.execute(client, message, args);
|
|
215
216
|
}
|
|
@@ -286,7 +287,12 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
|
|
|
286
287
|
}
|
|
287
288
|
|
|
288
289
|
if (options.slash.log) {
|
|
289
|
-
await cmd_log(
|
|
290
|
+
await cmd_log(
|
|
291
|
+
client,
|
|
292
|
+
interaction,
|
|
293
|
+
interaction.commandName,
|
|
294
|
+
options.slash.log
|
|
295
|
+
);
|
|
290
296
|
}
|
|
291
297
|
try {
|
|
292
298
|
if (typeof command.run === "function") {
|
|
@@ -316,26 +322,21 @@ client.slashData = validSlashCommands.map(cmd => cmd.data.toJSON());
|
|
|
316
322
|
|
|
317
323
|
client.once("ready", async () => {
|
|
318
324
|
if (ownerId) client.owner = await client.users.fetch(ownerId);
|
|
319
|
-
if (client.slashData?.length) {
|
|
320
|
-
|
|
321
|
-
}
|
|
325
|
+
if (client.slashData?.length) {
|
|
326
|
+
await client.application.commands.set(client.slashData);
|
|
327
|
+
}
|
|
322
328
|
|
|
323
329
|
if (terminal_info) {
|
|
324
330
|
await terminalInfo(client, options, termenal);
|
|
325
331
|
}
|
|
326
332
|
});
|
|
327
333
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
update(client,ownerId, anticrash.url);
|
|
332
|
-
}, 1000 * 60 * 60);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
setInterval(() => {
|
|
335
|
+
update(client, ownerId, anticrash.url);
|
|
336
|
+
}, 1000 * 60 * 60);
|
|
336
337
|
}
|
|
337
338
|
|
|
338
339
|
const { Wait, CreateBar, CreateRow } = require("../function/function");
|
|
339
340
|
const { log } = require("../function/log");
|
|
340
341
|
|
|
341
|
-
module.exports = { starter
|
|
342
|
+
module.exports = { starter, log, Wait, CreateBar, CreateRow };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
{
|
|
3
3
|
"name": "djs-builder",
|
|
4
|
-
"version": "0.6.
|
|
5
|
-
|
|
4
|
+
"version": "0.6.11",
|
|
5
|
+
"description": "π Package Update! π₯\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",
|
|
6
6
|
"main": "handler/starter.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"axios": "^1.11.0",
|