xernerx 3.0.1 → 3.0.3
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/build/ContextCommand.d.ts +4 -2
- package/dist/build/ContextCommand.js +6 -2
- package/dist/build/Event.d.ts +3 -1
- package/dist/build/Event.js +4 -1
- package/dist/build/Inhibitor.d.ts +3 -0
- package/dist/build/Inhibitor.js +4 -0
- package/dist/build/MessageCommand.d.ts +4 -2
- package/dist/build/MessageCommand.js +6 -2
- package/dist/build/SlashCommand.d.ts +5 -1
- package/dist/build/SlashCommand.js +6 -0
- package/dist/tools/values.d.ts +1 -0
- package/dist/tools/values.js +1 -0
- package/dist/utils/CommandUtil.d.ts +13 -1
- package/dist/utils/CommandUtil.js +40 -10
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChannelType, ContextMenuCommandBuilder, Interaction } from "discord.js";
|
|
2
2
|
import { ContextCommandOptions } from "../interfaces/CommandInterfaces.js";
|
|
3
|
+
import { XernerxClient } from "../main.js";
|
|
3
4
|
/**
|
|
4
5
|
* @description The command builder for context commands.
|
|
5
6
|
* @param {String} id - The unique ID of the command.
|
|
@@ -25,15 +26,16 @@ export declare class ContextCommand {
|
|
|
25
26
|
ephemeral?: boolean;
|
|
26
27
|
fetchReply?: boolean;
|
|
27
28
|
};
|
|
29
|
+
client: XernerxClient | object;
|
|
28
30
|
constructor(id: string, options: ContextCommandOptions);
|
|
29
31
|
/**
|
|
30
32
|
* @param {Interaction} interaction - The Discord interaction event data.
|
|
31
33
|
* @description make any preconditions here.
|
|
32
34
|
*/
|
|
33
|
-
conditions(interaction: Interaction): void
|
|
35
|
+
conditions(interaction: Interaction): Promise<void>;
|
|
34
36
|
/**
|
|
35
37
|
* @param {Interaction} interaction - The Discord interaction event data.
|
|
36
38
|
* @description Make your custom command here.
|
|
37
39
|
*/
|
|
38
|
-
exec(interaction: Interaction): void
|
|
40
|
+
exec(interaction: Interaction): Promise<void>;
|
|
39
41
|
}
|
|
@@ -20,6 +20,7 @@ export class ContextCommand {
|
|
|
20
20
|
userPermissions;
|
|
21
21
|
clientPermissions;
|
|
22
22
|
defer;
|
|
23
|
+
client;
|
|
23
24
|
constructor(id, options) {
|
|
24
25
|
this.id = id;
|
|
25
26
|
this.data = new ContextMenuCommandBuilder();
|
|
@@ -65,17 +66,20 @@ export class ContextCommand {
|
|
|
65
66
|
this.userPermissions = options.userPermissions;
|
|
66
67
|
this.clientPermissions = options.clientPermissions;
|
|
67
68
|
this.defer = options.defer;
|
|
69
|
+
this.client = {};
|
|
70
|
+
this.conditions = this.conditions;
|
|
71
|
+
this.exec = this.exec;
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
74
|
* @param {Interaction} interaction - The Discord interaction event data.
|
|
71
75
|
* @description make any preconditions here.
|
|
72
76
|
*/
|
|
73
|
-
conditions(interaction) { }
|
|
77
|
+
async conditions(interaction) { }
|
|
74
78
|
/**
|
|
75
79
|
* @param {Interaction} interaction - The Discord interaction event data.
|
|
76
80
|
* @description Make your custom command here.
|
|
77
81
|
*/
|
|
78
|
-
exec(interaction) { }
|
|
82
|
+
async exec(interaction) { }
|
|
79
83
|
#types(type) {
|
|
80
84
|
if (String(type)?.toLowerCase() === "message")
|
|
81
85
|
type = 3;
|
package/dist/build/Event.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
|
+
import { XernerxClient } from "../main.js";
|
|
2
3
|
/**
|
|
3
4
|
* @description - The event builder for any events.
|
|
4
5
|
* @param {String} id - The unique ID of the event.
|
|
@@ -10,6 +11,7 @@ export declare class Event {
|
|
|
10
11
|
emitter?: string;
|
|
11
12
|
type?: string;
|
|
12
13
|
once?: boolean;
|
|
14
|
+
client: XernerxClient | object;
|
|
13
15
|
constructor(id: string, options: EventOptions);
|
|
14
|
-
run(): void
|
|
16
|
+
run(): Promise<void>;
|
|
15
17
|
}
|
package/dist/build/Event.js
CHANGED
|
@@ -10,6 +10,7 @@ export class Event {
|
|
|
10
10
|
emitter;
|
|
11
11
|
type;
|
|
12
12
|
once;
|
|
13
|
+
client;
|
|
13
14
|
constructor(id, options) {
|
|
14
15
|
this.id = id;
|
|
15
16
|
s.object({
|
|
@@ -22,8 +23,10 @@ export class Event {
|
|
|
22
23
|
this.emitter = options.emitter || "client";
|
|
23
24
|
this.type = options.type || "discord";
|
|
24
25
|
this.once = options.once || false;
|
|
26
|
+
this.client = {};
|
|
27
|
+
this.run = this.run;
|
|
25
28
|
}
|
|
26
|
-
run() {
|
|
29
|
+
async run() {
|
|
27
30
|
/**
|
|
28
31
|
* @description run your custom event here.
|
|
29
32
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InhibitorOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
|
+
import { XernerxClient } from "../main.js";
|
|
2
3
|
/**
|
|
3
4
|
* @description - The inhibitor builder for inhibitors.
|
|
4
5
|
* @param {String} id - The unique ID of the inhibitor.
|
|
@@ -8,5 +9,7 @@ export declare class Inhibitor {
|
|
|
8
9
|
id: string;
|
|
9
10
|
name: string;
|
|
10
11
|
type: string;
|
|
12
|
+
client: XernerxClient | object;
|
|
11
13
|
constructor(id: string, options: InhibitorOptions);
|
|
14
|
+
check(): Promise<void>;
|
|
12
15
|
}
|
package/dist/build/Inhibitor.js
CHANGED
|
@@ -8,6 +8,7 @@ export class Inhibitor {
|
|
|
8
8
|
id;
|
|
9
9
|
name;
|
|
10
10
|
type;
|
|
11
|
+
client;
|
|
11
12
|
constructor(id, options) {
|
|
12
13
|
this.id = id;
|
|
13
14
|
s.object({
|
|
@@ -16,5 +17,8 @@ export class Inhibitor {
|
|
|
16
17
|
}).parse(options);
|
|
17
18
|
this.name = options.name;
|
|
18
19
|
this.type = options.type;
|
|
20
|
+
this.client = {};
|
|
21
|
+
this.check = this.check;
|
|
19
22
|
}
|
|
23
|
+
async check() { }
|
|
20
24
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MessageCommandOptions } from "../interfaces/CommandInterfaces.js";
|
|
2
2
|
import { Message, ChannelType } from "discord.js";
|
|
3
|
+
import { XernerxClient } from "../main.js";
|
|
3
4
|
/**
|
|
4
5
|
* @description - The command builder for message commands.
|
|
5
6
|
* @param {String} id - The unique ID of the command.
|
|
@@ -23,17 +24,18 @@ export declare class MessageCommand {
|
|
|
23
24
|
userPermissions?: bigint[];
|
|
24
25
|
clientPermissions?: bigint[];
|
|
25
26
|
args: object;
|
|
27
|
+
client: XernerxClient | object;
|
|
26
28
|
constructor(id: string, options: MessageCommandOptions);
|
|
27
29
|
/**
|
|
28
30
|
* @param {Message} message - The Discord message event data.
|
|
29
31
|
* @param {object} args - The arguments you created.
|
|
30
32
|
* @description make any preconditions here.
|
|
31
33
|
*/
|
|
32
|
-
conditions(message: Message, args: object): void
|
|
34
|
+
conditions(message: Message, args: object): Promise<void>;
|
|
33
35
|
/**
|
|
34
36
|
* @param {Message} message - The Discord message event data.
|
|
35
37
|
* @param {object} args - The arguments you created.
|
|
36
38
|
* @description Make your custom command here.
|
|
37
39
|
*/
|
|
38
|
-
exec(message: Message, args: object): void
|
|
40
|
+
exec(message: Message, args: object): Promise<void>;
|
|
39
41
|
}
|
|
@@ -22,6 +22,7 @@ export class MessageCommand {
|
|
|
22
22
|
userPermissions;
|
|
23
23
|
clientPermissions;
|
|
24
24
|
args;
|
|
25
|
+
client;
|
|
25
26
|
constructor(id, options) {
|
|
26
27
|
this.id = id;
|
|
27
28
|
s.object({
|
|
@@ -61,17 +62,20 @@ export class MessageCommand {
|
|
|
61
62
|
this.userPermissions = options.userPermissions || [];
|
|
62
63
|
this.clientPermissions = options.clientPermissions || [];
|
|
63
64
|
this.args = options.args;
|
|
65
|
+
this.client = {};
|
|
66
|
+
this.conditions = this.conditions;
|
|
67
|
+
this.exec = this.exec;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
66
70
|
* @param {Message} message - The Discord message event data.
|
|
67
71
|
* @param {object} args - The arguments you created.
|
|
68
72
|
* @description make any preconditions here.
|
|
69
73
|
*/
|
|
70
|
-
conditions(message, args) { }
|
|
74
|
+
async conditions(message, args) { }
|
|
71
75
|
/**
|
|
72
76
|
* @param {Message} message - The Discord message event data.
|
|
73
77
|
* @param {object} args - The arguments you created.
|
|
74
78
|
* @description Make your custom command here.
|
|
75
79
|
*/
|
|
76
|
-
exec(message, args) { }
|
|
80
|
+
async exec(message, args) { }
|
|
77
81
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SlashCommandOptions } from "../interfaces/CommandInterfaces.js";
|
|
2
|
-
import { ChannelType, SlashCommandBuilder } from "discord.js";
|
|
2
|
+
import { ChannelType, Interaction, SlashCommandBuilder } from "discord.js";
|
|
3
|
+
import { XernerxClient } from "../main.js";
|
|
3
4
|
/**
|
|
4
5
|
* @description - The command builder for slash commands.
|
|
5
6
|
* @param {String} id - The unique ID of the command.
|
|
@@ -28,5 +29,8 @@ export declare class SlashCommand {
|
|
|
28
29
|
ephemeral?: boolean;
|
|
29
30
|
fetchReply?: boolean;
|
|
30
31
|
};
|
|
32
|
+
client: XernerxClient | object;
|
|
31
33
|
constructor(id: string, options: SlashCommandOptions);
|
|
34
|
+
conditions(interaction: Interaction): Promise<void>;
|
|
35
|
+
exec(interaction: Interaction): Promise<void>;
|
|
32
36
|
}
|
|
@@ -23,6 +23,7 @@ export class SlashCommand {
|
|
|
23
23
|
subcommands;
|
|
24
24
|
groups;
|
|
25
25
|
defer;
|
|
26
|
+
client;
|
|
26
27
|
constructor(id, options) {
|
|
27
28
|
this.id = id;
|
|
28
29
|
this.data = new SlashCommandBuilder()
|
|
@@ -67,7 +68,12 @@ export class SlashCommand {
|
|
|
67
68
|
this.userPermissions = options.userPermissions;
|
|
68
69
|
this.clientPermissions = options.clientPermissions;
|
|
69
70
|
this.defer = options.defer;
|
|
71
|
+
this.client = {};
|
|
72
|
+
this.conditions = this.conditions;
|
|
73
|
+
this.exec = this.exec;
|
|
70
74
|
}
|
|
75
|
+
async conditions(interaction) { }
|
|
76
|
+
async exec(interaction) { }
|
|
71
77
|
#addArgs(command, args) {
|
|
72
78
|
const types = [
|
|
73
79
|
"boolean",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { ActionRowBuilder, ButtonBuilder, EmbedBuilder, Interaction, Message, MessagePayload } from "discord.js";
|
|
1
|
+
import { ActionRowBuilder, ButtonBuilder, EmbedBuilder, Interaction, Message, MessagePayload, StringSelectMenuBuilder } from "discord.js";
|
|
2
2
|
import XernerxClient from "../client/XernerxClient.js";
|
|
3
3
|
import { XernerxMessage } from "../interfaces/HandlerInterfaces.js";
|
|
4
|
+
interface SelectMenuOptions {
|
|
5
|
+
index?: EmbedBuilder;
|
|
6
|
+
row?: ActionRowBuilder;
|
|
7
|
+
component?: StringSelectMenuBuilder;
|
|
8
|
+
components?: object[];
|
|
9
|
+
reply?: boolean;
|
|
10
|
+
id?: string;
|
|
11
|
+
filter?: Function;
|
|
12
|
+
time?: number;
|
|
13
|
+
ephemeral?: boolean;
|
|
14
|
+
}
|
|
4
15
|
interface ButtonOptions {
|
|
5
16
|
index?: number;
|
|
6
17
|
buttons?: Array<string>;
|
|
@@ -32,6 +43,7 @@ export declare class InteractionCommandUtil {
|
|
|
32
43
|
reply(content: MessagePayload | string): any;
|
|
33
44
|
defer(time: number): Promise<unknown>;
|
|
34
45
|
getCommands(): import("@discordjs/collection").Collection<string, object>;
|
|
46
|
+
selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
|
|
35
47
|
buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
|
|
36
48
|
isOwner(): boolean;
|
|
37
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder,
|
|
1
|
+
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder, } from "discord.js";
|
|
2
2
|
export class MessageCommandUtil {
|
|
3
3
|
client;
|
|
4
4
|
message;
|
|
@@ -111,7 +111,7 @@ export class InteractionCommandUtil {
|
|
|
111
111
|
return this.client.commands.context;
|
|
112
112
|
}
|
|
113
113
|
#getCommandName() { }
|
|
114
|
-
|
|
114
|
+
selectMenuPaginator(embeds, options) {
|
|
115
115
|
if (!Array.isArray(embeds))
|
|
116
116
|
throw new Error(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
|
|
117
117
|
if (embeds.length > 25)
|
|
@@ -136,23 +136,48 @@ export class InteractionCommandUtil {
|
|
|
136
136
|
options.row = new ActionRowBuilder();
|
|
137
137
|
if (!options.id)
|
|
138
138
|
options.id = `${this.interaction.id}-menu`;
|
|
139
|
-
options.component = new
|
|
139
|
+
options.component = new StringSelectMenuBuilder()
|
|
140
140
|
.setCustomId(options.id)
|
|
141
141
|
.setMaxValues(1)
|
|
142
142
|
.setMinValues(1)
|
|
143
143
|
.setPlaceholder("Select a page.")
|
|
144
|
-
.addOptions({ label: "index", value: "
|
|
145
|
-
embeds.map((embed, i = 0) => {
|
|
144
|
+
.addOptions({ label: "index", value: "0" });
|
|
145
|
+
embeds.map((embed, i = 0) => {
|
|
146
|
+
options?.component?.addOptions({
|
|
147
|
+
label: embed.data.title || "No Name",
|
|
148
|
+
description: embed.data.description || `Page ${i}`,
|
|
149
|
+
value: String(i + 1),
|
|
150
|
+
});
|
|
151
|
+
});
|
|
146
152
|
options.row.addComponents(options.component);
|
|
147
153
|
}
|
|
154
|
+
embeds.unshift(options.index);
|
|
148
155
|
const content = {
|
|
149
156
|
embeds: [options.index],
|
|
150
|
-
components: [options.
|
|
157
|
+
components: [options.row, ...options.components],
|
|
151
158
|
ephemeral: !!options.ephemeral,
|
|
152
159
|
};
|
|
153
|
-
options.reply === undefined || options.reply === true
|
|
160
|
+
(options.reply === undefined || options.reply === true
|
|
154
161
|
? this.interaction.util.reply(content)
|
|
155
|
-
: this.interaction.channel.send(content)
|
|
162
|
+
: this.interaction.channel.send(content)).then(() => {
|
|
163
|
+
const collector = this.interaction.channel
|
|
164
|
+
.createMessageComponentCollector({
|
|
165
|
+
filter: options?.filter,
|
|
166
|
+
time: options?.time || 60000,
|
|
167
|
+
})
|
|
168
|
+
.on("collect", (interaction) => {
|
|
169
|
+
if (!interaction.customId.startsWith(this.interaction.id))
|
|
170
|
+
return;
|
|
171
|
+
interaction.update({
|
|
172
|
+
embeds: [
|
|
173
|
+
embeds[parseInt(interaction.values[0])],
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
})
|
|
177
|
+
.on("end", () => {
|
|
178
|
+
this.interaction.editReply({ components: [] });
|
|
179
|
+
});
|
|
180
|
+
});
|
|
156
181
|
}
|
|
157
182
|
buttonPaginator(embeds, options) {
|
|
158
183
|
if (!Array.isArray(embeds))
|
|
@@ -221,8 +246,13 @@ export class InteractionCommandUtil {
|
|
|
221
246
|
}
|
|
222
247
|
}
|
|
223
248
|
stop
|
|
224
|
-
? interaction.update({
|
|
225
|
-
|
|
249
|
+
? interaction.update({
|
|
250
|
+
embeds: [embed],
|
|
251
|
+
components: [],
|
|
252
|
+
})
|
|
253
|
+
: interaction.update({
|
|
254
|
+
embeds: [embed],
|
|
255
|
+
});
|
|
226
256
|
}
|
|
227
257
|
})
|
|
228
258
|
.on("end", () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "xernerx",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3",
|
|
5
5
|
"description": "A bot framework for discord.js. [BETA]",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"scripts": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/TheDummi/xernerx#readme",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@sapphire/shapeshift": "^3.7.
|
|
22
|
-
"discord.js": "^14.
|
|
21
|
+
"@sapphire/shapeshift": "^3.7.1",
|
|
22
|
+
"discord.js": "^14.7.0"
|
|
23
23
|
},
|
|
24
24
|
"packageManager": "npm@8.5.5"
|
|
25
25
|
}
|