xernerx 2.7.5 → 3.0.0

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.
Files changed (76) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +0 -0
  3. package/dist/build/ContextCommand.d.ts +39 -0
  4. package/dist/build/ContextCommand.js +86 -0
  5. package/dist/build/Event.d.ts +15 -0
  6. package/dist/build/Event.js +31 -0
  7. package/dist/build/Inhibitor.d.ts +12 -0
  8. package/dist/build/Inhibitor.js +20 -0
  9. package/dist/build/MessageCommand.d.ts +39 -0
  10. package/dist/build/MessageCommand.js +77 -0
  11. package/dist/build/SlashCommand.d.ts +32 -0
  12. package/dist/build/SlashCommand.js +119 -0
  13. package/dist/client/XernerxClient.d.ts +22 -0
  14. package/dist/client/XernerxClient.js +76 -0
  15. package/dist/handlers/CommandHandler.d.ts +27 -0
  16. package/dist/handlers/CommandHandler.js +42 -0
  17. package/dist/handlers/EventHandler.d.ts +13 -0
  18. package/dist/handlers/EventHandler.js +16 -0
  19. package/dist/handlers/Handler.d.ts +37 -0
  20. package/dist/handlers/Handler.js +242 -0
  21. package/dist/handlers/InhibitorHandler.d.ts +18 -0
  22. package/dist/handlers/InhibitorHandler.js +21 -0
  23. package/dist/interfaces/ClientInterfaces.d.ts +58 -0
  24. package/dist/interfaces/ClientInterfaces.js +1 -0
  25. package/dist/interfaces/CommandInterfaces.d.ts +94 -0
  26. package/dist/interfaces/CommandInterfaces.js +1 -0
  27. package/dist/interfaces/HandlerInterfaces.d.ts +70 -0
  28. package/dist/interfaces/HandlerInterfaces.js +1 -0
  29. package/dist/main.d.ts +26 -0
  30. package/dist/main.js +40 -0
  31. package/dist/models/CommandArguments.d.ts +9 -0
  32. package/dist/models/CommandArguments.js +128 -0
  33. package/dist/models/CommandValidations.d.ts +3 -0
  34. package/dist/models/CommandValidations.js +193 -0
  35. package/dist/models/Events.d.ts +23 -0
  36. package/dist/models/Events.js +328 -0
  37. package/dist/models/Functions.d.ts +1 -0
  38. package/dist/models/Functions.js +30 -0
  39. package/dist/models/InhibitorValidations.d.ts +17 -0
  40. package/dist/models/InhibitorValidations.js +42 -0
  41. package/dist/types/EventTypes.d.ts +1 -0
  42. package/dist/types/EventTypes.js +1 -0
  43. package/dist/types/InhibitorTypes.d.ts +12 -0
  44. package/dist/types/InhibitorTypes.js +13 -0
  45. package/dist/types/Types.d.ts +24 -0
  46. package/dist/types/Types.js +21 -0
  47. package/dist/utils/ClientUtil.d.ts +25 -0
  48. package/dist/utils/ClientUtil.js +232 -0
  49. package/dist/utils/CommandUtil.d.ts +24 -0
  50. package/dist/utils/CommandUtil.js +163 -0
  51. package/package.json +5 -8
  52. package/main.js +0 -49
  53. package/models/Client.js +0 -60
  54. package/models/commands/ContextMenuCommand.js +0 -68
  55. package/models/commands/Event.js +0 -33
  56. package/models/commands/Inhibitor.js +0 -31
  57. package/models/commands/InteractionCommand.js +0 -142
  58. package/models/commands/MessageCommand.js +0 -86
  59. package/models/data/colors.json +0 -16
  60. package/models/data/options.json +0 -27
  61. package/models/events/interactionCreate.js +0 -84
  62. package/models/events/messageCreate.js +0 -84
  63. package/models/events/messageUpdate.js +0 -83
  64. package/models/events/readyOnce.js +0 -58
  65. package/models/handlers/CommandHandler.js +0 -37
  66. package/models/handlers/EventHandler.js +0 -67
  67. package/models/handlers/Handler.js +0 -111
  68. package/models/handlers/InhibitorHandler.js +0 -16
  69. package/models/handlers/LanguageHandler.js +0 -37
  70. package/models/utils/Arguments.js +0 -120
  71. package/models/utils/CommandValidation.js +0 -96
  72. package/models/utils/CommandsUtil.js +0 -70
  73. package/models/utils/Functions.js +0 -266
  74. package/models/utils/InhibitorsUtil.js +0 -24
  75. package/models/utils/InhibitorsValidation.js +0 -40
  76. package/models/utils/Util.js +0 -96
@@ -1,266 +0,0 @@
1
- const colors = require('../data/colors.json');
2
- const { EmbedBuilder, ActionRowBuilder, SelectMenuBuilder, Embed, ButtonBuilder, ButtonStyle } = require('discord.js');
3
- const opts = require('../data/options.json');
4
-
5
- function reply(interaction, text) {
6
- return (interaction.replied || interaction.deferred) ? interaction.editReply(text) : interaction.reply(text);
7
- }
8
-
9
- /**
10
- * @param {object} Functions - Build in functions of the bot hidden away in the handlers/setters.
11
- */
12
- module.exports = new class Functions {
13
- /**
14
- * @param {object} client - Client object.
15
- * @param {object} options - Client options.
16
- * @returns an object of default colors and custom colors to be imported anywhere without having to import them.
17
- */
18
- color({ client: client, options: options }) {
19
- client.color = { FLAGS: colors }
20
-
21
- if (options.color) {
22
- for (const [name, color] of Object.entries(options.color)) {
23
- client.color[name] = color;
24
- }
25
- }
26
-
27
- return client.color;
28
- }
29
-
30
- /**
31
- *
32
- * @param {object} client - Client object.
33
- * @param {object} options - Client options.
34
- * @returns custom config settings for the bot.
35
- */
36
- config({ client: client, options: options }) {
37
- client.config = {}
38
-
39
- if (options.config) {
40
- for (const [key, value] of Object.entries(options.config)) {
41
- client.config[key] = value;
42
- }
43
- }
44
-
45
- return client.config;
46
- }
47
-
48
- reply(interaction, text) {
49
- return (interaction.replied || interaction.deferred) ? interaction.editReply(text) : interaction.reply(text);
50
- }
51
-
52
- selectMenuPaginator(interaction, embeds, options = {}) {
53
- if (!embeds) return interaction.client.emit('error', interaction, "no embeds");
54
-
55
- if (!Array.isArray(embeds)) return interaction.client.emit('error', interaction, "no array of embeds")
56
-
57
- if (!options.index) {
58
- options.index = new EmbedBuilder()
59
- .setTitle(`${embeds.length} pages`)
60
-
61
- embeds.map((embed, i = 0) => options.index.addFields([{ name: embed?.data?.title || embed?.data?.author?.name || "No name", value: embed?.data?.description || `Page ${i + 1}` }]))
62
- }
63
-
64
- if (!options.row) {
65
- options.row = new ActionRowBuilder();
66
-
67
- if (!options.id) options.id = `${interaction.id}-menu`;
68
-
69
- options.comp = new SelectMenuBuilder()
70
- .setCustomId(options.id)
71
- .setMaxValues(1)
72
- .setMinValues(1)
73
- .setPlaceholder('Select a page.')
74
- .addOptions({ label: 'Index', description: 'Index Page', value: 'index' })
75
-
76
- embeds.map((embed, i = 0) => options.comp.addOptions({ label: embed?.data?.title || embed?.data?.author?.name, description: embed?.data?.description?.slice(0, 100) || `Page ${i + 1}`, value: opts[embeds.indexOf(embed)] }))
77
-
78
- options.row.addComponents(options.comp);
79
- }
80
-
81
- if (!options.id) options.id = options.row.components[0].data.custom_id;
82
-
83
- (async () => {
84
- let embed = options.index;
85
-
86
- if (!options.components) options.components = [];
87
-
88
- let m = options.send ? await interaction.channel.send({ embeds: [embed], components: [options.row, ...options.components] }) : await reply(interaction, { embeds: [embed], components: [options.row, ...options.components] })
89
-
90
- interaction.channel.createMessageComponentCollector({ filter: options.filter, time: options.time || 300000 })
91
-
92
- .on('collect', async (a) => {
93
- if (a.customId != options.id) return;
94
-
95
- let chosen = a.values[0];
96
-
97
- if (chosen === options.row.components[0]?.options[0]?.data?.value) embed = options.index;
98
-
99
- else embed = embeds[opts.indexOf(chosen)];
100
-
101
- a.update({ embeds: [embed] });
102
- })
103
-
104
- .on('end', async () => {
105
- if (interaction.editReply) interaction.editReply({ components: [] });
106
-
107
- if (interaction.edit) await m.edit({ components: [] });
108
- })
109
- })();
110
- }
111
-
112
- commandName(interaction, cmd) {
113
- if (cmd) {
114
- let cmds = [];
115
-
116
- for (const commands of Object.values(interaction.client.commands)) {
117
- let commandInfo = {};
118
-
119
- const command = commands.find(command => command?.data?.name === cmd.toLowerCase() || command?.name === cmd.toLowerCase() || command?.id == cmd.toLowerCase());
120
-
121
- if (command) {
122
- if (command?.data?.options?.length > 0) {
123
- command?.data?.options?.map(option => {
124
- if (!option?.type) {
125
- if (option?.options?.length > 0) {
126
- option?.options?.map(opt => {
127
- if (!opt.type) {
128
- commandInfo = {
129
- name: command?.data?.name + " " + option?.name + " " + opt?.name,
130
- description: opt.description,
131
- category: command.category
132
- }
133
-
134
- if (!cmds.find(c => c.name === commandInfo.name)) cmds.push(commandInfo);
135
- }
136
-
137
- else {
138
- commandInfo = {
139
- name: command?.data?.name + " " + option?.name,
140
- description: option?.description,
141
- category: command.category
142
- }
143
-
144
- if (!cmds.find(c => c.name === commandInfo.name)) cmds.push(commandInfo);
145
- }
146
- })
147
- }
148
-
149
- else {
150
- commandInfo = {
151
- name: command?.data?.name + " " + option?.name,
152
- description: option?.description,
153
- category: command.category
154
- }
155
-
156
- if (!cmds.find(c => c.name === commandInfo.name)) cmds.push(commandInfo);
157
- }
158
- }
159
-
160
- else {
161
- commandInfo = {
162
- name: command?.data?.name || command?.name || command?.id,
163
- description: command?.data?.description || command?.description,
164
- category: command.category
165
- }
166
-
167
- if (!cmds.find(c => c.name === commandInfo.name)) cmds.push(commandInfo);
168
- }
169
- })
170
- }
171
-
172
- else {
173
- commandInfo = {
174
- name: command?.data?.name || command?.name || command?.id,
175
- description: command?.data?.description || command?.description,
176
- category: command.category
177
- }
178
-
179
- if (!cmds.find(c => c.name === commandInfo.name)) cmds.push(commandInfo);
180
- }
181
- }
182
- }
183
- return cmds;
184
- }
185
-
186
- if (!cmd) return [interaction?.commandName || interaction.name || interaction.content?.replace(interaction.client.settings.prefix.find(p => interaction.content.startsWith(p)), "").split(/ +/)[0], interaction?.options?._group, interaction?.options?._subcommand].join(' ').replace(/ +/g, " ").trim();
187
- }
188
-
189
- buttonPaginator(interaction, embeds, options = {}) {
190
- if (!options.buttons) options.buttons = ["⏪", "◀️", "⏹️", "▶️", "⏩"];
191
-
192
- if (options.buttons.length <= 4 || options.buttons.length > 5) throw new Error('Must specify 5 emotes.');
193
-
194
- options.row = new ActionRowBuilder();
195
-
196
- for (const button of options.buttons) {
197
- options.row
198
- .addComponents(
199
- new ButtonBuilder()
200
- .setCustomId(`${interaction.id}-${opts[options.buttons.indexOf(button)]}`)
201
- .setStyle(ButtonStyle[options.style || 'Primary'])
202
- .setEmoji(button)
203
- )
204
- };
205
-
206
- (async () => {
207
- let embed = embeds[options.index || 0];
208
-
209
- let m = options.send ? await interaction.channel.send({ embeds: [embed], components: [options.row, ...options.components] }) : await reply(interaction, { embeds: [embed], components: [options.row, ...options.components] });
210
-
211
- const collector = interaction.channel.createMessageComponentCollector({ filter: options.filter, time: options.time || 300000 })
212
-
213
- .on('collect', async (a) => {
214
- if (a.customId == `${interaction.id}-one`) {
215
- embed = embeds[0];
216
- a.update({ embeds: [embed] });
217
- }
218
-
219
- if (a.customId == `${interaction.id}-two`) {
220
- embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
221
- a.update({ embeds: [embed] });
222
- }
223
-
224
- if (a.customId == `${interaction.id}-three`) {
225
- a.update({ components: [] });
226
- collector.stop();
227
- }
228
-
229
- if (a.customId == `${interaction.id}-four`) {
230
- embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
231
- a.update({ embeds: [embed] });
232
- }
233
-
234
- if (a.customId == `${interaction.id}-five`) {
235
- embed = embeds[embeds.length - 1];
236
- a.update({ embeds: [embed] });
237
- }
238
- })
239
-
240
- .on('end', async () => {
241
- if (interaction.editReply) interaction.editReply({ components: [] });
242
-
243
- if (interaction.edit) await m.edit({ components: [] });
244
- })
245
- })();
246
- }
247
-
248
- uptime(interaction, timestamp) {
249
- if (!timestamp) timestamp = interaction.client.uptime;
250
- let totalSeconds = timestamp / 1000;
251
- let years = Math.floor(totalSeconds / 31536000);
252
- totalSeconds %= 31536000;
253
- let days = Math.floor(totalSeconds / 86400);
254
- totalSeconds %= 86400;
255
- let hours = Math.floor(totalSeconds / 3600);
256
- totalSeconds %= 3600;
257
- let minutes = Math.floor(totalSeconds / 60);
258
- let seconds = Math.floor(totalSeconds % 60);
259
-
260
- if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`
261
- else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;
262
- else if (hours >= 1) return `${hours}h ${minutes}m`;
263
- else if (minutes >= 1) return `${minutes}m ${seconds}s`;
264
- else return `${seconds}s`;
265
- }
266
- }
@@ -1,24 +0,0 @@
1
- const { logStyle } = require('dumfunctions');
2
-
3
- module.exports = new class InhibitorsUtil {
4
- importInhibitors(client, path, files) {
5
- for (const file of files) {
6
- try {
7
- let filepath = `${require("path").resolve(path)}/${file}`;
8
-
9
- let inhibitor = require(filepath);
10
-
11
- inhibitor = new inhibitor;
12
-
13
- inhibitor.filepath = filepath;
14
-
15
- inhibitor.client = client;
16
-
17
- client.inhibitors.set(inhibitor.name, inhibitor);
18
- }
19
- catch (error) {
20
- console.error(logStyle(`Couldn't load ${file} because of <${error.message}>!`, "text", "red"));
21
- }
22
- }
23
- }
24
- }
@@ -1,40 +0,0 @@
1
- module.exports = new class InhibitorValidation {
2
- async inhibitorsValidation(event, command) {
3
- let inhibited = {};
4
-
5
- if (event.client.inhibitors.has(command.runType)) {
6
- let inhibitor = event.client.inhibitors.get(command.runType);
7
-
8
- inhibited[command.runType] = await inhibitor.check(event);
9
- }
10
-
11
- if (event.client.inhibitors.has("member")) {
12
-
13
- let inhibitor = event.client.inhibitors.get("member");
14
-
15
- inhibited["member"] = await inhibitor.check(event, event.member);
16
- }
17
-
18
- if (event.client.inhibitors.has("guild")) {
19
- let inhibitor = event.client.inhibitors.get("guild");
20
-
21
- inhibited["guild"] = await inhibitor.check(event, event.guild);
22
- }
23
-
24
- if (event.client.inhibitors.has("user")) {
25
- let inhibitor = event.client.inhibitors.get("user");
26
-
27
- inhibited["user"] = await inhibitor.check(event, event.user || event.author);
28
- }
29
-
30
- if (event.client.inhibitors.has("channel")) {
31
- let inhibitor = event.client.inhibitors.get("channel");
32
-
33
- inhibited["channel"] = await inhibitor.check(event);
34
- }
35
-
36
- for (const inhibit of Object.values(inhibited)) {
37
- if (inhibit) return inhibited;
38
- }
39
- }
40
- }
@@ -1,96 +0,0 @@
1
- const { selectMenuPaginator, buttonPaginator, commandName, uptime, reply } = require('./Functions.js');
2
-
3
- module.exports = new class Util {
4
- async messageUtil(message, type) {
5
- setTimeout(() => {
6
- if (message.client.data.messages[message.id] === null || message.client.data.messages[message.id]) delete message.client.data.messages[message.id];
7
-
8
- if (message.channel.messages.cache.has(message.id)) message.channel.messages.cache.delete(message.id);
9
- }, message.client.settings.cacheTime);
10
-
11
- message.util = {
12
- selectMenuPaginator: (embeds, options) => selectMenuPaginator(message, embeds, options),
13
- buttonPaginator: (embeds, options) => buttonPaginator(message, embeds, options),
14
- commandName: (command) => commandName(message, command),
15
- uptime: (timestamp) => uptime(message, timestamp)
16
- }
17
-
18
- if (type == "create") {
19
- message.client.data.messages[message.id] = null;
20
-
21
- message.util.send = async (e) => {
22
- const msg = await message.channel.send(e);
23
-
24
- message.client.data.messages[message.id] = msg.id;
25
-
26
- return msg;
27
- }
28
-
29
- message.util.reply = async (e) => {
30
- const msg = await message.reply(e);
31
-
32
- message.client.data.messages[message.id] = msg.id;
33
-
34
- return msg;
35
- }
36
-
37
- return;
38
- }
39
-
40
- if (type == 'edit') {
41
- if (message.client.data.messages[message.id] === null) {
42
- message.util.send = async (e) => {
43
- const msg = await message.channel.send(e);
44
-
45
- message.client.data.messages[message.id] = msg.id;
46
-
47
- return msg;
48
- }
49
-
50
- message.util.reply = async (e) => {
51
- const msg = await message.reply(e);
52
-
53
- message.client.data.messages[message.id] = msg.id;
54
-
55
- return msg;
56
- }
57
-
58
- return;
59
- }
60
-
61
- else if (message.client.data.messages[message.id] !== null) {
62
- const msg = await message.channel.messages.fetch(message.client.data.messages[message.id]);
63
-
64
- message.util.send = async (e) => {
65
- try {
66
- return await msg.edit(e);
67
- }
68
- catch {
69
- message.channel.send(e);
70
- }
71
- }
72
-
73
- message.util.reply = async (e) => {
74
- try {
75
- return await msg.edit(e);
76
- }
77
- catch {
78
- message.reply(e);
79
- }
80
- }
81
-
82
- return;
83
- }
84
- }
85
- }
86
-
87
- interactionUtil(interaction) {
88
- interaction.util = {
89
- reply: (text) => reply(interaction, text),
90
- selectMenuPaginator: (embeds, options) => selectMenuPaginator(interaction, embeds, options),
91
- buttonPaginator: (embeds, options) => buttonPaginator(interaction, embeds, options),
92
- commandName: (command) => commandName(interaction, command),
93
- uptime: (timestamp) => uptime(interaction, timestamp)
94
- }
95
- }
96
- }