xernerx 4.17.9 → 5.0.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 (78) hide show
  1. package/README.md +14 -67
  2. package/dist/main.cjs +63 -0
  3. package/dist/main.cjs.map +1 -0
  4. package/dist/main.d.cts +21 -0
  5. package/dist/main.d.ts +18 -37
  6. package/dist/main.js +23 -42
  7. package/dist/main.js.map +1 -0
  8. package/package.json +63 -48
  9. package/src/main.ts +26 -0
  10. package/dist/build/XernerxContextCommand.d.ts +0 -54
  11. package/dist/build/XernerxContextCommand.js +0 -121
  12. package/dist/build/XernerxEvent.d.ts +0 -21
  13. package/dist/build/XernerxEvent.js +0 -27
  14. package/dist/build/XernerxInhibitor.d.ts +0 -29
  15. package/dist/build/XernerxInhibitor.js +0 -27
  16. package/dist/build/XernerxMessageCommand.d.ts +0 -58
  17. package/dist/build/XernerxMessageCommand.js +0 -119
  18. package/dist/build/XernerxSlashCommand.d.ts +0 -70
  19. package/dist/build/XernerxSlashCommand.js +0 -178
  20. package/dist/client/XernerxClient.d.ts +0 -64
  21. package/dist/client/XernerxClient.js +0 -109
  22. package/dist/client/XernerxShardClient.d.ts +0 -21
  23. package/dist/client/XernerxShardClient.js +0 -54
  24. package/dist/functions/deploy.d.ts +0 -3
  25. package/dist/functions/deploy.js +0 -63
  26. package/dist/functions/load.d.ts +0 -4
  27. package/dist/functions/load.js +0 -35
  28. package/dist/functions/reload.d.ts +0 -3
  29. package/dist/functions/reload.js +0 -30
  30. package/dist/functions/setPresence.d.ts +0 -4
  31. package/dist/functions/setPresence.js +0 -21
  32. package/dist/handlers/CommandHandler.d.ts +0 -16
  33. package/dist/handlers/CommandHandler.js +0 -351
  34. package/dist/handlers/EventHandler.d.ts +0 -11
  35. package/dist/handlers/EventHandler.js +0 -84
  36. package/dist/handlers/ExtensionHandler.d.ts +0 -9
  37. package/dist/handlers/ExtensionHandler.js +0 -29
  38. package/dist/handlers/Handler.d.ts +0 -26
  39. package/dist/handlers/Handler.js +0 -64
  40. package/dist/handlers/InhibitorHandler.d.ts +0 -9
  41. package/dist/handlers/InhibitorHandler.js +0 -31
  42. package/dist/handlers/IntegrationHandler.d.ts +0 -15
  43. package/dist/handlers/IntegrationHandler.js +0 -26
  44. package/dist/models/Arguments.d.ts +0 -9
  45. package/dist/models/Arguments.js +0 -154
  46. package/dist/models/Cooldowns.d.ts +0 -11
  47. package/dist/models/Cooldowns.js +0 -33
  48. package/dist/models/XernerxEntitlement.d.ts +0 -45
  49. package/dist/models/XernerxEntitlement.js +0 -57
  50. package/dist/models/XernerxUser.d.ts +0 -14
  51. package/dist/models/XernerxUser.js +0 -13
  52. package/dist/tools/XernerxError.d.ts +0 -7
  53. package/dist/tools/XernerxError.js +0 -11
  54. package/dist/tools/XernerxIntents.d.ts +0 -6
  55. package/dist/tools/XernerxIntents.js +0 -26
  56. package/dist/tools/XernerxLog.d.ts +0 -31
  57. package/dist/tools/XernerxLog.js +0 -139
  58. package/dist/tools/XernerxText.d.ts +0 -31
  59. package/dist/tools/XernerxText.js +0 -94
  60. package/dist/types/extenders.d.ts +0 -76
  61. package/dist/types/extenders.js +0 -2
  62. package/dist/types/interfaces.d.ts +0 -258
  63. package/dist/types/interfaces.js +0 -2
  64. package/dist/types/types.d.ts +0 -12
  65. package/dist/types/types.js +0 -2
  66. package/dist/utils/ClientUtil.d.ts +0 -20
  67. package/dist/utils/ClientUtil.js +0 -123
  68. package/dist/utils/InteractionUtil.d.ts +0 -25
  69. package/dist/utils/InteractionUtil.js +0 -153
  70. package/dist/utils/MessageUtil.d.ts +0 -26
  71. package/dist/utils/MessageUtil.js +0 -167
  72. package/dist/utils/Util.d.ts +0 -12
  73. package/dist/utils/Util.js +0 -11
  74. package/dist/validators/commandValidation.d.ts +0 -7
  75. package/dist/validators/commandValidation.js +0 -124
  76. package/dist/validators/inhibitorValidations.d.ts +0 -9
  77. package/dist/validators/inhibitorValidations.js +0 -44
  78. package/tsup.config.ts +0 -19
@@ -1,153 +0,0 @@
1
- /** @format */
2
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, InteractionType, StringSelectMenuBuilder, } from 'discord.js';
3
- import Util from './Util.js';
4
- import XernerxError from '../tools/XernerxError.js';
5
- import { Style } from 'dumfunctions';
6
- export default class InteractionUtil extends Util {
7
- constructor(client, interaction) {
8
- super(client);
9
- this.interaction = interaction;
10
- this.parsed = {
11
- alias: null,
12
- args: null,
13
- };
14
- }
15
- async send(content) {
16
- if (!content)
17
- throw new XernerxError(`Can't send a message without content.`);
18
- return await this.interaction.channel?.send(content);
19
- }
20
- async reply(content) {
21
- if (!content)
22
- throw new XernerxError(`Can't send a message without content.`);
23
- return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
24
- }
25
- async mimic(user, interaction, options) {
26
- user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
27
- const webhooks = await this.interaction.channel.fetchWebhooks();
28
- const webhook = webhooks.find((wh) => wh.token) ||
29
- (await this.interaction.channel.createWebhook({
30
- name: `${this.client.user?.username}'s mimic webhook.`,
31
- avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
32
- }));
33
- await webhook.send({
34
- content: interaction.content,
35
- username: user.username,
36
- avatarURL: user.displayAvatarURL(),
37
- });
38
- setTimeout(() => {
39
- webhook.delete().catch(() => true);
40
- }, options.timeout);
41
- }
42
- async paginator(embeds, options = {}) {
43
- let buttonRow, menuRow;
44
- if (embeds.length <= 0)
45
- throw new XernerxError(`Can't make a paginator without embeds`);
46
- options = {
47
- type: options.type ?? 'combined',
48
- buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
49
- description: options.description ?? false,
50
- placeholder: options.placeholder ?? 'Change page',
51
- index: options.index ?? 0,
52
- send: options.send ?? false,
53
- filter: options.filter ?? (() => true),
54
- time: options.time ?? 300000,
55
- };
56
- if (options.type == 'button' || options.type == 'combined') {
57
- if (!options.buttons)
58
- throw new XernerxError(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
59
- buttonRow = new ActionRowBuilder().addComponents(...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.interaction.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary)));
60
- }
61
- if (options.type == 'select-menu' || options.type == 'combined') {
62
- menuRow = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder()
63
- .setCustomId(`${this.interaction.id}-select-menu`)
64
- .setPlaceholder(options.placeholder)
65
- .addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` }))));
66
- }
67
- let index = options.index || 0;
68
- return options.send
69
- ? await this.interaction.util.send({
70
- embeds: [embeds[index]],
71
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
72
- })
73
- : await this.interaction.util
74
- .reply({
75
- embeds: [embeds[index]],
76
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
77
- })
78
- .then(async (msg) => {
79
- const collector = this.interaction.channel
80
- ?.createMessageComponentCollector({ time: options.time })
81
- .on('collect', (collect) => {
82
- if (!collect.customId.startsWith(this.interaction.id))
83
- return;
84
- if (collect.customId.endsWith('select-menu')) {
85
- index = Number(collect.values[0]);
86
- collect.update({ embeds: [embeds[index]] });
87
- }
88
- else {
89
- const option = Number(collect.customId.split(/-/)[1]);
90
- let embed = embeds[index];
91
- if (option == 0) {
92
- index = 0;
93
- embed = embeds[index];
94
- collect.update({ embeds: [embed] });
95
- }
96
- if (option == 1) {
97
- index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
98
- embed = embeds[index];
99
- collect.update({ embeds: [embed] });
100
- }
101
- if (option == 2) {
102
- collect.update({ components: [] });
103
- collector?.stop();
104
- }
105
- if (option == 3) {
106
- index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
107
- embed = embeds[index];
108
- collect.update({ embeds: [embed] });
109
- }
110
- if (option == 4) {
111
- index = embeds.length - 1;
112
- embed = embeds[index];
113
- collect.update({ embeds: [embed] });
114
- }
115
- }
116
- })
117
- .on('end', async () => {
118
- this.interaction.editReply({ components: [] });
119
- });
120
- });
121
- }
122
- commands() {
123
- if (this.interaction.type == InteractionType.ApplicationCommand)
124
- return this.client.commands.slash;
125
- else
126
- return this.client.commands.context;
127
- }
128
- permissionCheck(type, permissions, emit = true) {
129
- const missing = [];
130
- for (const permission of permissions) {
131
- if (type == 'user') {
132
- this.interaction.memberPermissions?.has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
133
- }
134
- if (type == 'client') {
135
- this.interaction.guild?.members.me?.permissionsIn(this.interaction.channel?.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
136
- }
137
- }
138
- const command = this.commands().toJSON().find((cmd) => cmd.name == this.parsed.alias?.split(/ +/)[0]);
139
- if (missing.length && emit) {
140
- this.client.emit(`commandBlock`, this.interaction, {
141
- reason: `missing${Style.pascalCase(type)}Permissions`,
142
- message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
143
- required: permissions,
144
- missing,
145
- }, command || null);
146
- return false;
147
- }
148
- else if (missing.length && !emit)
149
- return missing;
150
- else
151
- return true;
152
- }
153
- }
@@ -1,26 +0,0 @@
1
- /** @format */
2
- import { EmbedBuilder, MessageCreateOptions, MessageEditOptions, MessagePayload, MessageReplyOptions } from 'discord.js';
3
- import XernerxClient from '../client/XernerxClient.js';
4
- import { XernerxMessage, XernerxUser } from '../types/extenders.js';
5
- import Util from './Util.js';
6
- import { PaginatorOptions } from '../types/interfaces.js';
7
- import { PermissionNames } from '../main.js';
8
- type MimicOptions = {
9
- timeout: number;
10
- };
11
- export default class MessageUtil extends Util {
12
- private readonly message;
13
- parsed: {
14
- alias: string | null;
15
- prefix: string | null;
16
- args: Record<string, unknown> | null;
17
- };
18
- constructor(client: XernerxClient, message: XernerxMessage);
19
- send(content: any): Promise<any>;
20
- reply(content: string | MessagePayload | MessageReplyOptions | MessageEditOptions): Promise<import("discord.js").Message<boolean> | null>;
21
- mimic(user: XernerxUser | string, message: MessageCreateOptions, options: MimicOptions): Promise<void>;
22
- paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<any>;
23
- commands(): import("discord.js").Collection<string, import("../main.js").XernerxMessageCommand>;
24
- permissionCheck(type: 'user' | 'client', permissions: Array<PermissionNames>, emit?: boolean): boolean | string[];
25
- }
26
- export {};
@@ -1,167 +0,0 @@
1
- /** @format */
2
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, } from 'discord.js';
3
- import Util from './Util.js';
4
- import XernerxError from '../tools/XernerxError.js';
5
- import { Style } from 'dumfunctions';
6
- export default class MessageUtil extends Util {
7
- constructor(client, message) {
8
- super(client);
9
- this.message = message?.message || message;
10
- this.parsed = {
11
- alias: null,
12
- prefix: null,
13
- args: null,
14
- };
15
- }
16
- async send(content) {
17
- if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
18
- const id = this.client.cache.messages.get(this.message.id);
19
- if (!id)
20
- return null;
21
- const msg = await this.message.channel.messages.fetch(id);
22
- msg.edit(content);
23
- return msg;
24
- }
25
- const msg = await this.message.channel.send(content);
26
- this.client.cache.messages.set(this.message.id, msg.id);
27
- return msg;
28
- }
29
- async reply(content) {
30
- if (this.client.cache.messages.has(this.message.id) && this.client.modules.options.message?.handleEdits) {
31
- const id = this.client.cache.messages.get(this.message.id);
32
- if (!id)
33
- return null;
34
- const msg = await this.message.channel.messages.fetch(id);
35
- msg.edit(content);
36
- return msg;
37
- }
38
- const msg = await this.message.reply(content);
39
- this.client.cache.messages.set(this.message.id, msg.id);
40
- return msg;
41
- }
42
- async mimic(user, message, options) {
43
- user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
44
- const webhooks = await this.message.channel.fetchWebhooks();
45
- const webhook = webhooks.find((wh) => wh.token) ||
46
- (await this.message.channel.createWebhook({
47
- name: `${this.client.user?.username}'s mimic webhook.`,
48
- avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
49
- }));
50
- await webhook.send({
51
- content: message.content,
52
- username: user.username,
53
- avatarURL: user.displayAvatarURL(),
54
- });
55
- setTimeout(() => {
56
- webhook.delete().catch(() => true);
57
- }, options.timeout);
58
- }
59
- async paginator(embeds, options = {}) {
60
- let buttonRow, menuRow;
61
- if (embeds.length <= 0)
62
- throw new XernerxError(`Can't make a paginator without embeds`);
63
- options = {
64
- type: options.type ?? 'combined',
65
- buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
66
- description: options.description ?? false,
67
- placeholder: options.placeholder ?? 'Change page',
68
- index: options.index ?? 0,
69
- send: options.send ?? false,
70
- filter: options.filter ?? (() => true),
71
- time: options.time ?? 300000,
72
- };
73
- if (options.type == 'button' || options.type == 'combined') {
74
- if (!options.buttons)
75
- throw new XernerxError(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
76
- buttonRow = new ActionRowBuilder().addComponents(...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.message.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary)));
77
- }
78
- if (options.type == 'select-menu' || options.type == 'combined') {
79
- menuRow = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder()
80
- .setCustomId(`${this.message.id}-select-menu`)
81
- .setPlaceholder(options.placeholder)
82
- .addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` }))));
83
- }
84
- let index = options.index || 0;
85
- return options.send
86
- ? await this.message.util.send({
87
- embeds: [embeds[index]],
88
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
89
- })
90
- : await this.message.util
91
- .reply({
92
- embeds: [embeds[index]],
93
- components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
94
- })
95
- .then(async (msg) => {
96
- const collector = this.message.channel
97
- ?.createMessageComponentCollector({ time: options.time })
98
- .on('collect', (collect) => {
99
- if (!collect.customId.startsWith(this.message.id))
100
- return;
101
- if (collect.customId.endsWith('select-menu')) {
102
- index = Number(collect.values[0]);
103
- collect.update({ embeds: [embeds[index]] });
104
- }
105
- else {
106
- const option = Number(collect.customId.split(/-/)[1]);
107
- let embed = embeds[index];
108
- if (option == 0) {
109
- index = 0;
110
- embed = embeds[index];
111
- collect.update({ embeds: [embed] });
112
- }
113
- if (option == 1) {
114
- index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
115
- embed = embeds[index];
116
- collect.update({ embeds: [embed] });
117
- }
118
- if (option == 2) {
119
- collect.update({ components: [] });
120
- collector?.stop();
121
- }
122
- if (option == 3) {
123
- index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
124
- embed = embeds[index];
125
- collect.update({ embeds: [embed] });
126
- }
127
- if (option == 4) {
128
- index = embeds.length - 1;
129
- embed = embeds[index];
130
- collect.update({ embeds: [embed] });
131
- }
132
- }
133
- })
134
- .on('end', async () => {
135
- await msg?.edit({ components: [] });
136
- });
137
- });
138
- }
139
- commands() {
140
- return this.client.commands.message;
141
- }
142
- permissionCheck(type, permissions, emit = true) {
143
- const missing = [];
144
- for (const permission of permissions) {
145
- if (type == 'user') {
146
- this.message.member?.permissionsIn(this.message.channel.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
147
- }
148
- if (type == 'client') {
149
- this.message.guild?.members.me?.permissionsIn(this.message.channel.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission);
150
- }
151
- }
152
- const command = this.commands().find((cmd) => cmd.name == this.parsed.alias || cmd.aliases?.includes(this.parsed.alias));
153
- if (missing.length && emit) {
154
- this.client.emit(`commandBlock`, this.message, {
155
- reason: `missing${Style.pascalCase(type)}Permissions`,
156
- message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
157
- required: permissions,
158
- missing,
159
- }, command || null);
160
- return false;
161
- }
162
- else if (missing.length && !emit)
163
- return missing;
164
- else
165
- return true;
166
- }
167
- }
@@ -1,12 +0,0 @@
1
- /** @format */
2
- import XernerxClient from '../client/XernerxClient.js';
3
- import XernerxText from '../tools/XernerxText.js';
4
- export default class Util {
5
- readonly client: XernerxClient<{
6
- [index: string]: any;
7
- [index: number]: any;
8
- }>;
9
- readonly text: XernerxText;
10
- constructor(client: XernerxClient);
11
- delay(time: number): Promise<unknown>;
12
- }
@@ -1,11 +0,0 @@
1
- /** @format */
2
- import XernerxText from '../tools/XernerxText.js';
3
- export default class Util {
4
- constructor(client) {
5
- this.client = client;
6
- this.text = new XernerxText();
7
- }
8
- async delay(time) {
9
- return await new Promise((resolve) => setTimeout(resolve, time));
10
- }
11
- }
@@ -1,7 +0,0 @@
1
- /** @format */
2
- import XernerxContextCommand from '../build/XernerxContextCommand.js';
3
- import MessageCommandBuilder from '../build/XernerxMessageCommand.js';
4
- import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
5
- import { XernerxMessage, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
6
- import { XernerxInteraction } from '../types/types.js';
7
- export default function commandValidation(event: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction> | XernerxMessage, command: MessageCommandBuilder | XernerxSlashCommand | XernerxContextCommand): Promise<boolean>;
@@ -1,124 +0,0 @@
1
- /** @format */
2
- import { ChannelType } from 'discord.js';
3
- import { Style } from 'dumfunctions';
4
- var CommandTypes;
5
- (function (CommandTypes) {
6
- CommandTypes["SlashCommand"] = "slash";
7
- CommandTypes["MessageCommand"] = "message";
8
- CommandTypes["ContextCommand"] = "context";
9
- })(CommandTypes || (CommandTypes = {}));
10
- export default async function commandValidation(event, command) {
11
- const client = event.client;
12
- if (command.ignore?.owner && client.settings.ownerId?.includes(event.user.id))
13
- return false;
14
- const cooldownTime = command.cooldown || client.modules.options?.[CommandTypes[command.filetype]]?.cooldown || client.cooldown?.default || 0;
15
- const cooldown = {
16
- id: event.user.id,
17
- command: command.name,
18
- createdTimestamp: Number(Date.now()) + cooldownTime,
19
- };
20
- const clientPermissions = command.permissions?.client || client.modules.options?.[CommandTypes[command.filetype]]?.permissions?.client || client.settings.permissions?.client || [];
21
- const userPermissions = command.permissions?.user || client.modules.options?.[CommandTypes[command.filetype]]?.permissions?.user || client.settings.permissions?.user || [];
22
- if (!client.cooldowns.collections.commands.has(`${event.user.id}-${command.name}`)) {
23
- client.cooldowns.collections.commands.set(`${event.user.id}-${command.name}`, cooldown);
24
- setTimeout(() => {
25
- client.cooldowns.collections.commands.delete(`${event.user.id}-${command.name}`);
26
- }, cooldownTime);
27
- }
28
- else {
29
- const user = client.cooldowns.collections.commands.get(`${event.user.id}-${command.name}`);
30
- const time = (user?.createdTimestamp || 0) - Number(Date.now());
31
- return emit(event, {
32
- reason: 'cooldown',
33
- message: `You are on cooldown for \`${command.name}\`, wait another \`${Math.round(time / 10) / 100}s\``,
34
- startedAt: user.createdTimestamp,
35
- endsAt: user.createdTimestamp + time,
36
- time,
37
- }, command);
38
- }
39
- if (command.channel && event.channel?.type !== undefined && event.channel?.type >= 0) {
40
- if (!command.channel.includes(ChannelType[event.channel?.type]))
41
- return await emit(event, {
42
- reason: 'invalidChannel',
43
- message: `\`${command.name}\` can only be used in ${command.channel.join(', ')} channels`,
44
- channels: command.channel,
45
- }, command);
46
- }
47
- if ((command.ignore?.channels?.length || 0) > 0 && command.ignore?.channels?.includes(event.channel?.id))
48
- return true;
49
- if ((command.ignore?.guilds?.length || 0) > 0 && command.ignore?.guilds?.includes(event.guild?.id))
50
- return true;
51
- if ((command.ignore?.users?.length || 0) > 0 && command.ignore?.users?.includes(event.user.id))
52
- return true;
53
- if (command.ignore?.voice && event.member?.voice?.channel)
54
- return await emit(event, {
55
- reason: 'inVoice',
56
- message: `\`${command.name}\` cannot be ran while in voice chat`,
57
- }, command);
58
- if (command.strict?.owner && !client.settings.ownerId.includes(event.user.id))
59
- return await emit(event, {
60
- reason: 'notADeveloper',
61
- message: `\`${command.name}\` is a developer command`,
62
- owners: client.settings.ownerId,
63
- }, command);
64
- if ((command.strict?.channels?.length || 0) > 0 && !command.strict?.channels?.includes(event.channel?.id))
65
- return await emit(event, {
66
- reason: 'channelRestricted',
67
- message: `\`${command.name}\` cannot be ran in this channel`,
68
- channels: command.strict?.channels,
69
- }, command);
70
- if ((command.strict?.guilds?.length || 0) > 0 && !command.strict?.guilds?.includes(event.guild?.id))
71
- return await emit(event, {
72
- reason: 'guildRestricted',
73
- message: `\`${command.name}\` cannot be ran in this guild`,
74
- guilds: command.strict?.guilds,
75
- }, command);
76
- if ((command.strict?.users?.length || 0) > 0 && !command.strict?.users?.includes(event.user.id))
77
- return await emit(event, {
78
- reason: 'userRestricted',
79
- message: `\`${command.name}\` cannot be ran by you`,
80
- users: command.strict?.users,
81
- }, command);
82
- if (command.strict?.voice && !event.member?.voice?.channel)
83
- return await emit(event, {
84
- reason: 'voiceRestricted',
85
- message: `\`${command.name}\` cannot be ran while not in voice chat`,
86
- }, command);
87
- if (command.permissions?.dm == false && event.channel?.type === ChannelType.DM)
88
- return await emit(event, {
89
- reason: 'DMRestricted',
90
- message: `\`${command.name}\` can't be used in a DM Channel`,
91
- }, command);
92
- if (userPermissions.length) {
93
- const missing = [];
94
- userPermissions.map((permission) => ((event.member?.permissions).toArray().includes(Style.pascalCase(permission, true)) ? null : missing.push(permission)));
95
- if (missing.length)
96
- return await emit(event, {
97
- reason: 'missingUserPermissions',
98
- message: `You are missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
99
- required: userPermissions,
100
- missing,
101
- }, command);
102
- }
103
- if (clientPermissions.length) {
104
- const missing = [];
105
- clientPermissions.map((permission) => event.guild?.members.me?.permissionsIn(event.channel?.id).has(Style.pascalCase(permission, true)) ? null : missing.push(permission));
106
- if (missing.length)
107
- return await emit(event, {
108
- reason: 'missingClientPermissions',
109
- message: `I am missing the following permissions to run \`${command.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
110
- required: clientPermissions,
111
- missing,
112
- }, command);
113
- }
114
- if ((!command.global || !client.settings.global) && client.settings.local !== event.guild?.id)
115
- return await emit(event, {
116
- reason: 'local',
117
- message: `\`${command.name}\` is not globally deployed`,
118
- }, command);
119
- return false;
120
- }
121
- async function emit(event, info, command) {
122
- event.client.emit('commandBlock', event, info, command);
123
- return true;
124
- }
@@ -1,9 +0,0 @@
1
- /** @format */
2
- import { ContextCommandArguments, MessageCommandArguments, SlashCommandArguments } from '../types/interfaces.js';
3
- import XernerxContextCommand from '../build/XernerxContextCommand.js';
4
- import XernerxMessageCommand from '../build/XernerxMessageCommand.js';
5
- import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
6
- import { XernerxMessage, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
7
- import { InhibitorType, XernerxInteraction } from '../types/types.js';
8
- export declare function inhibitorValidation(event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args?: SlashCommandArguments | MessageCommandArguments | ContextCommandArguments<'user' | 'message'> | null, cmd?: XernerxContextCommand | XernerxMessageCommand | XernerxSlashCommand, type?: 'pre' | 'check' | 'post'): Promise<boolean>;
9
- export declare function inhibitorArguments(event: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, cmd: XernerxContextCommand | XernerxMessageCommand | XernerxSlashCommand | null, type: InhibitorType): import("../types/extenders.js").XernerxUser | import("discord.js").GuildMember | import("discord.js").Guild | import("discord.js").TextBasedChannel | XernerxSlashCommand | XernerxContextCommand | import("discord.js").APIInteractionGuildMember | XernerxMessageCommand | null | undefined;
@@ -1,44 +0,0 @@
1
- /** @format */
2
- export async function inhibitorValidation(event, args, cmd, type) {
3
- const client = event.client;
4
- const inhibits = [];
5
- for (const [name, inhibitor] of client.inhibitors) {
6
- if (type == 'pre')
7
- if (Boolean(await inhibitor.pre(event, (await inhibitorArguments(event, cmd || null, inhibitor.type))))) {
8
- inhibits.push(name);
9
- }
10
- if (type == 'check')
11
- if (Boolean(await inhibitor.check(event, args || null, (await inhibitorArguments(event, cmd || null, inhibitor.type))))) {
12
- inhibits.push(name);
13
- }
14
- if (type == 'post')
15
- if (Boolean(await inhibitor.post(event, args || null, (await inhibitorArguments(event, cmd || null, inhibitor.type))))) {
16
- inhibits.push(name);
17
- }
18
- }
19
- return !!inhibits.length;
20
- }
21
- export function inhibitorArguments(event, cmd, type) {
22
- switch (type) {
23
- case 'channel':
24
- return event.channel || null;
25
- case 'command':
26
- return cmd || null;
27
- case 'contextCommand':
28
- return cmd || null;
29
- case 'guild':
30
- return event.guild || null;
31
- case 'interaction':
32
- return null;
33
- case 'member':
34
- return event.member || null;
35
- case 'message':
36
- return null;
37
- case 'messageCommand':
38
- return cmd || null;
39
- case 'slashCommand':
40
- return cmd || null;
41
- case 'user':
42
- return event.user || null;
43
- }
44
- }
package/tsup.config.ts DELETED
@@ -1,19 +0,0 @@
1
- /** @format */
2
-
3
- import { defineConfig } from 'tsup';
4
-
5
- export default defineConfig({
6
- entry: ['src/main.ts'],
7
- splitting: true,
8
- sourcemap: true,
9
- dts: true,
10
- clean: true,
11
- format: ['esm', 'cjs'],
12
- tsconfig: 'tsconfig.json',
13
- treeshake: true,
14
- shims: true,
15
- keepNames: true,
16
- target: 'es2022',
17
- skipNodeModulesBundle: true,
18
- platform: 'node',
19
- });