xernerx 4.4.5 → 4.4.7

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 (40) hide show
  1. package/dist/build/ContextCommandBuilder.d.ts +22 -30
  2. package/dist/build/ContextCommandBuilder.js +38 -38
  3. package/dist/build/EventBuilder.d.ts +1 -1
  4. package/dist/build/EventBuilder.js +1 -1
  5. package/dist/build/InhibitorBuilder.js +1 -1
  6. package/dist/build/MessageCommandBuilder.d.ts +19 -25
  7. package/dist/build/MessageCommandBuilder.js +33 -33
  8. package/dist/build/SlashCommandBuilder.d.ts +22 -30
  9. package/dist/build/SlashCommandBuilder.js +47 -47
  10. package/dist/client/XernerxClient.d.ts +21 -29
  11. package/dist/client/XernerxClient.js +32 -32
  12. package/dist/client/XernerxShardClient.js +3 -5
  13. package/dist/functions/deploy.js +15 -12
  14. package/dist/functions/load.js +2 -1
  15. package/dist/functions/reload.js +11 -8
  16. package/dist/functions/sendWebhook.js +2 -1
  17. package/dist/functions/setPresence.d.ts +1 -1
  18. package/dist/functions/setPresence.js +10 -11
  19. package/dist/handlers/CommandHandler.js +104 -81
  20. package/dist/handlers/EventHandler.js +2 -2
  21. package/dist/handlers/ExtensionHandler.js +4 -2
  22. package/dist/handlers/Handler.js +15 -5
  23. package/dist/handlers/InhibitorHandler.js +2 -2
  24. package/dist/handlers/WebhookHandler.d.ts +3 -1
  25. package/dist/handlers/WebhookHandler.js +5 -8
  26. package/dist/main.d.ts +21 -28
  27. package/dist/main.js +21 -28
  28. package/dist/models/Arguments.js +62 -47
  29. package/dist/tools/XernerxLog.js +1 -6
  30. package/dist/types/extenders.d.ts +8 -4
  31. package/dist/types/interfaces.d.ts +6 -12
  32. package/dist/types/types.d.ts +6 -174
  33. package/dist/utils/ClientUtil.d.ts +3 -3
  34. package/dist/utils/ClientUtil.js +13 -7
  35. package/dist/utils/InteractionUtil.d.ts +1 -1
  36. package/dist/utils/MessageUtil.d.ts +1 -1
  37. package/dist/utils/MessageUtil.js +8 -4
  38. package/dist/validators/commandValidation.js +28 -18
  39. package/dist/validators/inhibitorValidations.d.ts +1 -14
  40. package/package.json +1 -1
@@ -1,35 +1,45 @@
1
1
  export async function messageArguments(message, command) {
2
- const separator = command.separator || ' ',
3
- content = message.content.split(separator).slice(1);
4
- let args = {},
5
- flags = {};
2
+ const separator = command.separator || ' ', content = message.content.split(separator).slice(1);
3
+ let args = {}, flags = {};
6
4
  if (command.flags)
7
5
  command.flags.map((flag) => {
8
- if (!flags) flags = {};
9
- if (content.includes(flag.match)) flags[flag.name] = true;
10
- else flags[flag.name] = false;
6
+ if (!flags)
7
+ flags = {};
8
+ if (content.includes(flag.match))
9
+ flags[flag.name] = true;
10
+ else
11
+ flags[flag.name] = false;
11
12
  const index = content.indexOf(flag.match);
12
- if (index > 0) content.splice(index, 1);
13
+ if (index > 0)
14
+ content.splice(index, 1);
13
15
  });
14
16
  if (command.args)
15
17
  for (const argument of command.args) {
16
18
  const element = content.at(0) || null;
17
19
  if (!element) {
18
- if (typeof argument.default === 'function') args[argument.name] = argument.default(message);
20
+ if (typeof argument.default === 'function')
21
+ args[argument.name] = argument.default(message);
19
22
  args[argument.name] = argument.default || null;
20
23
  continue;
21
24
  }
22
- if (argument.type === 'option') argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
23
- if (argument.type === 'number') args[argument.name] = parseInt(element);
24
- if (argument.type === 'integer') args[argument.name] = parseInt(element);
25
- if (argument.type === 'boolean') args[argument.name] = element === 'true' ? true : false;
26
- if (argument.type === 'confirm') args[argument.name] = element === 'yes' ? 'yes' : 'no';
27
- if (argument.type === 'string') args[argument.name] = element;
25
+ if (argument.type === 'option')
26
+ argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
27
+ if (argument.type === 'number')
28
+ args[argument.name] = parseInt(element);
29
+ if (argument.type === 'integer')
30
+ args[argument.name] = parseInt(element);
31
+ if (argument.type === 'boolean')
32
+ args[argument.name] = element === 'true' ? true : false;
33
+ if (argument.type === 'confirm')
34
+ args[argument.name] = element === 'yes' ? 'yes' : 'no';
35
+ if (argument.type === 'string')
36
+ args[argument.name] = element;
28
37
  if (argument.type === 'channel') {
29
38
  try {
30
39
  const channel = await message.client.channels.fetch(element);
31
40
  args[argument.name] = channel;
32
- } catch (e) {
41
+ }
42
+ catch (e) {
33
43
  args[argument.name] = null;
34
44
  }
35
45
  }
@@ -37,33 +47,32 @@ export async function messageArguments(message, command) {
37
47
  try {
38
48
  const guild = await message.client.guilds.fetch(element);
39
49
  args[argument.name] = guild;
40
- } catch (e) {
50
+ }
51
+ catch (e) {
41
52
  args[argument.name] = null;
42
53
  }
43
54
  }
44
55
  if (argument.type === 'mentionable') {
45
- (
46
- await Promise.all(
47
- [message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) =>
48
- req
49
- ? req
50
- .fetch(element)
51
- .then((r) => r)
52
- .catch(() => null)
53
- : null
54
- )
55
- )
56
- ).map((mentionable) => {
57
- if (!args) args = {};
58
- if (mentionable) return (args[argument.name] = mentionable);
59
- else args[argument.name] = null;
56
+ (await Promise.all([message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) => req
57
+ ? req
58
+ .fetch(element)
59
+ .then((r) => r)
60
+ .catch(() => null)
61
+ : null))).map((mentionable) => {
62
+ if (!args)
63
+ args = {};
64
+ if (mentionable)
65
+ return (args[argument.name] = mentionable);
66
+ else
67
+ args[argument.name] = null;
60
68
  });
61
69
  }
62
70
  if (argument.type === 'role') {
63
71
  try {
64
72
  const role = await message.guild?.roles.fetch(element);
65
73
  args[argument.name] = role;
66
- } catch (e) {
74
+ }
75
+ catch (e) {
67
76
  args[argument.name] = null;
68
77
  }
69
78
  }
@@ -71,7 +80,8 @@ export async function messageArguments(message, command) {
71
80
  try {
72
81
  const user = await message.client.users.fetch(element);
73
82
  args[argument.name] = user;
74
- } catch (e) {
83
+ }
84
+ catch (e) {
75
85
  args[argument.name] = null;
76
86
  }
77
87
  }
@@ -79,7 +89,8 @@ export async function messageArguments(message, command) {
79
89
  try {
80
90
  const member = await message.guild?.members.fetch(element);
81
91
  args[argument.name] = member;
82
- } catch (e) {
92
+ }
93
+ catch (e) {
83
94
  args[argument.name] = null;
84
95
  }
85
96
  }
@@ -87,18 +98,20 @@ export async function messageArguments(message, command) {
87
98
  try {
88
99
  const msg = await message.channel?.messages.fetch(element);
89
100
  args[argument.name] = msg;
90
- } catch (e) {
101
+ }
102
+ catch (e) {
91
103
  args[argument.name] = null;
92
104
  }
93
105
  }
94
106
  if (argument.type === 'list') {
95
107
  let separator = String(argument.separator) || ',';
96
- if (separator.startsWith('/') && separator.endsWith('/')) separator = separator.replace(/^\/|\/$/gim, '');
108
+ if (separator.startsWith('/') && separator.endsWith('/'))
109
+ separator = separator.replace(/^\/|\/$/gim, '');
97
110
  const items = content.join(' ').split(new RegExp(' *' + separator + ' *', 'gi'));
98
- if (!argument.content) args[argument.name] = items;
111
+ if (!argument.content)
112
+ args[argument.name] = items;
99
113
  else {
100
- const contents = argument.content.map((content) => content.toLowerCase()),
101
- itemList = [];
114
+ const contents = argument.content.map((content) => content.toLowerCase()), itemList = [];
102
115
  items.map((item) => (contents.includes(item.toLowerCase()) ? itemList.push(argument.content?.at(contents.indexOf(item.toLowerCase()))) : null));
103
116
  args[argument.name] = itemList;
104
117
  break;
@@ -110,16 +123,16 @@ export async function messageArguments(message, command) {
110
123
  }
111
124
  content.splice(0, 1);
112
125
  }
113
- if (!command.flags) flags = null;
114
- if (!command.args) args = null;
126
+ if (!command.flags)
127
+ flags = null;
128
+ if (!command.args)
129
+ args = null;
115
130
  return { args, flags };
116
131
  }
117
132
  export async function interactionArguments(interaction, command) {
118
133
  if (command.fileType === 'SlashCommand') {
119
134
  const options = {};
120
- let args = interaction?.options?._hoistedOptions,
121
- group = interaction?.options?._group,
122
- subcommand = interaction?.options?._subcommand;
135
+ let args = interaction?.options?._hoistedOptions, group = interaction?.options?._group, subcommand = interaction?.options?._subcommand;
123
136
  if (interaction.options._hoistedOptions) {
124
137
  for (const option of interaction.options._hoistedOptions) {
125
138
  options[option.name] = option.member || option.channel || option.user || option.role || option.value;
@@ -129,7 +142,9 @@ export async function interactionArguments(interaction, command) {
129
142
  return { args, group, subcommand };
130
143
  }
131
144
  if (command.fileType === 'ContextCommand') {
132
- if (command.type === 'user') return await interaction.client.users.fetch(interaction.targetId);
133
- if (command.type === 'message') return await interaction.channel.messages.fetch(interaction.targetId);
145
+ if (command.type === 'user')
146
+ return await interaction.client.users.fetch(interaction.targetId);
147
+ if (command.type === 'message')
148
+ return await interaction.channel.messages.fetch(interaction.targetId);
134
149
  }
135
150
  }
@@ -18,12 +18,7 @@ export default class XernerxLog {
18
18
  }
19
19
  ready() {
20
20
  this.client.prependOnceListener('ready', async (synced) => {
21
- this.info(
22
- `${synced.user.tag} is now online, watching ${this.client.guilds.cache.size} guilds, using ${
23
- this.client.settings.local ? await this.client.guilds.fetch(this.client.settings.local) : 'none'
24
- } as local guild.`,
25
- this.readyLog
26
- );
21
+ this.info(`${synced.user.tag} is now online, watching ${this.client.guilds.cache.size} guilds, using ${this.client.settings.local ? await this.client.guilds.fetch(this.client.settings.local) : 'none'} as local guild.`, this.readyLog);
27
22
  const files = [];
28
23
  for (const [id, data] of this.client.commands.message) {
29
24
  files.push(data);
@@ -8,10 +8,14 @@ export interface XernerxUser extends User {
8
8
  export interface XernerxMember extends GuildMember {
9
9
  username: string;
10
10
  }
11
- export interface XernerxGuild extends Guild {}
12
- export interface XernerxGuildChannel extends GuildChannel {}
13
- export interface XernerxDMChannel extends DMChannel {}
14
- interface XernerxCommand {}
11
+ export interface XernerxGuild extends Guild {
12
+ }
13
+ export interface XernerxGuildChannel extends GuildChannel {
14
+ }
15
+ export interface XernerxDMChannel extends DMChannel {
16
+ }
17
+ interface XernerxCommand {
18
+ }
15
19
  export interface XernerxMessage extends Message, XernerxCommand {
16
20
  user: XernerxUser;
17
21
  util: MessageUtil;
@@ -67,14 +67,11 @@ export interface DBLOptions {
67
67
  }
68
68
  export interface XernerxCache {
69
69
  messages: Collection<string, string>;
70
- cooldowns: Collection<
71
- string,
72
- {
73
- id: string;
74
- command: string;
75
- createdTimestamp: number;
76
- }
77
- >;
70
+ cooldowns: Collection<string, {
71
+ id: string;
72
+ command: string;
73
+ createdTimestamp: number;
74
+ }>;
78
75
  }
79
76
  interface CommandHandlerOptions {
80
77
  directory: string;
@@ -196,10 +193,7 @@ export interface SlashCommandArgumentOptions {
196
193
  description: string;
197
194
  required?: boolean;
198
195
  autocomplete?: boolean;
199
- choices?: Array<{
200
- name: string;
201
- value: string;
202
- }>;
196
+ choices?: Array<Record<string, string>>;
203
197
  }
204
198
  export interface SlashCommandSubcommandOptions {
205
199
  name: string;
@@ -1,181 +1,13 @@
1
- import {
2
- SlashCommandBooleanOption,
3
- SlashCommandChannelOption,
4
- SlashCommandIntegerOption,
5
- SlashCommandMentionableOption,
6
- SlashCommandNumberOption,
7
- SlashCommandRoleOption,
8
- SlashCommandStringOption,
9
- SlashCommandUserOption,
10
- } from 'discord.js';
1
+ import { SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandUserOption } from 'discord.js';
11
2
  import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from './extenders.js';
12
3
  export type FileType = 'MessageCommand' | 'SlashCommand' | 'ContextCommand' | 'Event' | 'Inhibitor';
13
- export type Locales =
14
- | 'en-US'
15
- | 'en-GB'
16
- | 'bg'
17
- | 'zh-CN'
18
- | 'zh-TW'
19
- | 'hr'
20
- | 'cs'
21
- | 'da'
22
- | 'nl'
23
- | 'fi'
24
- | 'fr'
25
- | 'de'
26
- | 'el'
27
- | 'hi'
28
- | 'hu'
29
- | 'it'
30
- | 'ja'
31
- | 'ko'
32
- | 'lt'
33
- | 'no'
34
- | 'pl'
35
- | 'pt-BR'
36
- | 'ro'
37
- | 'ru'
38
- | 'es-ES'
39
- | 'sv-SE'
40
- | 'th'
41
- | 'tr'
42
- | 'uk'
43
- | 'vi';
4
+ export type Locales = 'en-US' | 'en-GB' | 'bg' | 'zh-CN' | 'zh-TW' | 'hr' | 'cs' | 'da' | 'nl' | 'fi' | 'fr' | 'de' | 'el' | 'hi' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'ru' | 'es-ES' | 'sv-SE' | 'th' | 'tr' | 'uk' | 'vi';
44
5
  export type SlashCommandArgumentType = 'attachment' | 'boolean' | 'channel' | 'integer' | 'mentionable' | 'number' | 'role' | 'string' | 'user';
45
6
  export type SlashCommandOptionChoices = SlashCommandStringOption | SlashCommandNumberOption | SlashCommandIntegerOption;
46
7
  export type SlashCommandOption = SlashCommandOptionChoices | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption;
47
- export type MessageCommandArgumentType =
48
- | 'string'
49
- | 'number'
50
- | 'boolean'
51
- | 'confirm'
52
- | 'channel'
53
- | 'guild'
54
- | 'integer'
55
- | 'mentionable'
56
- | 'role'
57
- | 'user'
58
- | 'message'
59
- | 'member'
60
- | 'list'
61
- | 'option'
62
- | 'rest';
63
- export type DiscordEventType =
64
- | 'applicationCommandPermissionsUpdate'
65
- | 'autoModerationActionExecution'
66
- | 'autoModerationRuleCreate'
67
- | 'autoModerationRuleDelete'
68
- | 'autoModerationRuleUpdate'
69
- | 'ready'
70
- | 'guildCreate'
71
- | 'guildDelete'
72
- | 'guildUpdate'
73
- | 'guildUnavailable'
74
- | 'guildMemberAdd'
75
- | 'guildMemberRemove'
76
- | 'guildMemberUpdate'
77
- | 'guildMemberAvailable'
78
- | 'guildMembersChunk'
79
- | 'guildIntegrationsUpdate'
80
- | 'roleCreate'
81
- | 'roleDelete'
82
- | 'inviteCreate'
83
- | 'inviteDelete'
84
- | 'roleUpdate'
85
- | 'emojiCreate'
86
- | 'emojiDelete'
87
- | 'emojiUpdate'
88
- | 'guildBanAdd'
89
- | 'guildBanRemove'
90
- | 'channelCreate'
91
- | 'channelDelete'
92
- | 'channelUpdate'
93
- | 'channelPinsUpdate'
94
- | 'messageCreate'
95
- | 'messageDelete'
96
- | 'messageUpdate'
97
- | 'messageDeleteBulk'
98
- | 'messageReactionAdd'
99
- | 'messageReactionRemove'
100
- | 'messageReactionRemoveAll'
101
- | 'messageReactionRemoveEmoji'
102
- | 'threadCreate'
103
- | 'threadDelete'
104
- | 'threadUpdate'
105
- | 'threadListSync'
106
- | 'threadMemberUpdate'
107
- | 'threadMembersUpdate'
108
- | 'userUpdate'
109
- | 'presenceUpdate'
110
- | 'voiceServerUpdate'
111
- | 'voiceStateUpdate'
112
- | 'typingStart'
113
- | 'webhookUpdate'
114
- | 'interactionCreate'
115
- | 'error'
116
- | 'warn'
117
- | 'debug'
118
- | 'cacheSweep'
119
- | 'shardDisconnect'
120
- | 'shardError'
121
- | 'shardReconnecting'
122
- | 'shardReady'
123
- | 'shardResume'
124
- | 'invalidated'
125
- | 'raw'
126
- | 'stageInstanceCreate'
127
- | 'stageInstanceUpdate'
128
- | 'stageInstanceDelete'
129
- | 'stickerCreate'
130
- | 'stickerDelete'
131
- | 'stickerUpdate'
132
- | 'guildScheduledEventCreate'
133
- | 'guildScheduledEventUpdate'
134
- | 'guildScheduledEventDelete'
135
- | 'guildScheduledEventUserAdd'
136
- | 'guildScheduledEventUserRemove';
137
- export type EventType = DiscordEventType | 'webhookInit' | 'webhookPost' | 'webhookError';
8
+ export type MessageCommandArgumentType = 'string' | 'number' | 'boolean' | 'confirm' | 'channel' | 'guild' | 'integer' | 'mentionable' | 'role' | 'user' | 'message' | 'member' | 'list' | 'option' | 'rest';
9
+ export type DiscordEventType = 'applicationCommandPermissionsUpdate' | 'autoModerationActionExecution' | 'autoModerationRuleCreate' | 'autoModerationRuleDelete' | 'autoModerationRuleUpdate' | 'ready' | 'guildCreate' | 'guildDelete' | 'guildUpdate' | 'guildUnavailable' | 'guildMemberAdd' | 'guildMemberRemove' | 'guildMemberUpdate' | 'guildMemberAvailable' | 'guildMembersChunk' | 'guildIntegrationsUpdate' | 'roleCreate' | 'roleDelete' | 'inviteCreate' | 'inviteDelete' | 'roleUpdate' | 'emojiCreate' | 'emojiDelete' | 'emojiUpdate' | 'guildBanAdd' | 'guildBanRemove' | 'channelCreate' | 'channelDelete' | 'channelUpdate' | 'channelPinsUpdate' | 'messageCreate' | 'messageDelete' | 'messageUpdate' | 'messageDeleteBulk' | 'messageReactionAdd' | 'messageReactionRemove' | 'messageReactionRemoveAll' | 'messageReactionRemoveEmoji' | 'threadCreate' | 'threadDelete' | 'threadUpdate' | 'threadListSync' | 'threadMemberUpdate' | 'threadMembersUpdate' | 'userUpdate' | 'presenceUpdate' | 'voiceServerUpdate' | 'voiceStateUpdate' | 'typingStart' | 'webhookUpdate' | 'interactionCreate' | 'error' | 'warn' | 'debug' | 'cacheSweep' | 'shardDisconnect' | 'shardError' | 'shardReconnecting' | 'shardReady' | 'shardResume' | 'invalidated' | 'raw' | 'stageInstanceCreate' | 'stageInstanceUpdate' | 'stageInstanceDelete' | 'stickerCreate' | 'stickerDelete' | 'stickerUpdate' | 'guildScheduledEventCreate' | 'guildScheduledEventUpdate' | 'guildScheduledEventDelete' | 'guildScheduledEventUserAdd' | 'guildScheduledEventUserRemove';
10
+ export type EventType = DiscordEventType | 'webhookInit' | 'webhookPost' | 'webhookError' | 'commandBlock' | 'commandError' | 'commandStart' | 'commandFinish' | 'commandCooldown';
138
11
  export type XernerxInteraction = XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction;
139
- export type PermissionNames =
140
- | 'create instant invite'
141
- | 'kick members'
142
- | 'ban members'
143
- | 'administrator'
144
- | 'manage channels'
145
- | 'manage guild'
146
- | 'add reactions'
147
- | 'view audit log'
148
- | 'priority speaker'
149
- | 'stream'
150
- | 'view channel'
151
- | 'send messages'
152
- | 'send tts messages'
153
- | 'manage messages'
154
- | 'embed links'
155
- | 'attach files'
156
- | 'read message history'
157
- | 'mention everyone'
158
- | 'use external emojis'
159
- | 'view guild insights'
160
- | 'connect'
161
- | 'speak'
162
- | 'mute members'
163
- | 'deafen members'
164
- | 'move members'
165
- | 'use vad'
166
- | 'change nickname'
167
- | 'manage nicknames'
168
- | 'manage roles'
169
- | 'manage webhooks'
170
- | 'manage emojis and stickers'
171
- | 'use application commands'
172
- | 'request to speak'
173
- | 'manage events'
174
- | 'manage threads'
175
- | 'create public threads'
176
- | 'create private threads'
177
- | 'use external stickers'
178
- | 'send messages in threads'
179
- | 'start embedded activities'
180
- | 'moderate members';
12
+ export type PermissionNames = 'create instant invite' | 'kick members' | 'ban members' | 'administrator' | 'manage channels' | 'manage guild' | 'add reactions' | 'view audit log' | 'priority speaker' | 'stream' | 'view channel' | 'send messages' | 'send tts messages' | 'manage messages' | 'embed links' | 'attach files' | 'read message history' | 'mention everyone' | 'use external emojis' | 'view guild insights' | 'connect' | 'speak' | 'mute members' | 'deafen members' | 'move members' | 'use vad' | 'change nickname' | 'manage nicknames' | 'manage roles' | 'manage webhooks' | 'manage emojis and stickers' | 'use application commands' | 'request to speak' | 'manage events' | 'manage threads' | 'create public threads' | 'create private threads' | 'use external stickers' | 'send messages in threads' | 'start embedded activities' | 'moderate members';
181
13
  export type InhibitorType = 'message' | 'interaction' | 'command' | 'channel' | 'user' | 'member' | 'guild' | 'contextCommand' | 'messageCommand' | 'slashCommand';
@@ -4,7 +4,7 @@ import Util from './Util.js';
4
4
  export default class ClientUtil extends Util {
5
5
  hasVoted?: Function;
6
6
  constructor(client: XernerxClient);
7
- setPresence(options: PresenceOptions): import('discord.js').ClientPresence | undefined;
8
- resolveChannel(query: string | Record<string, string>): Promise<import('discord.js').Channel | null>;
9
- resolveGuild(query: string | Record<string, string>): Promise<import('discord.js').Guild | null>;
7
+ setPresence(options: PresenceOptions): import("discord.js").ClientPresence | undefined;
8
+ resolveChannel(query: string | Record<string, string>): Promise<import("discord.js").Channel | null>;
9
+ resolveGuild(query: string | Record<string, string>): Promise<import("discord.js").Guild | null>;
10
10
  }
@@ -8,22 +8,28 @@ export default class ClientUtil extends Util {
8
8
  return setPresence(this.client, options);
9
9
  }
10
10
  async resolveChannel(query) {
11
- if (typeof query == 'object') query = query.id;
11
+ if (typeof query == 'object')
12
+ query = query.id;
12
13
  try {
13
- let channel = this.client.channels.cache.find((channel) => (channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null)) || null;
14
- if (!channel) channel = (await this.client.channels.fetch(query)) || null;
14
+ let channel = this.client.channels.cache.find((channel) => channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null) || null;
15
+ if (!channel)
16
+ channel = (await this.client.channels.fetch(query)) || null;
15
17
  return channel;
16
- } catch {
18
+ }
19
+ catch {
17
20
  return null;
18
21
  }
19
22
  }
20
23
  async resolveGuild(query) {
21
- if (typeof query == 'object') query = query.id;
24
+ if (typeof query == 'object')
25
+ query = query.id;
22
26
  try {
23
27
  let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == query.toLowerCase()) || null;
24
- if (!guild) guild = (await this.client.guilds.fetch(query)) || null;
28
+ if (!guild)
29
+ guild = (await this.client.guilds.fetch(query)) || null;
25
30
  return guild;
26
- } catch {
31
+ }
32
+ catch {
27
33
  return null;
28
34
  }
29
35
  }
@@ -5,6 +5,6 @@ import Util from './Util.js';
5
5
  export default class InteractionUtil extends Util {
6
6
  private interaction;
7
7
  constructor(client: XernerxClient, interaction: XernerxInteraction);
8
- reply(content: MessagePayload): Promise<import('discord.js').Message<boolean> | import('discord.js').InteractionResponse<boolean>>;
8
+ reply(content: MessagePayload): Promise<import("discord.js").Message<boolean> | import("discord.js").InteractionResponse<boolean>>;
9
9
  delay(time: number): Promise<unknown>;
10
10
  }
@@ -9,7 +9,7 @@ export default class MessageUtil extends Util {
9
9
  prefix: null | string;
10
10
  };
11
11
  constructor(client: XernerxClient, message: XernerxMessage);
12
- reply(content: MessagePayload): Promise<import('discord.js').Message<boolean> | undefined>;
12
+ reply(content: MessagePayload): Promise<import("discord.js").Message<boolean> | undefined>;
13
13
  webhookReply(content: MessagePayload, url?: URL, user?: User): Promise<void>;
14
14
  delay(time: number): Promise<unknown>;
15
15
  }
@@ -16,7 +16,8 @@ export default class MessageUtil extends Util {
16
16
  async reply(content) {
17
17
  if (this.client.cache.messages.has(this.message.id)) {
18
18
  const id = this.client.cache.messages.get(this.message.id);
19
- if (!id) return;
19
+ if (!id)
20
+ return;
20
21
  const msg = await this.message.channel.messages.fetch(id);
21
22
  msg.edit(content);
22
23
  return msg;
@@ -26,7 +27,8 @@ export default class MessageUtil extends Util {
26
27
  return msg;
27
28
  }
28
29
  async webhookReply(content, url, user) {
29
- if (this.message.channel.type === ChannelType.DM) throw new XernerxError(`Can't use this method in DM Channels`);
30
+ if (this.message.channel.type === ChannelType.DM)
31
+ throw new XernerxError(`Can't use this method in DM Channels`);
30
32
  const channel = this.message.channel;
31
33
  let webhook;
32
34
  if (!url) {
@@ -35,9 +37,11 @@ export default class MessageUtil extends Util {
35
37
  avatar: user?.avatarURL() || this.client.user?.avatarURL(),
36
38
  });
37
39
  }
38
- if (!webhook) webhook = { url };
40
+ if (!webhook)
41
+ webhook = { url };
39
42
  await sendWebhook(webhook.url, content);
40
- if (!url) webhook.delete();
43
+ if (!url)
44
+ webhook.delete();
41
45
  return;
42
46
  }
43
47
  async delay(time) {
@@ -1,7 +1,8 @@
1
1
  import { ChannelType, PermissionFlagsBits } from 'discord.js';
2
2
  export default async function commandValidation(event, command) {
3
3
  const client = event.client;
4
- if (command.ignore?.owner && client.settings.ownerId.includes(event.user.id)) return false;
4
+ if (command.ignore?.owner && client.settings.ownerId.includes(event.user.id))
5
+ return false;
5
6
  if (!client.cache.cooldowns.has(`${event.user.id}-${command.name}`)) {
6
7
  client.cache.cooldowns.set(`${event.user.id}-${command.name}`, {
7
8
  id: event.user.id,
@@ -11,21 +12,31 @@ export default async function commandValidation(event, command) {
11
12
  setTimeout(() => {
12
13
  client.cache.cooldowns.delete(`${event.user.id}-${command.name}`);
13
14
  }, command.cooldown || 0);
14
- } else {
15
+ }
16
+ else {
15
17
  const user = client.cache.cooldowns.get(`${event.user.id}-${command.name}`);
16
18
  const time = (user?.createdTimestamp || 0) - Number(Date.now());
17
19
  return emit(event, `Command on cooldown, ${time}`);
18
20
  }
19
- if ((command.ignore?.channels?.length || 0) > 0 && command.ignore?.channels?.includes(event.channel?.id)) return true;
20
- if ((command.ignore?.guilds?.length || 0) > 0 && command.ignore?.guilds?.includes(event.guild?.id)) return true;
21
- if ((command.ignore?.users?.length || 0) > 0 && command.ignore?.users?.includes(event.user.id)) return true;
22
- if (command.strict?.owner && !client.settings.ownerId.includes(event.user.id)) return await emit(event, 'Command is a developer command');
23
- if ((command.strict?.channels?.length || 0) > 0 && !command.strict?.channels?.includes(event.channel?.id)) return await emit(event, 'Command cannot be ran in this channel');
24
- if ((command.strict?.guilds?.length || 0) > 0 && !command.strict?.guilds?.includes(event.guild?.id)) return await emit(event, 'Command cannot be ran in this guild');
25
- if ((command.strict?.users?.length || 0) > 0 && !command.strict?.users?.includes(event.user.id)) return await emit(event, 'Command cannot be ran by you');
26
- if (command.permissions?.dm == false && event.channel?.type === ChannelType.DM) return await emit(event, "Can't use in a DM Channel");
21
+ if ((command.ignore?.channels?.length || 0) > 0 && command.ignore?.channels?.includes(event.channel?.id))
22
+ return true;
23
+ if ((command.ignore?.guilds?.length || 0) > 0 && command.ignore?.guilds?.includes(event.guild?.id))
24
+ return true;
25
+ if ((command.ignore?.users?.length || 0) > 0 && command.ignore?.users?.includes(event.user.id))
26
+ return true;
27
+ if (command.strict?.owner && !client.settings.ownerId.includes(event.user.id))
28
+ return await emit(event, 'Command is a developer command');
29
+ if ((command.strict?.channels?.length || 0) > 0 && !command.strict?.channels?.includes(event.channel?.id))
30
+ return await emit(event, 'Command cannot be ran in this channel');
31
+ if ((command.strict?.guilds?.length || 0) > 0 && !command.strict?.guilds?.includes(event.guild?.id))
32
+ return await emit(event, 'Command cannot be ran in this guild');
33
+ if ((command.strict?.users?.length || 0) > 0 && !command.strict?.users?.includes(event.user.id))
34
+ return await emit(event, 'Command cannot be ran by you');
35
+ if (command.permissions?.dm == false && event.channel?.type === ChannelType.DM)
36
+ return await emit(event, "Can't use in a DM Channel");
27
37
  if (command.permissions?.user) {
28
- if (!(event.member?.permissions).has(toBigInt(command.permissions.user))) return await emit(event, 'Missing User Permissions');
38
+ if (!(event.member?.permissions).has(toBigInt(command.permissions.user)))
39
+ return await emit(event, 'Missing User Permissions');
29
40
  }
30
41
  return false;
31
42
  }
@@ -37,13 +48,12 @@ function toBigInt(permissions) {
37
48
  let bigIntPermissions = 0n;
38
49
  permissions.map((permission) => {
39
50
  permission =
40
- PermissionFlagsBits[
41
- permission
42
- .split(/ +/)
43
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
44
- .join('')
45
- ];
46
- if (typeof permission === 'bigint') bigIntPermissions += permission;
51
+ PermissionFlagsBits[permission
52
+ .split(/ +/)
53
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
54
+ .join('')];
55
+ if (typeof permission === 'bigint')
56
+ bigIntPermissions += permission;
47
57
  });
48
58
  return bigIntPermissions;
49
59
  }
@@ -2,17 +2,4 @@ import { ContextCommandBuilder, MessageCommandBuilder, SlashCommandBuilder } fro
2
2
  import { XernerxMessage } from '../types/extenders.js';
3
3
  import { InhibitorType, XernerxInteraction } from '../types/types.js';
4
4
  export declare function inhibitorValidation(event: XernerxMessage | XernerxInteraction, cmd?: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder): Promise<boolean>;
5
- export declare function inhibitorArguments(
6
- event: XernerxMessage | XernerxInteraction,
7
- cmd: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder | null,
8
- type: InhibitorType
9
- ):
10
- | import('discord.js').Guild
11
- | import('discord.js').GuildMember
12
- | import('discord.js').TextBasedChannel
13
- | import('discord.js').User
14
- | SlashCommandBuilder
15
- | ContextCommandBuilder
16
- | MessageCommandBuilder
17
- | import('../main.js').APIInteractionGuildMember
18
- | null;
5
+ export declare function inhibitorArguments(event: XernerxMessage | XernerxInteraction, cmd: ContextCommandBuilder | MessageCommandBuilder | SlashCommandBuilder | null, type: InhibitorType): import("discord.js").Guild | import("discord.js").GuildMember | import("discord.js").TextBasedChannel | import("discord.js").User | SlashCommandBuilder | ContextCommandBuilder | MessageCommandBuilder | import("../main.js").APIInteractionGuildMember | null;