xernerx 3.5.0 → 3.5.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.
- package/dist/cjs/build/ContextCommandBuilder.js +97 -0
- package/dist/cjs/build/EventBuilder.js +44 -0
- package/dist/cjs/build/InhibitorBuilder.js +37 -0
- package/dist/cjs/build/MessageCommandBuilder.js +100 -0
- package/{types → dist/cjs}/build/SlashCommandBuilder.d.ts +2 -1
- package/dist/cjs/build/SlashCommandBuilder.js +169 -0
- package/dist/cjs/client/XernerxClient.js +116 -0
- package/dist/{handlers → cjs/handlers}/CommandHandler.js +11 -8
- package/dist/{handlers → cjs/handlers}/EventHandler.js +6 -3
- package/dist/cjs/handlers/Handler.js +308 -0
- package/dist/{handlers → cjs/handlers}/InhibitorHandler.js +6 -3
- package/dist/cjs/main.js +112 -0
- package/dist/{models → cjs/models}/CommandArguments.js +37 -52
- package/dist/cjs/models/Events.js +307 -0
- package/dist/cjs/models/Extensions.js +26 -0
- package/dist/{tools → cjs/tools}/XernerxError.js +4 -1
- package/{types → dist/cjs}/tools/package.d.ts +11 -0
- package/dist/cjs/tools/package.js +50 -0
- package/dist/cjs/types/enums.js +38 -0
- package/dist/cjs/types/interfaces.js +2 -0
- package/dist/cjs/types/options.js +2 -0
- package/dist/cjs/types/types.js +2 -0
- package/dist/{utils → cjs/utils}/ClientUtil.js +73 -84
- package/dist/{utils → cjs/utils}/CommandUtil.js +102 -103
- package/dist/{validators → cjs/validators}/CommandValidations.js +36 -50
- package/dist/{validators → cjs/validators}/InhibitorValidations.js +12 -14
- package/dist/mjs/build/ContextCommandBuilder.d.ts +68 -0
- package/dist/mjs/build/ContextCommandBuilder.js +97 -0
- package/dist/mjs/build/EventBuilder.d.ts +21 -0
- package/dist/mjs/build/EventBuilder.js +44 -0
- package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
- package/dist/mjs/build/InhibitorBuilder.js +37 -0
- package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
- package/dist/mjs/build/MessageCommandBuilder.js +100 -0
- package/dist/mjs/build/SlashCommandBuilder.d.ts +65 -0
- package/dist/mjs/build/SlashCommandBuilder.js +169 -0
- package/dist/mjs/client/XernerxClient.d.ts +28 -0
- package/dist/mjs/client/XernerxClient.js +116 -0
- package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
- package/dist/mjs/handlers/CommandHandler.js +45 -0
- package/dist/mjs/handlers/EventHandler.d.ts +13 -0
- package/dist/mjs/handlers/EventHandler.js +19 -0
- package/dist/mjs/handlers/Handler.d.ts +57 -0
- package/dist/mjs/handlers/Handler.js +308 -0
- package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
- package/dist/mjs/handlers/InhibitorHandler.js +24 -0
- package/dist/{main.js → mjs/main.d.ts} +20 -18
- package/dist/mjs/main.js +112 -0
- package/dist/mjs/models/CommandArguments.d.ts +17 -0
- package/dist/mjs/models/CommandArguments.js +106 -0
- package/dist/mjs/models/Events.d.ts +24 -0
- package/dist/mjs/models/Events.js +307 -0
- package/dist/mjs/models/Extensions.d.ts +7 -0
- package/dist/mjs/models/Extensions.js +26 -0
- package/dist/mjs/tools/XernerxError.d.ts +5 -0
- package/dist/mjs/tools/XernerxError.js +11 -0
- package/dist/mjs/tools/package.d.ts +49 -0
- package/dist/mjs/tools/package.js +50 -0
- package/dist/mjs/types/enums.d.ts +44 -0
- package/dist/mjs/types/enums.js +38 -0
- package/dist/mjs/types/interfaces.d.ts +25 -0
- package/dist/mjs/types/interfaces.js +2 -0
- package/dist/mjs/types/options.d.ts +241 -0
- package/dist/mjs/types/options.js +2 -0
- package/dist/mjs/types/types.d.ts +61 -0
- package/dist/mjs/types/types.js +2 -0
- package/dist/mjs/utils/ClientUtil.d.ts +25 -0
- package/dist/mjs/utils/ClientUtil.js +211 -0
- package/dist/mjs/utils/CommandUtil.d.ts +58 -0
- package/dist/mjs/utils/CommandUtil.js +247 -0
- package/dist/mjs/validators/CommandValidations.d.ts +12 -0
- package/dist/mjs/validators/CommandValidations.js +169 -0
- package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
- package/dist/mjs/validators/InhibitorValidations.js +40 -0
- package/package.json +11 -16
- package/dist/build/ContextCommandBuilder.js +0 -93
- package/dist/build/EventBuilder.js +0 -34
- package/dist/build/InhibitorBuilder.js +0 -27
- package/dist/build/MessageCommandBuilder.js +0 -90
- package/dist/build/SlashCommandBuilder.js +0 -125
- package/dist/client/XernerxClient.js +0 -101
- package/dist/handlers/Handler.js +0 -250
- package/dist/main.cjs +0 -2012
- package/dist/models/Events.js +0 -294
- package/dist/models/Extensions.js +0 -23
- package/dist/tools/package.js +0 -37
- package/dist/types/enums.js +0 -35
- package/dist/types/interfaces.js +0 -1
- package/dist/types/options.js +0 -1
- package/dist/types/types.js +0 -1
- package/dist/validators/Shapes.js +0 -1
- package/types/validators/Shapes.d.ts +0 -1
- /package/{types → dist/cjs}/build/ContextCommandBuilder.d.ts +0 -0
- /package/{types → dist/cjs}/build/EventBuilder.d.ts +0 -0
- /package/{types → dist/cjs}/build/InhibitorBuilder.d.ts +0 -0
- /package/{types → dist/cjs}/build/MessageCommandBuilder.d.ts +0 -0
- /package/{types → dist/cjs}/client/XernerxClient.d.ts +0 -0
- /package/{types → dist/cjs}/handlers/CommandHandler.d.ts +0 -0
- /package/{types → dist/cjs}/handlers/EventHandler.d.ts +0 -0
- /package/{types → dist/cjs}/handlers/Handler.d.ts +0 -0
- /package/{types → dist/cjs}/handlers/InhibitorHandler.d.ts +0 -0
- /package/{types → dist/cjs}/main.d.ts +0 -0
- /package/{types → dist/cjs}/models/CommandArguments.d.ts +0 -0
- /package/{types → dist/cjs}/models/Events.d.ts +0 -0
- /package/{types → dist/cjs}/models/Extensions.d.ts +0 -0
- /package/{types → dist/cjs}/tools/XernerxError.d.ts +0 -0
- /package/{types → dist/cjs}/types/enums.d.ts +0 -0
- /package/{types → dist/cjs}/types/interfaces.d.ts +0 -0
- /package/{types → dist/cjs}/types/options.d.ts +0 -0
- /package/{types → dist/cjs}/types/types.d.ts +0 -0
- /package/{types → dist/cjs}/utils/ClientUtil.d.ts +0 -0
- /package/{types → dist/cjs}/utils/CommandUtil.d.ts +0 -0
- /package/{types → dist/cjs}/validators/CommandValidations.d.ts +0 -0
- /package/{types → dist/cjs}/validators/InhibitorValidations.d.ts +0 -0
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
+
exports.ClientUtil = void 0;
|
|
9
|
+
const XernerxError_js_1 = __importDefault(require('../tools/XernerxError.js'));
|
|
10
|
+
class ClientUtil {
|
|
3
11
|
client;
|
|
4
12
|
constructor(client) {
|
|
5
13
|
this.client = client;
|
|
6
14
|
}
|
|
7
15
|
uptime(timestamp) {
|
|
8
|
-
if (!timestamp)
|
|
9
|
-
timestamp = this.client.uptime || 0;
|
|
16
|
+
if (!timestamp) timestamp = this.client.uptime || 0;
|
|
10
17
|
let totalSeconds = timestamp / 1000;
|
|
11
18
|
let years = Math.floor(totalSeconds / 31536000);
|
|
12
19
|
totalSeconds %= 31536000;
|
|
@@ -16,90 +23,77 @@ export class ClientUtil {
|
|
|
16
23
|
totalSeconds %= 3600;
|
|
17
24
|
let minutes = Math.floor(totalSeconds / 60);
|
|
18
25
|
let seconds = Math.floor(totalSeconds % 60);
|
|
19
|
-
if (years >= 1)
|
|
20
|
-
|
|
21
|
-
else if (
|
|
22
|
-
|
|
23
|
-
else
|
|
24
|
-
return `${hours}h ${minutes}m`;
|
|
25
|
-
else if (minutes >= 1)
|
|
26
|
-
return `${minutes}m ${seconds}s`;
|
|
27
|
-
else
|
|
28
|
-
return `${seconds}s`;
|
|
26
|
+
if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`;
|
|
27
|
+
else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;
|
|
28
|
+
else if (hours >= 1) return `${hours}h ${minutes}m`;
|
|
29
|
+
else if (minutes >= 1) return `${minutes}m ${seconds}s`;
|
|
30
|
+
else return `${seconds}s`;
|
|
29
31
|
}
|
|
30
32
|
getSubcommands(name) {
|
|
31
|
-
if (!name || typeof name !== 'string')
|
|
32
|
-
throw new XernerxError(`Expected name to be of type string, received ${typeof name} instead!`);
|
|
33
|
+
if (!name || typeof name !== 'string') throw new XernerxError_js_1.default(`Expected name to be of type string, received ${typeof name} instead!`);
|
|
33
34
|
const commands = [];
|
|
34
35
|
this.getAllCommands()
|
|
35
36
|
.filter((c) => (c.data?.name?.toLowerCase() || c.name?.toLowerCase()) == name?.toLowerCase())
|
|
36
37
|
.map((c) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
38
|
+
if (c?.data?.options?.length > 0) {
|
|
39
|
+
c?.data?.options?.map((option) => {
|
|
40
|
+
if (!option?.type) {
|
|
41
|
+
if (option?.options?.length > 0) {
|
|
42
|
+
option?.options?.map((opt) => {
|
|
43
|
+
if (!opt.type) {
|
|
44
|
+
commands.push({
|
|
45
|
+
name: c.data.name,
|
|
46
|
+
formattedName: `${c.data.name} ${option.name} ${opt.name}`,
|
|
47
|
+
description: opt.description,
|
|
48
|
+
category: c.category || null,
|
|
49
|
+
commandType: c.commandType,
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
commands.push({
|
|
53
|
+
name: c.data.name,
|
|
54
|
+
formattedName: `${c.data.name} ${option.name}`,
|
|
55
|
+
description: option.description,
|
|
56
|
+
category: c.category || null,
|
|
57
|
+
commandType: c.commandType,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
commands.push({
|
|
63
|
+
name: c.data.name,
|
|
64
|
+
formattedName: `${c.data.name} ${option.name}`,
|
|
65
|
+
description: option.description,
|
|
66
|
+
category: c.category || null,
|
|
67
|
+
commandType: c.commandType,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
63
71
|
commands.push({
|
|
64
72
|
name: c.data.name,
|
|
65
|
-
formattedName: `${c.data.name}
|
|
66
|
-
description:
|
|
73
|
+
formattedName: `${c.data.name}`,
|
|
74
|
+
description: c.data.description,
|
|
67
75
|
category: c.category || null,
|
|
68
76
|
commandType: c.commandType,
|
|
69
77
|
});
|
|
70
78
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
commands.push({
|
|
85
|
-
name: c.data?.name || c.name,
|
|
86
|
-
formattedName: `${c.data?.name || c.name}`,
|
|
87
|
-
description: c.data?.description || c.description,
|
|
88
|
-
category: c.category || null,
|
|
89
|
-
commandType: c.commandType,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
});
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
commands.push({
|
|
82
|
+
name: c.data?.name || c.name,
|
|
83
|
+
formattedName: `${c.data?.name || c.name}`,
|
|
84
|
+
description: c.data?.description || c.description,
|
|
85
|
+
category: c.category || null,
|
|
86
|
+
commandType: c.commandType,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
93
90
|
return commands;
|
|
94
91
|
}
|
|
95
92
|
isOwner(userId) {
|
|
96
|
-
if (!userId)
|
|
97
|
-
throw new XernerxError('No ID specified');
|
|
93
|
+
if (!userId) throw new XernerxError_js_1.default('No ID specified');
|
|
98
94
|
let owners = this.client.settings.ownerId;
|
|
99
|
-
if (!owners)
|
|
100
|
-
|
|
101
|
-
if (typeof owners === 'string')
|
|
102
|
-
owners = [owners];
|
|
95
|
+
if (!owners) return false;
|
|
96
|
+
if (typeof owners === 'string') owners = [owners];
|
|
103
97
|
return owners.includes(userId);
|
|
104
98
|
}
|
|
105
99
|
getAllCommands() {
|
|
@@ -148,8 +142,7 @@ export class ClientUtil {
|
|
|
148
142
|
getCooldowns(id, command) {
|
|
149
143
|
let cooldowns = [];
|
|
150
144
|
for (const [key, value] of Object.entries(this.client.cache)) {
|
|
151
|
-
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
|
|
152
|
-
continue;
|
|
145
|
+
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
|
|
153
146
|
if (key === 'commands') {
|
|
154
147
|
if (command) {
|
|
155
148
|
value.map((x) => {
|
|
@@ -159,16 +152,14 @@ export class ClientUtil {
|
|
|
159
152
|
cooldowns.push(x);
|
|
160
153
|
}
|
|
161
154
|
});
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
155
|
+
} else {
|
|
164
156
|
value.map((x) => {
|
|
165
157
|
if (x.name.split(/-/).shift() === id) {
|
|
166
158
|
cooldowns.push(x);
|
|
167
159
|
}
|
|
168
160
|
});
|
|
169
161
|
}
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
162
|
+
} else {
|
|
172
163
|
if (value.has(id)) {
|
|
173
164
|
const x = value.get(id);
|
|
174
165
|
cooldowns.push(x);
|
|
@@ -180,8 +171,7 @@ export class ClientUtil {
|
|
|
180
171
|
getCooldownTimers(id, command) {
|
|
181
172
|
let cooldowns = [];
|
|
182
173
|
for (const [key, value] of Object.entries(this.client.cache)) {
|
|
183
|
-
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
|
|
184
|
-
continue;
|
|
174
|
+
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
|
|
185
175
|
if (key === 'commands') {
|
|
186
176
|
if (command) {
|
|
187
177
|
value.map((x) => {
|
|
@@ -193,8 +183,7 @@ export class ClientUtil {
|
|
|
193
183
|
});
|
|
194
184
|
}
|
|
195
185
|
});
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
186
|
+
} else {
|
|
198
187
|
value.map((x) => {
|
|
199
188
|
if (x.name.split(/-/).shift() === id) {
|
|
200
189
|
cooldowns.push({
|
|
@@ -203,8 +192,7 @@ export class ClientUtil {
|
|
|
203
192
|
}
|
|
204
193
|
});
|
|
205
194
|
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
195
|
+
} else {
|
|
208
196
|
if (value.has(id)) {
|
|
209
197
|
const x = value.get(id);
|
|
210
198
|
cooldowns.push({ [key]: x.endsAt - Date.now() });
|
|
@@ -220,3 +208,4 @@ export class ClientUtil {
|
|
|
220
208
|
return new Promise((resolve) => setTimeout(resolve, time || 0));
|
|
221
209
|
}
|
|
222
210
|
}
|
|
211
|
+
exports.ClientUtil = ClientUtil;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
+
exports.InteractionCommandUtil = exports.MessageCommandUtil = void 0;
|
|
9
|
+
const discord_js_1 = require('discord.js');
|
|
10
|
+
const XernerxError_js_1 = __importDefault(require('../tools/XernerxError.js'));
|
|
11
|
+
class MessageCommandUtil {
|
|
4
12
|
client;
|
|
5
13
|
message;
|
|
6
14
|
constructor(client, message) {
|
|
@@ -8,8 +16,7 @@ export class MessageCommandUtil {
|
|
|
8
16
|
this.message = message;
|
|
9
17
|
}
|
|
10
18
|
async reply(content) {
|
|
11
|
-
if (this.client.cache.messages.has(this.message.id))
|
|
12
|
-
var existingMessage = this.client.cache.messages.get(this.message.id);
|
|
19
|
+
if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
|
|
13
20
|
if (!existingMessage) {
|
|
14
21
|
const msg = await this.message.reply(content);
|
|
15
22
|
this.message.response = msg.id;
|
|
@@ -26,8 +33,7 @@ export class MessageCommandUtil {
|
|
|
26
33
|
const msg = await this.message.channel.messages.fetch(existingMessage.response);
|
|
27
34
|
msg.edit(content);
|
|
28
35
|
return msg;
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
36
|
+
} catch {
|
|
31
37
|
const msg = await this.message.reply(content);
|
|
32
38
|
this.message.response = msg.id;
|
|
33
39
|
if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
|
|
@@ -40,8 +46,7 @@ export class MessageCommandUtil {
|
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
async send(content) {
|
|
43
|
-
if (this.client.cache.messages.has(this.message.id))
|
|
44
|
-
var existingMessage = this.client.cache.messages.get(this.message.id);
|
|
49
|
+
if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
|
|
45
50
|
if (!existingMessage) {
|
|
46
51
|
const msg = await this.message.channel.send(content);
|
|
47
52
|
this.message.response = msg.id;
|
|
@@ -58,8 +63,7 @@ export class MessageCommandUtil {
|
|
|
58
63
|
const msg = await this.message.channel.messages.fetch(existingMessage.response);
|
|
59
64
|
msg.edit(content);
|
|
60
65
|
return msg;
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
66
|
+
} catch {
|
|
63
67
|
const msg = await this.message.channel.send(content);
|
|
64
68
|
this.message.response = msg.id;
|
|
65
69
|
if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
|
|
@@ -77,16 +81,17 @@ export class MessageCommandUtil {
|
|
|
77
81
|
getCommands() {
|
|
78
82
|
return this.client.commands.message;
|
|
79
83
|
}
|
|
80
|
-
getCommandName() {
|
|
81
|
-
selectMenuPaginator(embeds, options) {
|
|
82
|
-
buttonPaginator(embeds, options) {
|
|
83
|
-
buttonMenuPaginator(embeds, options) {
|
|
84
|
+
getCommandName() {}
|
|
85
|
+
selectMenuPaginator(embeds, options) {}
|
|
86
|
+
buttonPaginator(embeds, options) {}
|
|
87
|
+
buttonMenuPaginator(embeds, options) {}
|
|
84
88
|
isOwner() {
|
|
85
89
|
return this.client.util.isOwner(this.message.author.id);
|
|
86
90
|
}
|
|
87
|
-
createModal() {
|
|
91
|
+
createModal() {}
|
|
88
92
|
}
|
|
89
|
-
|
|
93
|
+
exports.MessageCommandUtil = MessageCommandUtil;
|
|
94
|
+
class InteractionCommandUtil {
|
|
90
95
|
client;
|
|
91
96
|
interaction;
|
|
92
97
|
constructor(client, interaction) {
|
|
@@ -100,23 +105,17 @@ export class InteractionCommandUtil {
|
|
|
100
105
|
return new Promise((resolve) => setTimeout(resolve, time));
|
|
101
106
|
}
|
|
102
107
|
getCommands() {
|
|
103
|
-
if (this.interaction.commandType === 1)
|
|
104
|
-
|
|
105
|
-
else
|
|
106
|
-
return this.client.commands.context;
|
|
108
|
+
if (this.interaction.commandType === 1) return this.client.commands.slash;
|
|
109
|
+
else return this.client.commands.context;
|
|
107
110
|
}
|
|
108
|
-
getCommandName() {
|
|
111
|
+
getCommandName() {}
|
|
109
112
|
selectMenuPaginator(embeds, options) {
|
|
110
|
-
if (!Array.isArray(embeds))
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
if (typeof options !== 'object')
|
|
115
|
-
options = {};
|
|
116
|
-
if (!Array.isArray(options.components))
|
|
117
|
-
options.components = [];
|
|
113
|
+
if (!Array.isArray(embeds)) throw new XernerxError_js_1.default(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
|
|
114
|
+
if (embeds.length > 25) throw new XernerxError_js_1.default(`Max select menu length is 25.`);
|
|
115
|
+
if (typeof options !== 'object') options = {};
|
|
116
|
+
if (!Array.isArray(options.components)) options.components = [];
|
|
118
117
|
if (!options.index) {
|
|
119
|
-
options.index = new EmbedBuilder().setTitle('Index').setColor('Random');
|
|
118
|
+
options.index = new discord_js_1.EmbedBuilder().setTitle('Index').setColor('Random');
|
|
120
119
|
for (const embed of embeds) {
|
|
121
120
|
options.index.addFields([
|
|
122
121
|
{
|
|
@@ -128,10 +127,14 @@ export class InteractionCommandUtil {
|
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
if (!options.row) {
|
|
131
|
-
options.row = new ActionRowBuilder();
|
|
132
|
-
if (!options.id)
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
options.row = new discord_js_1.ActionRowBuilder();
|
|
131
|
+
if (!options.id) options.id = `${this.interaction.id}-menu`;
|
|
132
|
+
options.component = new discord_js_1.StringSelectMenuBuilder()
|
|
133
|
+
.setCustomId(options.id)
|
|
134
|
+
.setMaxValues(1)
|
|
135
|
+
.setMinValues(1)
|
|
136
|
+
.setPlaceholder('Select a page.')
|
|
137
|
+
.addOptions({ label: 'index', value: '0' });
|
|
135
138
|
embeds.map((embed, i = 0) => {
|
|
136
139
|
options?.component?.addOptions({
|
|
137
140
|
label: embed.data.title || 'No Name',
|
|
@@ -150,42 +153,37 @@ export class InteractionCommandUtil {
|
|
|
150
153
|
(options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then(() => {
|
|
151
154
|
const collector = this.interaction.channel
|
|
152
155
|
.createMessageComponentCollector({
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
filter: options?.filter,
|
|
157
|
+
time: options?.time || 60000,
|
|
158
|
+
})
|
|
156
159
|
.on('collect', (interaction) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
})
|
|
162
|
-
})
|
|
160
|
+
if (!interaction.customId.startsWith(this.interaction.id)) return;
|
|
161
|
+
interaction.update({
|
|
162
|
+
embeds: [embeds[parseInt(interaction.values[0])]],
|
|
163
|
+
});
|
|
164
|
+
})
|
|
163
165
|
.on('end', () => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
this.interaction.editReply({ components: [] });
|
|
167
|
+
});
|
|
166
168
|
});
|
|
167
169
|
}
|
|
168
170
|
buttonPaginator(embeds, options) {
|
|
169
|
-
if (!Array.isArray(embeds))
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
if (typeof options !== 'object')
|
|
174
|
-
options = {};
|
|
175
|
-
if (!Array.isArray(options.components))
|
|
176
|
-
options.components = [];
|
|
171
|
+
if (!Array.isArray(embeds)) throw new XernerxError_js_1.default(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
|
|
172
|
+
if (embeds.length <= 0) throw new XernerxError_js_1.default(`The minimum embeds is 1.`);
|
|
173
|
+
if (typeof options !== 'object') options = {};
|
|
174
|
+
if (!Array.isArray(options.components)) options.components = [];
|
|
177
175
|
if (!options.row) {
|
|
178
|
-
options.row = new ActionRowBuilder();
|
|
179
|
-
if (!options.id)
|
|
180
|
-
options.id = `${this.interaction.id}-menu`;
|
|
176
|
+
options.row = new discord_js_1.ActionRowBuilder();
|
|
177
|
+
if (!options.id) options.id = `${this.interaction.id}-menu`;
|
|
181
178
|
}
|
|
182
|
-
if (!options.buttons)
|
|
183
|
-
options.buttons = ['⏮️', '◀️', '⏹️', '▶️', '⏭️'];
|
|
179
|
+
if (!options.buttons) options.buttons = ['⏮️', '◀️', '⏹️', '▶️', '⏭️'];
|
|
184
180
|
for (const button of options.buttons) {
|
|
185
|
-
options.row.addComponents(
|
|
186
|
-
.
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
options.row.addComponents(
|
|
182
|
+
new discord_js_1.ButtonBuilder()
|
|
183
|
+
.setCustomId(`${this.interaction.id}-${options.buttons.indexOf(button)}`)
|
|
184
|
+
.setEmoji(button)
|
|
185
|
+
.setStyle(discord_js_1.ButtonStyle.Primary)
|
|
186
|
+
);
|
|
189
187
|
}
|
|
190
188
|
let embed = embeds[options.index || 0];
|
|
191
189
|
const content = {
|
|
@@ -196,53 +194,54 @@ export class InteractionCommandUtil {
|
|
|
196
194
|
(options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then((message) => {
|
|
197
195
|
const collector = message.channel
|
|
198
196
|
.createMessageComponentCollector({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
filter: options.filter,
|
|
198
|
+
time: options?.time || 60000,
|
|
199
|
+
})
|
|
202
200
|
.on('collect', (interaction) => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
201
|
+
let stop = false;
|
|
202
|
+
if (interaction.customId.startsWith(this.interaction.id)) {
|
|
203
|
+
switch (Number(interaction.customId.split(/-/).pop())) {
|
|
204
|
+
case 0: {
|
|
205
|
+
embed = embeds[0];
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
case 1: {
|
|
209
|
+
embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case 2: {
|
|
213
|
+
collector.stop();
|
|
214
|
+
stop = true;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case 3: {
|
|
218
|
+
embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case 4: {
|
|
222
|
+
embed = embeds[embeds.length - 1];
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
226
225
|
}
|
|
226
|
+
stop
|
|
227
|
+
? interaction.update({
|
|
228
|
+
embeds: [embed],
|
|
229
|
+
components: [],
|
|
230
|
+
})
|
|
231
|
+
: interaction.update({
|
|
232
|
+
embeds: [embed],
|
|
233
|
+
});
|
|
227
234
|
}
|
|
228
|
-
|
|
229
|
-
? interaction.update({
|
|
230
|
-
embeds: [embed],
|
|
231
|
-
components: [],
|
|
232
|
-
})
|
|
233
|
-
: interaction.update({
|
|
234
|
-
embeds: [embed],
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
})
|
|
235
|
+
})
|
|
238
236
|
.on('end', () => {
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
this.interaction.editReply({ components: [] });
|
|
238
|
+
});
|
|
241
239
|
});
|
|
242
240
|
}
|
|
243
|
-
buttonMenuPaginator(embeds, options) {
|
|
241
|
+
buttonMenuPaginator(embeds, options) {}
|
|
244
242
|
isOwner() {
|
|
245
243
|
return this.client.util.isOwner(this.interaction.user.id);
|
|
246
244
|
}
|
|
247
|
-
createModal() {
|
|
245
|
+
createModal() {}
|
|
248
246
|
}
|
|
247
|
+
exports.InteractionCommandUtil = InteractionCommandUtil;
|