xernerx 4.15.0 → 4.15.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.
Files changed (137) hide show
  1. package/dist/{cjs/utils → utils}/InteractionUtil.d.ts +1 -1
  2. package/dist/{mjs/utils → utils}/InteractionUtil.js +4 -3
  3. package/dist/{cjs/utils → utils}/MessageUtil.d.ts +1 -1
  4. package/dist/{mjs/utils → utils}/MessageUtil.js +4 -3
  5. package/package.json +3 -4
  6. package/dist/cjs/build/XernerxContextCommand.js +0 -124
  7. package/dist/cjs/build/XernerxEvent.js +0 -34
  8. package/dist/cjs/build/XernerxInhibitor.js +0 -30
  9. package/dist/cjs/build/XernerxMessageCommand.js +0 -122
  10. package/dist/cjs/build/XernerxSlashCommand.js +0 -180
  11. package/dist/cjs/client/XernerxClient.js +0 -105
  12. package/dist/cjs/client/XernerxShardClient.js +0 -56
  13. package/dist/cjs/functions/deploy.js +0 -66
  14. package/dist/cjs/functions/load.js +0 -38
  15. package/dist/cjs/functions/reload.js +0 -33
  16. package/dist/cjs/functions/setPresence.js +0 -24
  17. package/dist/cjs/functions/xernerxUser.js +0 -15
  18. package/dist/cjs/handlers/CommandHandler.js +0 -342
  19. package/dist/cjs/handlers/EventHandler.js +0 -32
  20. package/dist/cjs/handlers/ExtensionHandler.js +0 -32
  21. package/dist/cjs/handlers/Handler.js +0 -48
  22. package/dist/cjs/handlers/InhibitorHandler.js +0 -34
  23. package/dist/cjs/handlers/IntegrationHandler.js +0 -29
  24. package/dist/cjs/main.js +0 -36
  25. package/dist/cjs/models/Arguments.js +0 -159
  26. package/dist/cjs/models/Cooldowns.js +0 -36
  27. package/dist/cjs/tools/XernerxError.js +0 -14
  28. package/dist/cjs/tools/XernerxIntents.js +0 -27
  29. package/dist/cjs/tools/XernerxLog.js +0 -98
  30. package/dist/cjs/tools/XernerxText.js +0 -92
  31. package/dist/cjs/types/extenders.js +0 -3
  32. package/dist/cjs/types/interfaces.js +0 -3
  33. package/dist/cjs/types/types.js +0 -3
  34. package/dist/cjs/utils/ClientUtil.js +0 -84
  35. package/dist/cjs/utils/InteractionUtil.js +0 -156
  36. package/dist/cjs/utils/MessageUtil.js +0 -170
  37. package/dist/cjs/utils/Util.js +0 -14
  38. package/dist/cjs/validators/commandValidation.js +0 -127
  39. package/dist/cjs/validators/inhibitorValidations.js +0 -49
  40. package/dist/mjs/build/XernerxContextCommand.d.ts +0 -53
  41. package/dist/mjs/build/XernerxEvent.d.ts +0 -25
  42. package/dist/mjs/build/XernerxInhibitor.d.ts +0 -29
  43. package/dist/mjs/build/XernerxMessageCommand.d.ts +0 -57
  44. package/dist/mjs/build/XernerxSlashCommand.d.ts +0 -69
  45. package/dist/mjs/client/XernerxClient.d.ts +0 -53
  46. package/dist/mjs/client/XernerxShardClient.d.ts +0 -21
  47. package/dist/mjs/functions/deploy.d.ts +0 -3
  48. package/dist/mjs/functions/load.d.ts +0 -4
  49. package/dist/mjs/functions/reload.d.ts +0 -3
  50. package/dist/mjs/functions/setPresence.d.ts +0 -4
  51. package/dist/mjs/functions/xernerxUser.d.ts +0 -4
  52. package/dist/mjs/handlers/CommandHandler.d.ts +0 -16
  53. package/dist/mjs/handlers/EventHandler.d.ts +0 -9
  54. package/dist/mjs/handlers/ExtensionHandler.d.ts +0 -9
  55. package/dist/mjs/handlers/Handler.d.ts +0 -14
  56. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -9
  57. package/dist/mjs/handlers/IntegrationHandler.d.ts +0 -15
  58. package/dist/mjs/main.d.ts +0 -40
  59. package/dist/mjs/models/Arguments.d.ts +0 -9
  60. package/dist/mjs/models/Cooldowns.d.ts +0 -11
  61. package/dist/mjs/tools/XernerxError.d.ts +0 -7
  62. package/dist/mjs/tools/XernerxIntents.d.ts +0 -5
  63. package/dist/mjs/tools/XernerxLog.d.ts +0 -28
  64. package/dist/mjs/tools/XernerxText.d.ts +0 -30
  65. package/dist/mjs/types/extenders.d.ts +0 -61
  66. package/dist/mjs/types/interfaces.d.ts +0 -256
  67. package/dist/mjs/types/types.d.ts +0 -14
  68. package/dist/mjs/utils/ClientUtil.d.ts +0 -19
  69. package/dist/mjs/utils/InteractionUtil.d.ts +0 -25
  70. package/dist/mjs/utils/MessageUtil.d.ts +0 -26
  71. package/dist/mjs/utils/Util.d.ts +0 -9
  72. package/dist/mjs/validators/commandValidation.d.ts +0 -7
  73. package/dist/mjs/validators/inhibitorValidations.d.ts +0 -9
  74. /package/dist/{cjs/build → build}/XernerxContextCommand.d.ts +0 -0
  75. /package/dist/{mjs/build → build}/XernerxContextCommand.js +0 -0
  76. /package/dist/{cjs/build → build}/XernerxEvent.d.ts +0 -0
  77. /package/dist/{mjs/build → build}/XernerxEvent.js +0 -0
  78. /package/dist/{cjs/build → build}/XernerxInhibitor.d.ts +0 -0
  79. /package/dist/{mjs/build → build}/XernerxInhibitor.js +0 -0
  80. /package/dist/{cjs/build → build}/XernerxMessageCommand.d.ts +0 -0
  81. /package/dist/{mjs/build → build}/XernerxMessageCommand.js +0 -0
  82. /package/dist/{cjs/build → build}/XernerxSlashCommand.d.ts +0 -0
  83. /package/dist/{mjs/build → build}/XernerxSlashCommand.js +0 -0
  84. /package/dist/{cjs/client → client}/XernerxClient.d.ts +0 -0
  85. /package/dist/{mjs/client → client}/XernerxClient.js +0 -0
  86. /package/dist/{cjs/client → client}/XernerxShardClient.d.ts +0 -0
  87. /package/dist/{mjs/client → client}/XernerxShardClient.js +0 -0
  88. /package/dist/{cjs/functions → functions}/deploy.d.ts +0 -0
  89. /package/dist/{mjs/functions → functions}/deploy.js +0 -0
  90. /package/dist/{cjs/functions → functions}/load.d.ts +0 -0
  91. /package/dist/{mjs/functions → functions}/load.js +0 -0
  92. /package/dist/{cjs/functions → functions}/reload.d.ts +0 -0
  93. /package/dist/{mjs/functions → functions}/reload.js +0 -0
  94. /package/dist/{cjs/functions → functions}/setPresence.d.ts +0 -0
  95. /package/dist/{mjs/functions → functions}/setPresence.js +0 -0
  96. /package/dist/{cjs/functions → functions}/xernerxUser.d.ts +0 -0
  97. /package/dist/{mjs/functions → functions}/xernerxUser.js +0 -0
  98. /package/dist/{cjs/handlers → handlers}/CommandHandler.d.ts +0 -0
  99. /package/dist/{mjs/handlers → handlers}/CommandHandler.js +0 -0
  100. /package/dist/{cjs/handlers → handlers}/EventHandler.d.ts +0 -0
  101. /package/dist/{mjs/handlers → handlers}/EventHandler.js +0 -0
  102. /package/dist/{cjs/handlers → handlers}/ExtensionHandler.d.ts +0 -0
  103. /package/dist/{mjs/handlers → handlers}/ExtensionHandler.js +0 -0
  104. /package/dist/{cjs/handlers → handlers}/Handler.d.ts +0 -0
  105. /package/dist/{mjs/handlers → handlers}/Handler.js +0 -0
  106. /package/dist/{cjs/handlers → handlers}/InhibitorHandler.d.ts +0 -0
  107. /package/dist/{mjs/handlers → handlers}/InhibitorHandler.js +0 -0
  108. /package/dist/{cjs/handlers → handlers}/IntegrationHandler.d.ts +0 -0
  109. /package/dist/{mjs/handlers → handlers}/IntegrationHandler.js +0 -0
  110. /package/dist/{cjs/main.d.ts → main.d.ts} +0 -0
  111. /package/dist/{mjs/main.js → main.js} +0 -0
  112. /package/dist/{cjs/models → models}/Arguments.d.ts +0 -0
  113. /package/dist/{mjs/models → models}/Arguments.js +0 -0
  114. /package/dist/{cjs/models → models}/Cooldowns.d.ts +0 -0
  115. /package/dist/{mjs/models → models}/Cooldowns.js +0 -0
  116. /package/dist/{cjs/tools → tools}/XernerxError.d.ts +0 -0
  117. /package/dist/{mjs/tools → tools}/XernerxError.js +0 -0
  118. /package/dist/{cjs/tools → tools}/XernerxIntents.d.ts +0 -0
  119. /package/dist/{mjs/tools → tools}/XernerxIntents.js +0 -0
  120. /package/dist/{cjs/tools → tools}/XernerxLog.d.ts +0 -0
  121. /package/dist/{mjs/tools → tools}/XernerxLog.js +0 -0
  122. /package/dist/{cjs/tools → tools}/XernerxText.d.ts +0 -0
  123. /package/dist/{mjs/tools → tools}/XernerxText.js +0 -0
  124. /package/dist/{cjs/types → types}/extenders.d.ts +0 -0
  125. /package/dist/{mjs/types → types}/extenders.js +0 -0
  126. /package/dist/{cjs/types → types}/interfaces.d.ts +0 -0
  127. /package/dist/{mjs/types → types}/interfaces.js +0 -0
  128. /package/dist/{cjs/types → types}/types.d.ts +0 -0
  129. /package/dist/{mjs/types → types}/types.js +0 -0
  130. /package/dist/{cjs/utils → utils}/ClientUtil.d.ts +0 -0
  131. /package/dist/{mjs/utils → utils}/ClientUtil.js +0 -0
  132. /package/dist/{cjs/utils → utils}/Util.d.ts +0 -0
  133. /package/dist/{mjs/utils → utils}/Util.js +0 -0
  134. /package/dist/{cjs/validators → validators}/commandValidation.d.ts +0 -0
  135. /package/dist/{mjs/validators → validators}/commandValidation.js +0 -0
  136. /package/dist/{cjs/validators → validators}/inhibitorValidations.d.ts +0 -0
  137. /package/dist/{mjs/validators → validators}/inhibitorValidations.js +0 -0
@@ -1,156 +0,0 @@
1
- "use strict";
2
- /** @format */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const discord_js_1 = require("discord.js");
5
- const Util_js_1 = __importDefault(require("./Util.js"));
6
- const XernerxError_js_1 = __importDefault(require("../tools/XernerxError.js"));
7
- const dumfunctions_1 = require("dumfunctions");
8
- class InteractionUtil extends Util_js_1.default {
9
- constructor(client, interaction) {
10
- super(client);
11
- this.interaction = interaction;
12
- this.parsed = {
13
- alias: null,
14
- args: null,
15
- };
16
- }
17
- async send(content) {
18
- if (!content)
19
- throw new XernerxError_js_1.default(`Can't send a message without content.`);
20
- return await this.interaction.channel?.send(content);
21
- }
22
- async reply(content) {
23
- if (!content)
24
- throw new XernerxError_js_1.default(`Can't send a message without content.`);
25
- return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
26
- }
27
- async mimic(user, interaction, options) {
28
- user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
29
- const webhooks = await this.interaction.channel.fetchWebhooks();
30
- const webhook = webhooks.find((wh) => wh.token) ||
31
- (await this.interaction.channel.createWebhook({
32
- name: `${this.client.user?.username}'s mimic webhook.`,
33
- avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
34
- }));
35
- await webhook.send({
36
- content: interaction.content,
37
- username: user.username,
38
- avatarURL: user.displayAvatarURL(),
39
- });
40
- setTimeout(() => {
41
- webhook.delete().catch(() => true);
42
- }, options.timeout);
43
- }
44
- async paginator(embeds, options = {}) {
45
- let buttonRow, menuRow;
46
- if (embeds.length <= 0)
47
- throw new XernerxError_js_1.default(`Can't make a paginator without embeds`);
48
- options = {
49
- type: options.type ?? 'combined',
50
- buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
51
- description: options.description ?? false,
52
- placeholder: options.placeholder ?? 'Change page',
53
- index: options.index ?? 0,
54
- send: options.send ?? false,
55
- filter: options.filter ?? (() => true),
56
- time: options.time ?? 300000,
57
- };
58
- if (options.type == 'button' || options.type == 'combined') {
59
- if (!options.buttons)
60
- throw new XernerxError_js_1.default(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
61
- buttonRow = new discord_js_1.ActionRowBuilder().addComponents(...options.buttons.map((button, i) => new discord_js_1.ButtonBuilder().setCustomId(`${this.interaction.id}-${i}`).setEmoji(button).setStyle(discord_js_1.ButtonStyle.Primary)));
62
- }
63
- if (options.type == 'select-menu' || options.type == 'combined') {
64
- menuRow = new discord_js_1.ActionRowBuilder().addComponents(new discord_js_1.StringSelectMenuBuilder()
65
- .setCustomId(`${this.interaction.id}-select-menu`)
66
- .setPlaceholder(options.placeholder)
67
- .addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` }))));
68
- }
69
- let index = options.index || 0;
70
- return options.send
71
- ? await this.interaction.util.send({
72
- embeds: [embeds[index]],
73
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
74
- })
75
- : await this.interaction.util
76
- .reply({
77
- embeds: [embeds[index]],
78
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
79
- })
80
- .then(async (msg) => {
81
- const collector = this.interaction.channel
82
- ?.createMessageComponentCollector({ time: options.time })
83
- .on('collect', (collect) => {
84
- if (!collect.customId.startsWith(this.interaction.id))
85
- return;
86
- if (collect.customId.endsWith('select-menu')) {
87
- index = Number(collect.values[0]);
88
- collect.update({ embeds: [embeds[index]] });
89
- }
90
- else {
91
- const option = Number(collect.customId.split(/-/)[1]);
92
- let embed = embeds[index];
93
- if (option == 0) {
94
- index = 0;
95
- embed = embeds[index];
96
- collect.update({ embeds: [embed] });
97
- }
98
- if (option == 1) {
99
- index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
100
- embed = embeds[index];
101
- collect.update({ embeds: [embed] });
102
- }
103
- if (option == 2) {
104
- collect.update({ components: [] });
105
- collector?.stop();
106
- }
107
- if (option == 3) {
108
- index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
109
- embed = embeds[index];
110
- collect.update({ embeds: [embed] });
111
- }
112
- if (option == 4) {
113
- index = embeds.length - 1;
114
- embed = embeds[index];
115
- collect.update({ embeds: [embed] });
116
- }
117
- }
118
- })
119
- .on('end', async () => {
120
- this.interaction.editReply({ components: [] });
121
- });
122
- });
123
- }
124
- commands() {
125
- if (this.interaction.type == discord_js_1.InteractionType.ApplicationCommand)
126
- return this.client.commands.slash;
127
- else
128
- return this.client.commands.context;
129
- }
130
- permissionCheck(type, permissions) {
131
- console.log(type);
132
- const missing = [];
133
- for (const permission of permissions) {
134
- if (type == 'user') {
135
- this.interaction.memberPermissions?.has(dumfunctions_1.Style.pascalCase(permission, true)) ? null : missing.push(permission);
136
- }
137
- if (type == 'client') {
138
- this.interaction.guild?.members.me?.permissionsIn(this.interaction.channel?.id).has(dumfunctions_1.Style.pascalCase(permission, true)) ? null : missing.push(permission);
139
- }
140
- }
141
- const command = this.commands().toJSON().find((cmd) => cmd.name == this.parsed.alias?.split(/ +/)[0]);
142
- console.log(type);
143
- if (missing.length) {
144
- this.client.emit(`commandBlock`, this.interaction, {
145
- reason: `missing${dumfunctions_1.Style.pascalCase(type)}Permissions`,
146
- message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
147
- required: permissions,
148
- missing,
149
- }, command || null);
150
- return false;
151
- }
152
- else
153
- return true;
154
- }
155
- }
156
- exports.default = InteractionUtil;
@@ -1,170 +0,0 @@
1
- "use strict";
2
- /** @format */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const discord_js_1 = require("discord.js");
5
- const Util_js_1 = __importDefault(require("./Util.js"));
6
- const XernerxError_js_1 = __importDefault(require("../tools/XernerxError.js"));
7
- const dumfunctions_1 = require("dumfunctions");
8
- class MessageUtil extends Util_js_1.default {
9
- constructor(client, message) {
10
- super(client);
11
- this.message = message;
12
- this.parsed = {
13
- alias: null,
14
- prefix: null,
15
- args: null,
16
- };
17
- }
18
- async send(content) {
19
- if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
20
- const id = this.client.cache.messages.get(this.message.id);
21
- if (!id)
22
- return null;
23
- const msg = await this.message.channel.messages.fetch(id);
24
- msg.edit(content);
25
- return msg;
26
- }
27
- const msg = await this.message.channel.send(content);
28
- this.client.cache.messages.set(this.message.id, msg.id);
29
- return msg;
30
- }
31
- async reply(content) {
32
- if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
33
- const id = this.client.cache.messages.get(this.message.id);
34
- if (!id)
35
- return null;
36
- const msg = await this.message.channel.messages.fetch(id);
37
- msg.edit(content);
38
- return msg;
39
- }
40
- const msg = await this.message.reply(content);
41
- this.client.cache.messages.set(this.message.id, msg.id);
42
- return msg;
43
- }
44
- async mimic(user, message, options) {
45
- user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
46
- const webhooks = await this.message.channel.fetchWebhooks();
47
- const webhook = webhooks.find((wh) => wh.token) ||
48
- (await this.message.channel.createWebhook({
49
- name: `${this.client.user?.username}'s mimic webhook.`,
50
- avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
51
- }));
52
- await webhook.send({
53
- content: message.content,
54
- username: user.username,
55
- avatarURL: user.displayAvatarURL(),
56
- });
57
- setTimeout(() => {
58
- webhook.delete().catch(() => true);
59
- }, options.timeout);
60
- }
61
- async paginator(embeds, options = {}) {
62
- let buttonRow, menuRow;
63
- if (embeds.length <= 0)
64
- throw new XernerxError_js_1.default(`Can't make a paginator without embeds`);
65
- options = {
66
- type: options.type ?? 'combined',
67
- buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
68
- description: options.description ?? false,
69
- placeholder: options.placeholder ?? 'Change page',
70
- index: options.index ?? 0,
71
- send: options.send ?? false,
72
- filter: options.filter ?? (() => true),
73
- time: options.time ?? 300000,
74
- };
75
- if (options.type == 'button' || options.type == 'combined') {
76
- if (!options.buttons)
77
- throw new XernerxError_js_1.default(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
78
- buttonRow = new discord_js_1.ActionRowBuilder().addComponents(...options.buttons.map((button, i) => new discord_js_1.ButtonBuilder().setCustomId(`${this.message.id}-${i}`).setEmoji(button).setStyle(discord_js_1.ButtonStyle.Primary)));
79
- }
80
- if (options.type == 'select-menu' || options.type == 'combined') {
81
- menuRow = new discord_js_1.ActionRowBuilder().addComponents(new discord_js_1.StringSelectMenuBuilder()
82
- .setCustomId(`${this.message.id}-select-menu`)
83
- .setPlaceholder(options.placeholder)
84
- .addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` }))));
85
- }
86
- let index = options.index || 0;
87
- return options.send
88
- ? await this.message.util.send({
89
- embeds: [embeds[index]],
90
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
91
- })
92
- : await this.message.util
93
- .reply({
94
- embeds: [embeds[index]],
95
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
96
- })
97
- .then(async (msg) => {
98
- const collector = this.message.channel
99
- ?.createMessageComponentCollector({ time: options.time })
100
- .on('collect', (collect) => {
101
- if (!collect.customId.startsWith(this.message.id))
102
- return;
103
- if (collect.customId.endsWith('select-menu')) {
104
- index = Number(collect.values[0]);
105
- collect.update({ embeds: [embeds[index]] });
106
- }
107
- else {
108
- const option = Number(collect.customId.split(/-/)[1]);
109
- let embed = embeds[index];
110
- if (option == 0) {
111
- index = 0;
112
- embed = embeds[index];
113
- collect.update({ embeds: [embed] });
114
- }
115
- if (option == 1) {
116
- index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
117
- embed = embeds[index];
118
- collect.update({ embeds: [embed] });
119
- }
120
- if (option == 2) {
121
- collect.update({ components: [] });
122
- collector?.stop();
123
- }
124
- if (option == 3) {
125
- index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
126
- embed = embeds[index];
127
- collect.update({ embeds: [embed] });
128
- }
129
- if (option == 4) {
130
- index = embeds.length - 1;
131
- embed = embeds[index];
132
- collect.update({ embeds: [embed] });
133
- }
134
- }
135
- })
136
- .on('end', async () => {
137
- await msg?.edit({ components: [] });
138
- });
139
- });
140
- }
141
- commands() {
142
- return this.client.commands.message;
143
- }
144
- permissionCheck(type, permissions) {
145
- console.log(type);
146
- const missing = [];
147
- for (const permission of permissions) {
148
- if (type == 'user') {
149
- this.message.member?.permissionsIn(this.message.channel.id).has(dumfunctions_1.Style.pascalCase(permission, true)) ? null : missing.push(permission);
150
- }
151
- if (type == 'client') {
152
- this.message.guild?.members.me?.permissionsIn(this.message.channel.id).has(dumfunctions_1.Style.pascalCase(permission, true)) ? null : missing.push(permission);
153
- }
154
- }
155
- const command = this.commands().find((cmd) => cmd.name == this.parsed.alias || cmd.aliases?.includes(this.parsed.alias));
156
- console.log(type);
157
- if (missing.length) {
158
- this.client.emit(`commandBlock`, this.message, {
159
- reason: `missing${dumfunctions_1.Style.pascalCase(type)}Permissions`,
160
- message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
161
- required: permissions,
162
- missing,
163
- }, command || null);
164
- return false;
165
- }
166
- else
167
- return true;
168
- }
169
- }
170
- exports.default = MessageUtil;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- /** @format */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const XernerxText_js_1 = __importDefault(require("../tools/XernerxText.js"));
5
- class Util {
6
- constructor(client) {
7
- this.client = client;
8
- this.text = new XernerxText_js_1.default();
9
- }
10
- async delay(time) {
11
- return await new Promise((resolve) => setTimeout(resolve, time));
12
- }
13
- }
14
- exports.default = Util;
@@ -1,127 +0,0 @@
1
- "use strict";
2
- /** @format */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const discord_js_1 = require("discord.js");
5
- const dumfunctions_1 = require("dumfunctions");
6
- var CommandTypes;
7
- (function (CommandTypes) {
8
- CommandTypes["SlashCommand"] = "slash";
9
- CommandTypes["MessageCommand"] = "message";
10
- CommandTypes["ContextCommand"] = "context";
11
- })(CommandTypes || (CommandTypes = {}));
12
- async function commandValidation(event, command) {
13
- const client = event.client;
14
- if (command.ignore?.owner && client.settings.ownerId?.includes(event.user.id))
15
- return false;
16
- const cooldownTime = command.cooldown || client.modules.options?.[CommandTypes[command.filetype]]?.cooldown || client.cooldown?.default || 0;
17
- const cooldown = {
18
- id: event.user.id,
19
- command: command.name,
20
- createdTimestamp: Number(Date.now()) + cooldownTime,
21
- };
22
- const clientPermissions = command.permissions?.client || client.modules.options?.[CommandTypes[command.filetype]]?.permissions?.client || client.settings.permissions?.client || [];
23
- const userPermissions = command.permissions?.user || client.modules.options?.[CommandTypes[command.filetype]]?.permissions?.user || client.settings.permissions?.user || [];
24
- if (!client.cooldowns.collections.commands.has(`${event.user.id}-${command.name}`)) {
25
- client.cooldowns.collections.commands.set(`${event.user.id}-${command.name}`, cooldown);
26
- setTimeout(() => {
27
- client.cooldowns.collections.commands.delete(`${event.user.id}-${command.name}`);
28
- }, cooldownTime);
29
- }
30
- else {
31
- const user = client.cooldowns.collections.commands.get(`${event.user.id}-${command.name}`);
32
- const time = (user?.createdTimestamp || 0) - Number(Date.now());
33
- return emit(event, {
34
- reason: 'cooldown',
35
- message: `You are on cooldown for \`${command.name}\`, wait another \`${Math.round(time / 10) / 100}s\``,
36
- startedAt: user.createdTimestamp,
37
- endsAt: user.createdTimestamp + time,
38
- time,
39
- }, command);
40
- }
41
- if (command.channel && event.channel?.type !== undefined && event.channel?.type >= 0) {
42
- if (!command.channel.includes(discord_js_1.ChannelType[event.channel?.type]))
43
- return await emit(event, {
44
- reason: 'invalidChannel',
45
- message: `\`${command.name}\` can only be used in ${command.channel.join(', ')} channels`,
46
- channels: command.channel,
47
- }, command);
48
- }
49
- if ((command.ignore?.channels?.length || 0) > 0 && command.ignore?.channels?.includes(event.channel?.id))
50
- return true;
51
- if ((command.ignore?.guilds?.length || 0) > 0 && command.ignore?.guilds?.includes(event.guild?.id))
52
- return true;
53
- if ((command.ignore?.users?.length || 0) > 0 && command.ignore?.users?.includes(event.user.id))
54
- return true;
55
- if (command.ignore?.voice && event.member?.voice?.channel)
56
- return await emit(event, {
57
- reason: 'inVoice',
58
- message: `\`${command.name}\` cannot be ran while in voice chat`,
59
- }, command);
60
- if (command.strict?.owner && !client.settings.ownerId.includes(event.user.id))
61
- return await emit(event, {
62
- reason: 'notADeveloper',
63
- message: `\`${command.name}\` is a developer command`,
64
- owners: client.settings.ownerId,
65
- }, command);
66
- if ((command.strict?.channels?.length || 0) > 0 && !command.strict?.channels?.includes(event.channel?.id))
67
- return await emit(event, {
68
- reason: 'channelRestricted',
69
- message: `\`${command.name}\` cannot be ran in this channel`,
70
- channels: command.strict?.channels,
71
- }, command);
72
- if ((command.strict?.guilds?.length || 0) > 0 && !command.strict?.guilds?.includes(event.guild?.id))
73
- return await emit(event, {
74
- reason: 'guildRestricted',
75
- message: `\`${command.name}\` cannot be ran in this guild`,
76
- guilds: command.strict?.guilds,
77
- }, command);
78
- if ((command.strict?.users?.length || 0) > 0 && !command.strict?.users?.includes(event.user.id))
79
- return await emit(event, {
80
- reason: 'userRestricted',
81
- message: `\`${command.name}\` cannot be ran by you`,
82
- users: command.strict?.users,
83
- }, command);
84
- if (command.strict?.voice && !event.member?.voice?.channel)
85
- return await emit(event, {
86
- reason: 'voiceRestricted',
87
- message: `\`${command.name}\` cannot be ran while not in voice chat`,
88
- }, command);
89
- if (command.permissions?.dm == false && event.channel?.type === discord_js_1.ChannelType.DM)
90
- return await emit(event, {
91
- reason: 'DMRestricted',
92
- message: `\`${command.name}\` can't be used in a DM Channel`,
93
- }, command);
94
- if (userPermissions.length) {
95
- const missing = [];
96
- userPermissions.map((permission) => event.guild?.members.me?.permissionsIn(event.channel?.id).has(dumfunctions_1.Style.pascalCase(permission, true)) ? null : missing.push(permission));
97
- if (missing.length)
98
- return await emit(event, {
99
- reason: 'missingUserPermissions',
100
- message: `You are missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
101
- required: userPermissions,
102
- missing,
103
- }, command);
104
- }
105
- if (clientPermissions.length) {
106
- const missing = [];
107
- clientPermissions.map((permission) => event.guild?.members.me?.permissionsIn(event.channel?.id).has(dumfunctions_1.Style.pascalCase(permission, true)) ? null : missing.push(permission));
108
- if (missing.length)
109
- return await emit(event, {
110
- reason: 'missingClientPermissions',
111
- message: `I am missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
112
- required: clientPermissions,
113
- missing,
114
- }, command);
115
- }
116
- if ((!command.global || !client.settings.global) && client.settings.local !== event.guild?.id)
117
- return await emit(event, {
118
- reason: 'local',
119
- message: `\`${command.name}\` is not globally deployed`,
120
- }, command);
121
- return false;
122
- }
123
- exports.default = commandValidation;
124
- async function emit(event, info, command) {
125
- event.client.emit('commandBlock', event, info, command);
126
- return true;
127
- }
@@ -1,49 +0,0 @@
1
- "use strict";
2
- /** @format */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.inhibitorArguments = exports.inhibitorValidation = void 0;
5
- async function inhibitorValidation(event, args, cmd, type) {
6
- const client = event.client;
7
- const inhibits = [];
8
- for (const [name, inhibitor] of client.inhibitors) {
9
- if (type == 'pre')
10
- if (Boolean(await inhibitor.pre(event, (await inhibitorArguments(event, cmd || null, inhibitor.type))))) {
11
- inhibits.push(name);
12
- }
13
- if (type == 'check')
14
- if (Boolean(await inhibitor.check(event, args || null, (await inhibitorArguments(event, cmd || null, inhibitor.type))))) {
15
- inhibits.push(name);
16
- }
17
- if (type == 'post')
18
- if (Boolean(await inhibitor.post(event, args || null, (await inhibitorArguments(event, cmd || null, inhibitor.type))))) {
19
- inhibits.push(name);
20
- }
21
- }
22
- return !!inhibits.length;
23
- }
24
- exports.inhibitorValidation = inhibitorValidation;
25
- function inhibitorArguments(event, cmd, type) {
26
- switch (type) {
27
- case 'channel':
28
- return event.channel || null;
29
- case 'command':
30
- return cmd || null;
31
- case 'contextCommand':
32
- return cmd || null;
33
- case 'guild':
34
- return event.guild || null;
35
- case 'interaction':
36
- return null;
37
- case 'member':
38
- return event.member || null;
39
- case 'message':
40
- return null;
41
- case 'messageCommand':
42
- return cmd || null;
43
- case 'slashCommand':
44
- return cmd || null;
45
- case 'user':
46
- return event.user || null;
47
- }
48
- }
49
- exports.inhibitorArguments = inhibitorArguments;
@@ -1,53 +0,0 @@
1
- /** @format */
2
- import { ContextMenuCommandBuilder } from 'discord.js';
3
- import { XernerxMessageContextInteraction, XernerxUserContextInteraction, XernerxClientType } from '../types/extenders.js';
4
- import { ContextCommandArguments, ContextCommandOptions } from '../types/interfaces.js';
5
- import InteractionUtil from '../utils/InteractionUtil.js';
6
- export default class XernerxContextCommand {
7
- readonly id: string;
8
- readonly data: ContextMenuCommandBuilder;
9
- readonly name: string;
10
- readonly type: 'user' | 'message';
11
- readonly description: string | null | undefined;
12
- readonly usage: string | null | undefined;
13
- readonly info: string | null | undefined;
14
- readonly category: string | null | undefined;
15
- readonly cooldown: number | null | undefined;
16
- readonly channel: ("GuildText" | "DM" | "GuildVoice" | "GroupDM" | "GuildCategory" | "GuildAnnouncement" | "AnnouncementThread" | "PublicThread" | "PrivateThread" | "GuildStageVoice" | "GuildDirectory" | "GuildForum" | "GuildMedia" | "GuildNews" | "GuildNewsThread" | "GuildPublicThread" | "GuildPrivateThread")[] | null;
17
- readonly global: boolean | undefined;
18
- readonly ignore: {
19
- owner?: boolean | undefined;
20
- users?: string[] | undefined;
21
- channels?: string[] | undefined;
22
- guilds?: string[] | undefined;
23
- voice?: boolean | undefined;
24
- } | undefined;
25
- readonly strict: {
26
- owner?: boolean | undefined;
27
- users?: string[] | undefined;
28
- channels?: string[] | undefined;
29
- guilds?: string[] | undefined;
30
- voice?: boolean | undefined;
31
- } | undefined;
32
- readonly permissions: {
33
- user?: string[] | import("../main.js").PermissionNames[] | null | undefined;
34
- client?: string[] | import("../main.js").PermissionNames[] | null | undefined;
35
- dm?: boolean | undefined;
36
- } | undefined;
37
- readonly defer: {
38
- reply?: boolean | undefined;
39
- ephemeral?: boolean | undefined;
40
- fetchReply?: boolean | undefined;
41
- } | undefined;
42
- readonly filetype: 'ContextCommand';
43
- readonly filepath: string;
44
- readonly client: XernerxClientType;
45
- util: InteractionUtil;
46
- constructor(id: string, options: ContextCommandOptions);
47
- /**
48
- * @description the execution of the command
49
- * @param interaction - Interaction event emitted on command
50
- * @param args - The arguments parsed with the command, if any
51
- */
52
- exec(interaction: XernerxUserContextInteraction | XernerxMessageContextInteraction, args: ContextCommandArguments<'user' | 'message'>): Promise<any>;
53
- }
@@ -1,25 +0,0 @@
1
- /** @format */
2
- import { XernerxEventOptions } from '../types/interfaces.js';
3
- import { XernerxEventType } from '../types/types.js';
4
- import { XernerxClientType } from '../types/extenders.js';
5
- /**
6
- * @description - The event builder for events.
7
- * @param {String} id - The unique ID of the event.
8
- * @param {EventOptions} options - The event options.
9
- */
10
- export default class XernerxEvent {
11
- readonly id: string;
12
- readonly name: XernerxEventType | string;
13
- readonly emitter?: 'client' | 'process' | string;
14
- readonly type?: 'discord' | string;
15
- readonly once?: boolean;
16
- readonly filetype: 'Event';
17
- readonly filepath: string;
18
- readonly client: XernerxClientType;
19
- constructor(id: string, options: XernerxEventOptions);
20
- /**
21
- * @description run your custom event here.
22
- * @param any - there can be all kinds of parameters on events.
23
- */
24
- run(...args: any): Promise<any>;
25
- }
@@ -1,29 +0,0 @@
1
- /** @format */
2
- import { XernerxInhibitorOptions, MessageCommandArguments, SlashCommandArguments, ContextCommandArguments } from '../types/interfaces.js';
3
- import { InhibitorType, XernerxInteraction } from '../types/types.js';
4
- import { XernerxClientType, XernerxMessage, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
5
- import XernerxContextCommand from '../build/XernerxContextCommand.js';
6
- import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
7
- import XernerxMessageCommand from '../build/XernerxMessageCommand.js';
8
- /**
9
- * @description - The inhibitor builder for inhibitors.
10
- * @param {String} id - The unique ID of the inhibitor.
11
- * @param {InhibitorOptions} options - The inhibitor options.
12
- */
13
- export default class XernerxInhibitor {
14
- readonly id: string;
15
- readonly name: string;
16
- readonly type: InhibitorType;
17
- readonly filetype: 'Inhibitor';
18
- readonly filepath: string;
19
- readonly client: XernerxClientType;
20
- constructor(id: string, options: XernerxInhibitorOptions);
21
- pre(interaction: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args: any): void;
22
- /**
23
- * @description The check rule
24
- * @param interaction - The interaction with the inhibitor, can be message and interaction
25
- * @param args - The arguments parsed with this command
26
- */
27
- check<T extends XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>>(interaction: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args: (T extends XernerxMessage ? MessageCommandArguments : T extends XernerxSlashInteraction ? SlashCommandArguments : T extends XernerxUserContextInteraction ? ContextCommandArguments<'user' | 'message'> : never) | null, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand): Promise<any>;
28
- post<T extends XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>>(interaction: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args: (T extends XernerxMessage ? MessageCommandArguments : T extends XernerxSlashInteraction ? SlashCommandArguments : T extends XernerxUserContextInteraction ? ContextCommandArguments<'user' | 'message'> : never) | null, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand): Promise<any>;
29
- }