xernerx 2.0.7 → 2.1.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/README.md CHANGED
Binary file
package/main.js CHANGED
@@ -1,36 +1,36 @@
1
- const { Client } = require('./models/Client.js'),
2
- { CommandHandler } = require('./models/handlers/CommandHandler.js'),
3
- { EventHandler } = require('./models/handlers/EventHandler.js'),
4
- { MessageCommand } = require('./models/commands/MessageCommand.js'),
5
- { InteractionCommand } = require('./models/commands/InteractionCommand.js'),
6
- { Event } = require('./models/commands/Event.js'),
7
- { LanguageHandler } = require('./models/handlers/LanguageHandler.js'),
8
- { ContextMenuCommand } = require('./models/commands/ContextMenuCommand.js'),
9
- pkg = require('./package.json'),
10
- Dumfunctions = require('dumfunctions'),
11
- Discord = require('discord.js');
12
-
13
- module.exports = {
14
- // Client
15
- Client,
16
-
17
- // Handlers
18
- CommandHandler,
19
- EventHandler,
20
- LanguageHandler,
21
-
22
- // Commands
23
- MessageCommand,
24
- InteractionCommand,
25
- ContextMenuCommand,
26
-
27
- // Events
28
- Event,
29
-
30
- // Discord
31
- Discord,
32
- functions: Dumfunctions,
33
-
34
- // Details
35
- version: pkg.version,
1
+ const { Client } = require('./models/Client.js'),
2
+ { CommandHandler } = require('./models/handlers/CommandHandler.js'),
3
+ { EventHandler } = require('./models/handlers/EventHandler.js'),
4
+ { MessageCommand } = require('./models/commands/MessageCommand.js'),
5
+ { InteractionCommand } = require('./models/commands/InteractionCommand.js'),
6
+ { Event } = require('./models/commands/Event.js'),
7
+ { LanguageHandler } = require('./models/handlers/LanguageHandler.js'),
8
+ { ContextMenuCommand } = require('./models/commands/ContextMenuCommand.js'),
9
+ pkg = require('./package.json'),
10
+ Dumfunctions = require('dumfunctions'),
11
+ Discord = require('discord.js');
12
+
13
+ module.exports = {
14
+ // Client
15
+ Client,
16
+
17
+ // Handlers
18
+ CommandHandler,
19
+ EventHandler,
20
+ LanguageHandler,
21
+
22
+ // Commands
23
+ MessageCommand,
24
+ InteractionCommand,
25
+ ContextMenuCommand,
26
+
27
+ // Events
28
+ Event,
29
+
30
+ // Discord
31
+ Discord,
32
+ functions: Dumfunctions,
33
+
34
+ // Details
35
+ version: pkg.version,
36
36
  }
package/models/Client.js CHANGED
@@ -7,7 +7,7 @@ const { LanguageHandler } = require('./handlers/LanguageHandler.js');
7
7
 
8
8
  /**
9
9
  * @param {string} guildId - Test guild ID.
10
- * @param {boolean} global - Whether the bot shoumd be globally or locally loaded.
10
+ * @param {boolean} global - Whether the bot should be globally or locally loaded.
11
11
  * @param {string[]} prefix - An array of prefix'.
12
12
  * @param {string[]} ownerId - An array of bot owners.
13
13
  * @param {boolean} ignoreOwner - Whether the bot should ignore owner privileges.
@@ -30,7 +30,6 @@ class Client extends Discord.Client {
30
30
  defaultCooldown: s.number.optional,
31
31
  logging: s.boolean.optional,
32
32
  cacheTime: s.number.optional,
33
- dummi: s.boolean.optional,
34
33
  userPermissions: s.array(s.string).optional,
35
34
  clientPermissions: s.array(s.string).optional
36
35
  }).parse(options)
@@ -34,7 +34,7 @@ class MessageCommand {
34
34
 
35
35
  this.id = id;
36
36
 
37
- this.aliases = [...(options.aliases ? options.aliases : []), options.name];
37
+ this.aliases = [options.name, ...(options.aliases ? options.aliases : [])];
38
38
 
39
39
  this.type = options.type;
40
40
 
@@ -0,0 +1,108 @@
1
+ class Arguments {
2
+ /**
3
+ *
4
+ * @param {object} interaction - Interaction event.
5
+ * @returns argument options without having to do the whole builders way.
6
+ */
7
+ interactionArgs(interaction) {
8
+ let group, sub, options = {};
9
+
10
+ if (interaction?.options?._group) group = interaction.options._group;
11
+
12
+ if (interaction?.options?._subcommand) sub = interaction.options._subcommand;
13
+
14
+ if (interaction?.options?._hoistedOptions) {
15
+ for (const option of interaction.options._hoistedOptions) {
16
+ options[option.name] = option.channel || option.user || option.role || option.value;
17
+ }
18
+ }
19
+
20
+ return { group, sub, options };
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @param {object} message - Message Object.
26
+ * @param {object} command - Command Class.
27
+ * @returns argument options without having to make them yourself.
28
+ */
29
+ async messageArgs({ message: message, command: command }) {
30
+ let args = {}, separator = command.separator || ' ', i = 0;
31
+
32
+ if (!command.args) return;
33
+
34
+ for (const argument of command.args) {
35
+
36
+ let content = message.content.replace(new RegExp(`${separator}${separator}+`, "g"), separator).split(separator).slice(i + 1);
37
+
38
+ if (content.join(separator) != '') {
39
+
40
+ if (argument?.content?.includes(content[0])) {
41
+ args[argument.name] = content[0];
42
+ }
43
+
44
+ else if (argument.type == 'string') {
45
+ args[argument.name] = content[0];
46
+ }
47
+
48
+ else if (argument.type == 'number') {
49
+ args[argument.name] = parseInt(content[0]);
50
+ }
51
+
52
+ else if (argument.type == 'boolean') {
53
+ if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false') content[0] = undefined;
54
+ args[argument.name] = content[0];
55
+ }
56
+
57
+ else if (argument.type == 'user') {
58
+ let user;
59
+ try { user = await message.client.users.fetch(content[0].replace(/<@!?|>/g, "")) } catch (e) { user = e }
60
+ args[argument.name] = user;
61
+ }
62
+
63
+ else if (argument.type == 'role') {
64
+ let role;
65
+ try { role = await message.guild.roles.fetch(content[0].replace(/<@&?|>/g, "")) } catch (e) { role = e }
66
+ args[argument.name] = role;
67
+ }
68
+
69
+ else if (argument.type == 'member') {
70
+ let member;
71
+ try { member = await message.guild.members.fetch(content[0].replace(/<@!?|>/g, "")) } catch (e) { member = e }
72
+ args[argument.name] = member;
73
+ }
74
+
75
+ else if (argument.type == 'channel') {
76
+ let channel;
77
+ try { channel = await message.client.channels.fetch(content[0].replace(/<#|>/g, "")) } catch (e) { channel = e }
78
+ args[argument.name] = channel;
79
+ }
80
+
81
+ else if (argument.type == 'rest') {
82
+ args[argument.name] = content.join(separator);
83
+ break;
84
+ }
85
+
86
+ else if (argument.prompt) {
87
+ if (argument.prompt.reply) return message.reply(argument.prompt.reply);
88
+ else if (argument.prompt.send) return message.channel.send(argument.prompt.send);
89
+ }
90
+
91
+ else args[argument.name] = undefined;
92
+
93
+ i++
94
+ }
95
+
96
+ else args[argument.name] = undefined;
97
+ }
98
+
99
+ return args;
100
+ }
101
+ }
102
+
103
+ args = new Arguments()
104
+
105
+ module.exports = {
106
+ interactionArgs: args.interactionArgs,
107
+ messageArgs: args.messageArgs
108
+ }
@@ -3,94 +3,98 @@ const { toPascalCase } = require('dumfunctions');
3
3
 
4
4
  const Cooldown = {};
5
5
 
6
- module.exports = function commandValidation(event, command, res = false) {
7
- function emit(reason, extra) {
8
- return event.client.emit('commandBlocked', event, reason, extra);
9
- }
10
-
11
- if ((command?.ignoreOwner || event?.client?.settings?.ignoreOwner) && event?.client?.settings?.ownerId?.includes((event.user || event.author).id)) return res;
12
-
13
- if (Cooldown[(event.user || event.author).id]) {
14
- res = true;
15
- return emit("command on cooldown", (Cooldown[(event.user || event.author).id] - (event.editedTimestamp || event.createdTimestamp)));
16
- }
17
-
18
- if (!Cooldown[(event.user || event.author).id]) {
19
- Cooldown[(event.user || event.author).id] = ((event.editedTimestamp || event.createdTimestamp) + (command.cooldown || event.client.settings.defaultCooldown || 0));
20
-
21
- setTimeout(() => {
22
- delete Cooldown[(event.user || event.author).id]
23
- }, command.cooldown || event?.client?.settings?.defaultCooldown || 0);
24
- }
6
+ class CommandValidation {
7
+ commandValidation(event, command, res = false) {
8
+ function emit(reason, extra) {
9
+ return event.client.emit('commandBlocked', event, reason, extra);
10
+ }
25
11
 
26
- if (command?.owner && event?.client?.settings?.ownerId != undefined && !event?.client?.settings?.ownerId?.includes((event.user || event.author).id)) {
27
- res = true;
28
- return emit("missing ownership", event?.client?.settings?.ownerId)
29
- }
12
+ if ((command?.ignoreOwner || event?.client?.settings?.ignoreOwner) && event?.client?.settings?.ownerId?.includes((event.user || event.author).id)) return res;
30
13
 
31
- if (command?.admin && event?.member?.permissions?.has(Discord.PermissionFlagsBits.Administrator) == false) {
32
- res = true;
33
- return emit("missing admin permission", "Administrator")
34
- }
14
+ if (Cooldown[(event.user || event.author).id]) {
15
+ res = true;
16
+ return emit("command on cooldown", (Cooldown[(event.user || event.author).id] - (event.editedTimestamp || event.createdTimestamp)));
17
+ }
35
18
 
36
- if (command?.channel == "guild" && event?.channel?.type != "GUILD_TEXT") {
37
- res = true
38
- return emit("not a guild channel");
39
- }
19
+ if (!Cooldown[(event.user || event.author).id]) {
20
+ Cooldown[(event.user || event.author).id] = ((event.editedTimestamp || event.createdTimestamp) + (command.cooldown || event.client.settings.defaultCooldown || 0));
40
21
 
41
- if (command?.channel == "dm" && event?.type != null) {
42
- res = true;
43
- return emit("not a dm channel");
44
- }
22
+ setTimeout(() => {
23
+ delete Cooldown[(event.user || event.author).id]
24
+ }, command.cooldown || event?.client?.settings?.defaultCooldown || 0);
25
+ }
45
26
 
46
- if (command?.inVoice && !event?.member?.voice?.channelId) {
47
- res = true;
48
- return emit("not a in a voice channel");
49
- }
27
+ if (command?.owner && event?.client?.settings?.ownerId != undefined && !event?.client?.settings?.ownerId?.includes((event.user || event.author).id)) {
28
+ res = true;
29
+ return emit("missing ownership", event?.client?.settings?.ownerId)
30
+ }
50
31
 
51
- if (event?.guild && command?.userPermissions?.length >= 1 || event?.client?.settings?.userPermissions?.length >= 1) {
52
- let missingPerms = [];
32
+ if (command?.admin && event?.member?.permissions?.has(Discord.PermissionFlagsBits.Administrator) == false) {
33
+ res = true;
34
+ return emit("missing admin permission", "Administrator")
35
+ }
53
36
 
54
- for (const permission of command.userPermissions) {
55
- if (!event?.member?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
37
+ if (command?.channel == "guild" && event?.channel?.type != "GUILD_TEXT") {
38
+ res = true
39
+ return emit("not a guild channel");
56
40
  }
57
41
 
58
- for (const permission of event?.client?.settings?.userPermissions) {
59
- if (!event?.member?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
42
+ if (command?.channel == "dm" && event?.type != null) {
43
+ res = true;
44
+ return emit("not a dm channel");
60
45
  }
61
46
 
62
- if (missingPerms.length >= 1) {
47
+ if (command?.inVoice && !event?.member?.voice?.channelId) {
63
48
  res = true;
64
- return emit("missing user permissions", missingPerms);
49
+ return emit("not a in a voice channel");
65
50
  }
66
- }
67
51
 
68
- if (event?.guild && command?.clientPermissions.length >= 1 || event.client.settings.clientPermissions.length >= 1) {
69
- let missingPerms = [];
52
+ if (event?.guild && command?.userPermissions?.length >= 1 || event?.client?.settings?.userPermissions?.length >= 1) {
53
+ let missingPerms = [];
54
+
55
+ for (const permission of command.userPermissions) {
56
+ if (!event?.member?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
57
+ }
58
+
59
+ for (const permission of event?.client?.settings?.userPermissions) {
60
+ if (!event?.member?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
61
+ }
70
62
 
71
- for (const permission of command?.clientPermissions) {
72
- if (!event?.guild?.members?.me?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
63
+ if (missingPerms.length >= 1) {
64
+ res = true;
65
+ return emit("missing user permissions", missingPerms);
66
+ }
73
67
  }
74
68
 
75
- for (const permission of event?.client?.settings?.clientPermissions) {
76
- if (!event?.guild?.members?.me?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
69
+ if (event?.guild && command?.clientPermissions.length >= 1 || event.client.settings.clientPermissions.length >= 1) {
70
+ let missingPerms = [];
71
+
72
+ for (const permission of command?.clientPermissions) {
73
+ if (!event?.guild?.members?.me?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
74
+ }
75
+
76
+ for (const permission of event?.client?.settings?.clientPermissions) {
77
+ if (!event?.guild?.members?.me?.permissions?.has(Discord.PermissionFlagsBits[toPascalCase(permission)])) missingPerms.push(toPascalCase(permission));
78
+ }
79
+
80
+ if (missingPerms.length >= 1) {
81
+ res = true;
82
+ return emit("missing client permissions", missingPerms);
83
+ }
77
84
  }
78
85
 
79
- if (missingPerms.length >= 1) {
86
+ if (command?.guilds?.length >= 1 && !command?.guilds?.includes(event.guild)) {
80
87
  res = true;
81
- return emit("missing client permissions", missingPerms);
88
+ return emit('not in a specified guild', command.guilds);
82
89
  }
83
- }
84
90
 
85
- if (command?.guilds?.length >= 1 && !command?.guilds?.includes(event.guild)) {
86
- res = true;
87
- return emit('not in a specified guild', command.guilds);
88
- }
91
+ if (command?.channels?.length >= 1 && !command?.channels?.includes(event.channel.id)) {
92
+ res = true;
93
+ return emit('not in a specified channel', command.channels);
94
+ }
89
95
 
90
- if (command?.channels?.length >= 1 && !command?.channels?.includes(event.channel.id)) {
91
- res = true;
92
- return emit('not in a specified channel', command.channels);
96
+ return res;
93
97
  }
98
+ }
94
99
 
95
- return res;
96
- }
100
+ module.exports = new CommandValidation().commandValidation;
@@ -39,176 +39,6 @@ class Functions {
39
39
 
40
40
  return client.config;
41
41
  }
42
-
43
- /**
44
- *
45
- * @param {object} interaction - Interaction event.
46
- * @returns argument options without having to do the whole builders way.
47
- */
48
- interactionArgs(interaction) {
49
- let group, sub, options = {};
50
-
51
- if (interaction?.options?._group) group = interaction.options._group;
52
-
53
- if (interaction?.options?._subcommand) sub = interaction.options._subcommand;
54
-
55
- if (interaction?.options?._hoistedOptions) {
56
- for (const option of interaction.options._hoistedOptions) {
57
- options[option.name] = option.channel || option.user || option.role || option.value;
58
- }
59
- }
60
-
61
- return { group, sub, options };
62
- }
63
-
64
- /**
65
- *
66
- * @param {object} message - Message Object.
67
- * @param {object} command - Command Class.
68
- * @returns argument options without having to make them yourself.
69
- */
70
- async messageArgs({ message: message, command: command }) {
71
- let args = {}, separator = command.separator || ' ', i = 0;
72
-
73
- if (!command.args) return;
74
-
75
- for (const argument of command.args) {
76
-
77
- let content = message.content.replace(new RegExp(`${separator}${separator}+`, "g"), separator).split(separator).slice(i + 1);
78
-
79
- if (content.join(separator) != '') {
80
-
81
- if (argument?.content?.includes(content[0])) {
82
- args[argument.name] = content[0];
83
- }
84
-
85
- else if (argument.type == 'string') {
86
- args[argument.name] = content[0];
87
- }
88
-
89
- else if (argument.type == 'number') {
90
- args[argument.name] = parseInt(content[0]);
91
- }
92
-
93
- else if (argument.type == 'boolean') {
94
- if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false') content[0] = undefined;
95
- args[argument.name] = content[0];
96
- }
97
-
98
- else if (argument.type == 'user') {
99
- let user;
100
- try { user = await message.client.users.fetch(content[0].replace(/<@!?|>/g, "")) } catch (e) { user = e }
101
- args[argument.name] = user;
102
- }
103
-
104
- else if (argument.type == 'role') {
105
- let role;
106
- try { role = await message.guild.roles.fetch(content[0].replace(/<@&?|>/g, "")) } catch (e) { role = e }
107
- args[argument.name] = role;
108
- }
109
-
110
- else if (argument.type == 'member') {
111
- let member;
112
- try { member = await message.guild.members.fetch(content[0].replace(/<@!?|>/g, "")) } catch (e) { member = e }
113
- args[argument.name] = member;
114
- }
115
-
116
- else if (argument.type == 'channel') {
117
- let channel;
118
- try { channel = await message.client.channels.fetch(content[0].replace(/<#|>/g, "")) } catch (e) { channel = e }
119
- args[argument.name] = channel;
120
- }
121
-
122
- else if (argument.type == 'rest') {
123
- args[argument.name] = content.join(separator);
124
- break;
125
- }
126
-
127
- else if (argument.prompt) {
128
- if (argument.prompt.reply) return message.reply(argument.prompt.reply);
129
- else if (argument.prompt.send) return message.channel.send(argument.prompt.send);
130
- }
131
-
132
- else args[argument.name] = undefined;
133
-
134
- i++
135
- }
136
-
137
- else args[argument.name] = undefined;
138
- }
139
-
140
- return args;
141
- }
142
-
143
- async messageEdit(message, type) {
144
- setTimeout(() => {
145
- if (message.client.messages[message.id] === null || message.client.messages[message.id]) delete message.client.messages[message.id];
146
-
147
- if (message.channel.messages.cache.has(message.id)) message.channel.messages.cache.delete(message.id);
148
- }, message.client.settings.cacheTime);
149
-
150
- message.util = {};
151
-
152
- if (type == "create") {
153
- message.client.messages[message.id] = null;
154
-
155
- message.util.send = async (e) => {
156
- const msg = await message.channel.send(e);
157
-
158
- message.client.messages[message.id] = msg.id;
159
-
160
- return msg;
161
- }
162
-
163
- message.util.reply = async (e) => {
164
- const msg = await message.reply(e);
165
-
166
- message.client.messages[message.id] = msg.id;
167
-
168
- return msg;
169
- }
170
-
171
- return;
172
- }
173
-
174
- if (type == 'edit') {
175
- if (message.client.messages[message.id] === null) {
176
- message.util.send = async (e) => {
177
- const msg = await message.channel.send(e);
178
-
179
- message.client.messages[message.id] = msg.id;
180
-
181
- return msg;
182
- }
183
-
184
- message.util.reply = async (e) => {
185
- const msg = await message.reply(e);
186
-
187
- message.client.messages[message.id] = msg.id;
188
-
189
- return msg;
190
- }
191
-
192
- return;
193
- }
194
-
195
- else if (message.client.messages[message.id] !== null) {
196
- const msg = await message.channel.messages.fetch(message.client.messages[message.id]);
197
-
198
- message.util.send = async (e) => {
199
- return await msg.edit(e);
200
- }
201
-
202
- message.util.reply = async (e) => {
203
- return await msg.edit(e);
204
- }
205
-
206
- return;
207
- }
208
- }
209
-
210
- else return;
211
- }
212
42
  }
213
43
 
214
44
  module.exports = new Functions();
@@ -0,0 +1,213 @@
1
+ const { EmbedBuilder, ActionRowBuilder, SelectMenuBuilder, Embed, ButtonBuilder, ButtonStyle } = require('discord.js');
2
+ const opts = require('./options.json');
3
+
4
+ function reply(interaction, text) {
5
+ return (interaction.replied || interaction.deferred) ? interaction.editReply(text) : interaction.reply(text);
6
+ }
7
+
8
+ function selectMenuPaginator(interaction, embeds, options = {}) {
9
+ if (!embeds) return interaction.client.emit('error', interaction, "no embeds");
10
+
11
+ if (!Array.isArray(embeds)) return interaction.client.emit('error', interaction, "no array of embeds")
12
+
13
+ if (!options.index) {
14
+ options.index = new EmbedBuilder()
15
+ .setTitle(`${embeds.length} pages`)
16
+
17
+ 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}` }]))
18
+ }
19
+
20
+ if (!options.row) {
21
+ options.row = new ActionRowBuilder();
22
+
23
+ if (!options.id) options.id = `${interaction.id}-menu`;
24
+
25
+ options.comp = new SelectMenuBuilder()
26
+ .setCustomId(options.id)
27
+ .setMaxValues(1)
28
+ .setMinValues(1)
29
+ .setPlaceholder('Select a page.')
30
+ .addOptions({ label: 'Index', description: 'Index Page', value: 'index' })
31
+
32
+ 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)] }))
33
+
34
+ options.row.addComponents(options.comp);
35
+ }
36
+
37
+ if (!options.id) options.id = options.row.components[0].data.custom_id;
38
+
39
+ (async () => {
40
+ let embed = options.index;
41
+
42
+ let m = options.send ? await interaction.channel.send({ embeds: [embed], components: [options.row] }) : await reply(interaction, { embeds: [embed], components: [options.row] })
43
+
44
+ interaction.channel.createMessageComponentCollector({ filter: options.filter, time: options.time || 300000 })
45
+
46
+ .on('collect', async (a) => {
47
+ if (a.customId != options.id) return;
48
+
49
+ let chosen = a.values[0];
50
+
51
+ if (chosen === options.row.components[0]?.options[0]?.data?.value) embed = options.index;
52
+
53
+ else embed = embeds[opts.indexOf(chosen)];
54
+
55
+ a.update({ embeds: [embed] });
56
+ })
57
+
58
+ .on('end', async () => {
59
+ if (interaction.editReply) interaction.editReply({ components: [] });
60
+
61
+ if (interaction.edit) await m.edit({ components: [] });
62
+ })
63
+ })();
64
+ }
65
+
66
+ function buttonPaginator(interaction, embeds, options = {}) {
67
+ if (!options.buttons) options.buttons = ["⏪", "◀️", "⏹️", "▶️", "⏩"];
68
+
69
+ if (options.buttons.length <= 4 || options.buttons.length > 5) throw new Error('Must specify 5 emotes.')
70
+
71
+ options.row = new ActionRowBuilder()
72
+
73
+ for (const button of options.buttons) {
74
+ options.row
75
+ .addComponents(
76
+ new ButtonBuilder()
77
+ .setCustomId(`${interaction.id}-${opts[options.buttons.indexOf(button)]}`)
78
+ .setStyle(ButtonStyle[options.style || 'Primary'])
79
+ .setEmoji(button)
80
+ )
81
+ }
82
+
83
+ (async () => {
84
+ let embed = embeds[options.index || 0];
85
+
86
+ let m = options.send ? await interaction.channel.send({ embeds: [embed], components: [options.row] }) : await reply(interaction, { embeds: [embed], components: [options.row] });
87
+
88
+ interaction.channel.createMessageComponentCollector({ filter: options.filter, time: options.time || 300000 })
89
+
90
+ .on('collect', async (a) => {
91
+ if (a.customId == `${interaction.id}-one`) {
92
+ embed = embeds[0];
93
+ a.update({ embeds: [embed] });
94
+ }
95
+
96
+ if (a.customId == `${interaction.id}-two`) {
97
+ embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
98
+ a.update({ embeds: [embed] });
99
+ }
100
+
101
+ if (a.customId == `${interaction.id}-three`) {
102
+ a.update({ components: [] });
103
+ }
104
+
105
+ if (a.customId == `${interaction.id}-four`) {
106
+ embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
107
+ a.update({ embeds: [embed] });
108
+ }
109
+
110
+ if (a.customId == `${interaction.id}-five`) {
111
+ embed = embeds[embeds.length - 1];
112
+ a.update({ embeds: [embed] });
113
+ }
114
+ })
115
+
116
+ .on('end', async () => {
117
+ if (interaction.editReply) interaction.editReply({ components: [] });
118
+
119
+ if (interaction.edit) await m.edit({ components: [] });
120
+ })
121
+ })();
122
+ }
123
+
124
+ class Util {
125
+ async messageUtil(message, type) {
126
+ setTimeout(() => {
127
+ if (message.client.messages[message.id] === null || message.client.messages[message.id]) delete message.client.messages[message.id];
128
+
129
+ if (message.channel.messages.cache.has(message.id)) message.channel.messages.cache.delete(message.id);
130
+ }, message.client.settings.cacheTime);
131
+
132
+ message.util = {};
133
+
134
+ message.util.selectMenuPaginator = (embeds, options) => selectMenuPaginator(message, embeds, options);
135
+
136
+ message.util.buttonPaginator = (embeds, options) => buttonPaginator(message, embeds, options);
137
+
138
+ if (type == "create") {
139
+ message.client.messages[message.id] = null;
140
+
141
+ message.util.send = async (e) => {
142
+ const msg = await message.channel.send(e);
143
+
144
+ message.client.messages[message.id] = msg.id;
145
+
146
+ return msg;
147
+ }
148
+
149
+ message.util.reply = async (e) => {
150
+ const msg = await message.reply(e);
151
+
152
+ message.client.messages[message.id] = msg.id;
153
+
154
+ return msg;
155
+ }
156
+
157
+ return;
158
+ }
159
+
160
+ if (type == 'edit') {
161
+ if (message.client.messages[message.id] === null) {
162
+ message.util.send = async (e) => {
163
+ const msg = await message.channel.send(e);
164
+
165
+ message.client.messages[message.id] = msg.id;
166
+
167
+ return msg;
168
+ }
169
+
170
+ message.util.reply = async (e) => {
171
+ const msg = await message.reply(e);
172
+
173
+ message.client.messages[message.id] = msg.id;
174
+
175
+ return msg;
176
+ }
177
+
178
+ return;
179
+ }
180
+
181
+ else if (message.client.messages[message.id] !== null) {
182
+ const msg = await message.channel.messages.fetch(message.client.messages[message.id]);
183
+
184
+ message.util.send = async (e) => {
185
+ return await msg.edit(e);
186
+ }
187
+
188
+ message.util.reply = async (e) => {
189
+ return await msg.edit(e);
190
+ }
191
+
192
+ return;
193
+ }
194
+ }
195
+ }
196
+
197
+ interactionUtil(interaction) {
198
+ interaction.util = {}
199
+
200
+ interaction.util.reply = (text) => reply(interaction, text);
201
+
202
+ interaction.util.selectMenuPaginator = (embeds, options) => selectMenuPaginator(interaction, embeds, options);
203
+
204
+ interaction.util.buttonPaginator = (embeds, options) => buttonPaginator(interaction, embeds, options);
205
+ }
206
+ }
207
+
208
+ u = new Util;
209
+
210
+ module.exports = {
211
+ messageUtil: u.messageUtil,
212
+ interactionUtil: u.interactionUtil
213
+ };
@@ -0,0 +1,27 @@
1
+ [
2
+ "one",
3
+ "two",
4
+ "three",
5
+ "four",
6
+ "five",
7
+ "six",
8
+ "seven",
9
+ "eight",
10
+ "nine",
11
+ "ten",
12
+ "eleven",
13
+ "twelve",
14
+ "thirteen",
15
+ "fourteen",
16
+ "fifteen",
17
+ "sixteen",
18
+ "seventeen",
19
+ "eighteen",
20
+ "nineteen",
21
+ "twenty",
22
+ "twentyone",
23
+ "twentytwo",
24
+ "twentythree",
25
+ "twentyfour",
26
+ "twentyfive"
27
+ ]
@@ -1,7 +1,8 @@
1
1
  const { Event } = require('../commands/Event.js');
2
- const { interactionArgs } = require('./../data/Functions.js');
2
+ const { interactionArgs } = require('./../data/Arguments.js');
3
3
  const { InteractionType } = require('discord.js')
4
4
  const commandValidation = require('./../data/CommandValidation.js');
5
+ const { interactionUtil } = require('./../data/Util.js');
5
6
  /**
6
7
  * @returns interaction command executor.
7
8
  */
@@ -15,6 +16,8 @@ class BuildInInteractionEvent extends Event {
15
16
  }
16
17
 
17
18
  async run(interaction) {
19
+ await interactionUtil(interaction)
20
+
18
21
  if (interaction.type == InteractionType.ApplicationCommand) {
19
22
  if (interaction.client.interactionCommands.has(interaction.commandName)) {
20
23
  let command = interaction.client.interactionCommands.get(interaction.commandName);
@@ -29,13 +32,6 @@ class BuildInInteractionEvent extends Event {
29
32
 
30
33
  if (commandValidation(interaction, command)) return;
31
34
 
32
- interaction.util = {}
33
-
34
- interaction.util.reply = (text) => {
35
- if (interaction.replied || interaction.deferred) return interaction.editReply(text);
36
- else return interaction.reply(text);
37
- }
38
-
39
35
  try {
40
36
  await command.exec(interaction, { group: group, subcommand: subcommand, args: args });
41
37
 
@@ -1,6 +1,7 @@
1
1
  const { Event } = require('../commands/Event.js');
2
- const { messageArgs, messageEdit } = require("./../data/Functions.js");
2
+ const { messageArgs } = require("./../data/Arguments.js");
3
3
  const commandValidation = require('./../data/CommandValidation.js');
4
+ const { messageUtil } = require('../data/Util.js');
4
5
 
5
6
  /**
6
7
  * @returns message command executor.
@@ -16,8 +17,9 @@ class BuildInMessageEvent extends Event {
16
17
 
17
18
  async run(message) {
18
19
  if (!message.author.bot) {
20
+ if (message?.client?.settings?.prefix?.length <= 0) return;
19
21
 
20
- await messageEdit(message, "create");
22
+ await messageUtil(message, "create");
21
23
 
22
24
  for (const prefix of message.client.settings.prefix) {
23
25
  if (!message.content.startsWith(prefix)) continue;
@@ -1,6 +1,7 @@
1
1
  const { Event } = require('../commands/Event.js');
2
- const { messageArgs, messageEdit } = require("./../data/Functions.js");
2
+ const { messageArgs } = require("./../data/Arguments.js");
3
3
  const commandValidation = require('./../data/CommandValidation.js');
4
+ const { messageUtil } = require('../data/Util.js');
4
5
 
5
6
  /**
6
7
  * @returns message command executor.
@@ -15,19 +16,20 @@ class BuildInMessageUpdateEvent extends Event {
15
16
  }
16
17
 
17
18
  async run(oldMessage, newMessage) {
19
+ if (newMessage?.client?.settings?.prefix?.length <= 0) return;
18
20
 
19
- await messageEdit(newMessage, "edit");
21
+ await messageUtil(newMessage, "edit");
20
22
 
21
23
  if (!oldMessage.author.bot && !newMessage.author.bot) {
22
24
 
23
- if (!newMessage.client.messages[newMessage.id] == undefined) return;
25
+ if (!newMessage.client.messages[newMessage.id] === undefined) return;
24
26
 
25
27
  for (const prefix of newMessage.client.settings.prefix) {
26
28
  if (!newMessage.content.startsWith(prefix)) continue;
27
29
 
28
30
  let command = newMessage.content.replace(prefix, "").split(/ +/).shift().toLowerCase();
29
31
 
30
- if (!newMessage.client.messageCommands.has(command) || command == '') return;
32
+ if (!newMessage.client.messageCommands.has(command) || command === '') return;
31
33
 
32
34
  command = newMessage.client.messageCommands.get(command);
33
35
 
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "xernerx",
3
- "version": "2.0.7",
4
- "description": "A bot framework for discord.js. [BETA]",
5
- "main": "main.js",
6
- "scripts": {
7
- "test": "echo Setup a bot then start the bot."
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/TheDummi/xernerx.git"
12
- },
13
- "author": "Dummi",
14
- "license": "MIT",
15
- "bugs": {
16
- "url": "https://github.com/TheDummi/xernerx/issues"
17
- },
18
- "homepage": "https://github.com/TheDummi/xernerx#readme",
19
- "dependencies": {
20
- "@discordjs/rest": "1.0.1",
21
- "@sapphire/shapeshift": "3.5.1",
22
- "discord-api-types": "^0.37.0",
23
- "discord.js": "^14.1.2",
24
- "dumfunctions": "^1.0.6",
25
- "i18next": "^21.8.16"
26
- },
27
- "packageManager": "npm@8.5.5"
28
- }
1
+ {
2
+ "name": "xernerx",
3
+ "version": "2.1.2",
4
+ "description": "A bot framework for discord.js. [BETA]",
5
+ "main": "main.js",
6
+ "scripts": {
7
+ "test": "echo Setup a bot then start the bot."
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/TheDummi/xernerx.git"
12
+ },
13
+ "author": "Dummi",
14
+ "license": "MIT",
15
+ "bugs": {
16
+ "url": "https://github.com/TheDummi/xernerx/issues"
17
+ },
18
+ "homepage": "https://github.com/TheDummi/xernerx#readme",
19
+ "dependencies": {
20
+ "@discordjs/rest": "1.0.1",
21
+ "@sapphire/shapeshift": "3.5.1",
22
+ "discord-api-types": "^0.37.0",
23
+ "discord.js": "^14.1.2",
24
+ "dumfunctions": "^1.0.7",
25
+ "i18next": "^21.8.16"
26
+ },
27
+ "packageManager": "npm@8.5.5"
28
+ }