xernerx 2.4.4 → 2.6.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.
- package/main.js +3 -0
- package/models/Client.js +30 -64
- package/models/commands/ContextMenuCommand.js +5 -3
- package/models/commands/Inhibitor.js +31 -0
- package/models/commands/MessageCommand.js +6 -1
- package/models/events/interactionCreate.js +14 -5
- package/models/events/messageCreate.js +49 -19
- package/models/events/messageUpdate.js +50 -22
- package/models/events/readyOnce.js +19 -4
- package/models/handlers/CommandHandler.js +2 -9
- package/models/handlers/EventHandler.js +5 -3
- package/models/handlers/Handler.js +111 -0
- package/models/handlers/InhibitorHandler.js +16 -0
- package/models/{data → utils}/Arguments.js +34 -22
- package/models/{data → utils}/CommandValidation.js +7 -11
- package/models/utils/CommandsUtil.js +70 -0
- package/models/utils/Functions.js +259 -0
- package/models/utils/InhibitorsUtil.js +24 -0
- package/models/utils/InhibitorsValidation.js +40 -0
- package/models/utils/Util.js +96 -0
- package/package.json +4 -4
- package/models/data/Functions.js +0 -44
- package/models/data/Util.js +0 -321
- package/models/handlers/Loader.js +0 -205
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const Handler = require("./Handler");
|
|
2
|
+
const Discord = require('discord.js');
|
|
3
|
+
|
|
4
|
+
module.exports = class InhibitorHandler {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
|
|
8
|
+
client.inhibitors = new Discord.Collection();
|
|
9
|
+
|
|
10
|
+
this.load = new Handler(client);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
loadAllInhibitors(path) {
|
|
14
|
+
this.load.loadAllInhibitors(path);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class Arguments {
|
|
1
|
+
module.exports = new class Arguments {
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
4
|
* @param {object} interaction - Interaction event.
|
|
@@ -27,16 +27,26 @@ class Arguments {
|
|
|
27
27
|
* @returns argument options without having to make them yourself.
|
|
28
28
|
*/
|
|
29
29
|
async messageArgs({ message: message, command: command }) {
|
|
30
|
-
let args = {}, separator = command.separator || ' ', i = 0;
|
|
30
|
+
let args = { flags: {} }, separator = command.separator || ' ', i = 0;
|
|
31
31
|
|
|
32
32
|
if (!command.args) return;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
command.args.filter(c => c.type == "flag").map(flag => {
|
|
35
|
+
for (const flg of message.content.matchAll(flag.content)) {
|
|
36
|
+
if (flag.content == flg) {
|
|
37
|
+
message.content = message.content.replace(flag.content, "");
|
|
38
|
+
|
|
39
|
+
args.flags[flag.name] = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
if (!args.flags[flag.name]) args.flags[flag.name] = false;
|
|
44
|
+
})
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
for (const argument of command.args) {
|
|
47
|
+
let content = message.content.split(/ +/).slice(1).join(separator).replace(new RegExp(`${separator}${separator}+`, "g"), separator).split(separator).slice(i);
|
|
39
48
|
|
|
49
|
+
if (content.join(separator) != '' && argument.type !== "flag") {
|
|
40
50
|
if (argument?.content?.includes(content[0])) {
|
|
41
51
|
args[argument.name] = content[0];
|
|
42
52
|
}
|
|
@@ -51,30 +61,39 @@ class Arguments {
|
|
|
51
61
|
|
|
52
62
|
else if (argument.type == 'boolean') {
|
|
53
63
|
if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false') content[0] = undefined;
|
|
64
|
+
|
|
54
65
|
args[argument.name] = content[0];
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
else if (argument.type == 'user') {
|
|
58
|
-
let user;
|
|
59
|
-
|
|
69
|
+
let user = message.client.users.cache.find(u => u?.username?.toLowerCase()?.includes(content[0]));
|
|
70
|
+
|
|
71
|
+
try { user = await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, "")) } catch (e) { user = new Error("Invalid user snowflake ID") };
|
|
72
|
+
|
|
60
73
|
args[argument.name] = user;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
else if (argument.type == 'role') {
|
|
64
|
-
let role;
|
|
65
|
-
|
|
77
|
+
let role = message.guild.roles.cache.find(r => r?.name?.toLowerCase()?.includes(content[0]));
|
|
78
|
+
|
|
79
|
+
try { role = await message.guild.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, "")) } catch (e) { role = new Error("Invalid role snowflake ID") };
|
|
80
|
+
|
|
66
81
|
args[argument.name] = role;
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
else if (argument.type == 'member') {
|
|
70
|
-
let member;
|
|
71
|
-
|
|
85
|
+
let member = message.guild.members.cache.find(m => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0]));
|
|
86
|
+
|
|
87
|
+
try { member = await message.guild.members.fetch(member?.id || content[0].replace(/<@!?|>/g, "")) } catch (e) { member = new Error("Invalid member snowflake ID") };
|
|
88
|
+
|
|
72
89
|
args[argument.name] = member;
|
|
73
90
|
}
|
|
74
91
|
|
|
75
92
|
else if (argument.type == 'channel') {
|
|
76
|
-
let channel;
|
|
77
|
-
|
|
93
|
+
let channel = message.guild.channels.cache.find(c => c?.name?.toLowerCase()?.includes(content[0]));
|
|
94
|
+
|
|
95
|
+
try { channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, "")) } catch (e) { channel = new Error("Invalid channel snowflake ID") }
|
|
96
|
+
|
|
78
97
|
args[argument.name] = channel;
|
|
79
98
|
}
|
|
80
99
|
|
|
@@ -88,21 +107,14 @@ class Arguments {
|
|
|
88
107
|
else if (argument.prompt.send) return message.channel.send(argument.prompt.send);
|
|
89
108
|
}
|
|
90
109
|
|
|
91
|
-
else args[argument.name] =
|
|
110
|
+
else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
|
|
92
111
|
|
|
93
112
|
i++
|
|
94
113
|
}
|
|
95
114
|
|
|
96
|
-
else args[argument.name] =
|
|
115
|
+
else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
|
|
97
116
|
}
|
|
98
117
|
|
|
99
118
|
return args;
|
|
100
119
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
args = new Arguments()
|
|
104
|
-
|
|
105
|
-
module.exports = {
|
|
106
|
-
interactionArgs: args.interactionArgs,
|
|
107
|
-
messageArgs: args.messageArgs
|
|
108
120
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const Discord = require('discord.js');
|
|
2
2
|
const { toPascalCase } = require('dumfunctions');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class CommandValidation {
|
|
4
|
+
module.exports = new class CommandValidation {
|
|
7
5
|
commandValidation(event, command, res = false) {
|
|
8
6
|
function emit(reason, extra) {
|
|
9
7
|
return event.client.emit('commandBlocked', event, reason, extra);
|
|
@@ -11,16 +9,16 @@ class CommandValidation {
|
|
|
11
9
|
|
|
12
10
|
if ((command?.ignoreOwner || event?.client?.settings?.ignoreOwner) && event?.client?.settings?.ownerId?.includes((event.user || event.author).id)) return res;
|
|
13
11
|
|
|
14
|
-
if (
|
|
12
|
+
if (event.client.data.cooldowns[(event.user || event.author).id]) {
|
|
15
13
|
res = true;
|
|
16
|
-
return emit("command on cooldown", (
|
|
14
|
+
return emit("command on cooldown", (event.client.data.cooldowns[(event.user || event.author).id] - (event.editedTimestamp || event.createdTimestamp)));
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
if (!
|
|
20
|
-
|
|
17
|
+
if (!event.client.data.cooldowns[(event.user || event.author).id]) {
|
|
18
|
+
event.client.data.cooldowns[(event.user || event.author).id] = ((event.editedTimestamp || event.createdTimestamp) + (command.cooldown || event.client.settings.defaultCooldown || 0));
|
|
21
19
|
|
|
22
20
|
setTimeout(() => {
|
|
23
|
-
delete
|
|
21
|
+
delete event.client.data.cooldowns[(event.user || event.author).id]
|
|
24
22
|
}, command.cooldown || event?.client?.settings?.defaultCooldown || 0);
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -95,6 +93,4 @@ class CommandValidation {
|
|
|
95
93
|
|
|
96
94
|
return res;
|
|
97
95
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
module.exports = new CommandValidation().commandValidation;
|
|
96
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const { logStyle } = require("dumfunctions");
|
|
2
|
+
|
|
3
|
+
module.exports = new class CommandsUtil {
|
|
4
|
+
importCommands(client, path, files, commands, type) {
|
|
5
|
+
for (const file of files) {
|
|
6
|
+
try {
|
|
7
|
+
let filepath = `${require("path").resolve(path)}/${file}`;
|
|
8
|
+
|
|
9
|
+
let command = require(filepath);
|
|
10
|
+
|
|
11
|
+
command = new command;
|
|
12
|
+
|
|
13
|
+
command.filepath = filepath;
|
|
14
|
+
|
|
15
|
+
command.runType = type;
|
|
16
|
+
|
|
17
|
+
command.client = client;
|
|
18
|
+
|
|
19
|
+
if (type !== 'message') {
|
|
20
|
+
commands.push(command.data.toJSON());
|
|
21
|
+
|
|
22
|
+
client.commands[type].set(command.data.name, command);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (type === 'message') {
|
|
26
|
+
client.commands[type].set(command.name, command);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error(logStyle(`Couldn't load ${file} because of <${error.message}>!`, "text", "red"));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return commands;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
reimportCommands(client, cmds, type) {
|
|
38
|
+
let commands = [];
|
|
39
|
+
|
|
40
|
+
client.commands[type].map(command => { if (!commands.includes(command.filepath)) commands.push(command.filepath) });
|
|
41
|
+
|
|
42
|
+
client.commands[type].sweep(() => true);
|
|
43
|
+
|
|
44
|
+
commands.map(path => {
|
|
45
|
+
delete require.cache[require.resolve(path)];
|
|
46
|
+
|
|
47
|
+
let command = require(path);
|
|
48
|
+
|
|
49
|
+
command = new command;
|
|
50
|
+
|
|
51
|
+
command.filepath = path;
|
|
52
|
+
|
|
53
|
+
command.runType = type;
|
|
54
|
+
|
|
55
|
+
command.client = client;
|
|
56
|
+
|
|
57
|
+
if (type !== 'message') {
|
|
58
|
+
cmds.push(command.data.toJSON());
|
|
59
|
+
|
|
60
|
+
client.commands[type].set(command.data.name, command);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (type === 'message') {
|
|
64
|
+
client.commands[type].set(command.name, command);
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
return commands;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
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
|
+
const { logStyle } = require('dumfunctions');
|
|
5
|
+
|
|
6
|
+
function reply(interaction, text) {
|
|
7
|
+
return (interaction.replied || interaction.deferred) ? interaction.editReply(text) : interaction.reply(text);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {object} Functions - Build in functions of the bot hidden away in the handlers/setters.
|
|
12
|
+
*/
|
|
13
|
+
module.exports = new class Functions {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {object} client - Client object.
|
|
17
|
+
* @param {object} options - Client options.
|
|
18
|
+
* @returns an object of default colors and custom colors to be imported anywhere without having to import them.
|
|
19
|
+
*/
|
|
20
|
+
color({ client: client, options: options }) {
|
|
21
|
+
client.color = { FLAGS: colors }
|
|
22
|
+
|
|
23
|
+
if (options.color) {
|
|
24
|
+
for (const [name, color] of Object.entries(options.color)) {
|
|
25
|
+
client.color[name] = color;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return client.color;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {object} client - Client object.
|
|
35
|
+
* @param {object} options - Client options.
|
|
36
|
+
* @returns custom config settings for the bot.
|
|
37
|
+
*/
|
|
38
|
+
config({ client: client, options: options }) {
|
|
39
|
+
client.config = {}
|
|
40
|
+
|
|
41
|
+
if (options.config) {
|
|
42
|
+
for (const [key, value] of Object.entries(options.config)) {
|
|
43
|
+
client.config[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return client.config;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
reply(interaction, text) {
|
|
51
|
+
return (interaction.replied || interaction.deferred) ? interaction.editReply(text) : interaction.reply(text);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
selectMenuPaginator(interaction, embeds, options = {}) {
|
|
55
|
+
if (!embeds) return interaction.client.emit('error', interaction, "no embeds");
|
|
56
|
+
|
|
57
|
+
if (!Array.isArray(embeds)) return interaction.client.emit('error', interaction, "no array of embeds")
|
|
58
|
+
|
|
59
|
+
if (!options.index) {
|
|
60
|
+
options.index = new EmbedBuilder()
|
|
61
|
+
.setTitle(`${embeds.length} pages`)
|
|
62
|
+
|
|
63
|
+
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}` }]))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!options.row) {
|
|
67
|
+
options.row = new ActionRowBuilder();
|
|
68
|
+
|
|
69
|
+
if (!options.id) options.id = `${interaction.id}-menu`;
|
|
70
|
+
|
|
71
|
+
options.comp = new SelectMenuBuilder()
|
|
72
|
+
.setCustomId(options.id)
|
|
73
|
+
.setMaxValues(1)
|
|
74
|
+
.setMinValues(1)
|
|
75
|
+
.setPlaceholder('Select a page.')
|
|
76
|
+
.addOptions({ label: 'Index', description: 'Index Page', value: 'index' })
|
|
77
|
+
|
|
78
|
+
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)] }))
|
|
79
|
+
|
|
80
|
+
options.row.addComponents(options.comp);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!options.id) options.id = options.row.components[0].data.custom_id;
|
|
84
|
+
|
|
85
|
+
(async () => {
|
|
86
|
+
let embed = options.index;
|
|
87
|
+
|
|
88
|
+
let m = options.send ? await interaction.channel.send({ embeds: [embed], components: [options.row] }) : await reply(interaction, { embeds: [embed], components: [options.row] })
|
|
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
|
+
if (commands.has(cmd)) {
|
|
120
|
+
const command = commands.get(cmd);
|
|
121
|
+
|
|
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
|
+
|
|
135
|
+
else {
|
|
136
|
+
commandInfo = {
|
|
137
|
+
name: command?.data?.name + " " + option?.name,
|
|
138
|
+
description: option?.description,
|
|
139
|
+
category: command.category
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
else {
|
|
146
|
+
commandInfo = {
|
|
147
|
+
name: command?.data?.name + " " + option?.name,
|
|
148
|
+
description: option?.description,
|
|
149
|
+
category: command.category
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
else {
|
|
155
|
+
commandInfo = {
|
|
156
|
+
name: command?.data?.name || command?.name || command?.id,
|
|
157
|
+
description: command?.data?.description || command?.description,
|
|
158
|
+
category: command.category
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
else {
|
|
165
|
+
commandInfo = {
|
|
166
|
+
name: command?.data?.name || command?.name || command?.id,
|
|
167
|
+
description: command?.data?.description || command?.description,
|
|
168
|
+
category: command.category
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
cmds.push(commandInfo);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
return cmds;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
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();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
buttonPaginator(interaction, embeds, options = {}) {
|
|
183
|
+
if (!options.buttons) options.buttons = ["⏪", "◀️", "⏹️", "▶️", "⏩"];
|
|
184
|
+
|
|
185
|
+
if (options.buttons.length <= 4 || options.buttons.length > 5) throw new Error('Must specify 5 emotes.');
|
|
186
|
+
|
|
187
|
+
options.row = new ActionRowBuilder();
|
|
188
|
+
|
|
189
|
+
for (const button of options.buttons) {
|
|
190
|
+
options.row
|
|
191
|
+
.addComponents(
|
|
192
|
+
new ButtonBuilder()
|
|
193
|
+
.setCustomId(`${interaction.id}-${opts[options.buttons.indexOf(button)]}`)
|
|
194
|
+
.setStyle(ButtonStyle[options.style || 'Primary'])
|
|
195
|
+
.setEmoji(button)
|
|
196
|
+
)
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
(async () => {
|
|
200
|
+
let embed = embeds[options.index || 0];
|
|
201
|
+
|
|
202
|
+
let m = options.send ? await interaction.channel.send({ embeds: [embed], components: [options.row] }) : await reply(interaction, { embeds: [embed], components: [options.row] });
|
|
203
|
+
|
|
204
|
+
const collector = interaction.channel.createMessageComponentCollector({ filter: options.filter, time: options.time || 300000 })
|
|
205
|
+
|
|
206
|
+
.on('collect', async (a) => {
|
|
207
|
+
if (a.customId == `${interaction.id}-one`) {
|
|
208
|
+
embed = embeds[0];
|
|
209
|
+
a.update({ embeds: [embed] });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (a.customId == `${interaction.id}-two`) {
|
|
213
|
+
embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
|
|
214
|
+
a.update({ embeds: [embed] });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (a.customId == `${interaction.id}-three`) {
|
|
218
|
+
a.update({ components: [] });
|
|
219
|
+
collector.stop();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (a.customId == `${interaction.id}-four`) {
|
|
223
|
+
embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
|
|
224
|
+
a.update({ embeds: [embed] });
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (a.customId == `${interaction.id}-five`) {
|
|
228
|
+
embed = embeds[embeds.length - 1];
|
|
229
|
+
a.update({ embeds: [embed] });
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
.on('end', async () => {
|
|
234
|
+
if (interaction.editReply) interaction.editReply({ components: [] });
|
|
235
|
+
|
|
236
|
+
if (interaction.edit) await m.edit({ components: [] });
|
|
237
|
+
})
|
|
238
|
+
})();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
uptime(interaction, timestamp) {
|
|
242
|
+
if (!timestamp) timestamp = interaction.client.uptime;
|
|
243
|
+
let totalSeconds = timestamp / 1000;
|
|
244
|
+
let years = Math.floor(totalSeconds / 31536000);
|
|
245
|
+
totalSeconds %= 31536000;
|
|
246
|
+
let days = Math.floor(totalSeconds / 86400);
|
|
247
|
+
totalSeconds %= 86400;
|
|
248
|
+
let hours = Math.floor(totalSeconds / 3600);
|
|
249
|
+
totalSeconds %= 3600;
|
|
250
|
+
let minutes = Math.floor(totalSeconds / 60);
|
|
251
|
+
let seconds = Math.floor(totalSeconds % 60);
|
|
252
|
+
|
|
253
|
+
if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`
|
|
254
|
+
else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;
|
|
255
|
+
else if (hours >= 1) return `${hours}h ${minutes}m`;
|
|
256
|
+
else if (minutes >= 1) return `${minutes}m ${seconds}s`;
|
|
257
|
+
else return `${seconds}s`;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module.exports = new class InhibitorValidation {
|
|
2
|
+
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] = 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"] = 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"] = 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"] = 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"] = inhibitor.check(event);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const inhibit of Object.values(inhibited)) {
|
|
37
|
+
if (inhibit) return inhibited;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xernerx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "A bot framework for discord.js. [BETA]",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/TheDummi/xernerx#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@discordjs/rest": "1.0
|
|
20
|
+
"@discordjs/rest": "1.1.0",
|
|
21
21
|
"@sapphire/shapeshift": "3.5.1",
|
|
22
|
-
"discord-api-types": "^0.37.
|
|
23
|
-
"discord.js": "^14.
|
|
22
|
+
"discord-api-types": "^0.37.5",
|
|
23
|
+
"discord.js": "^14.3.0",
|
|
24
24
|
"dumfunctions": "^1.0.7",
|
|
25
25
|
"i18next": "^21.9.1"
|
|
26
26
|
},
|