xernerx 4.2.1 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +21 -21
  2. package/dist/build/ContextCommandBuilder.d.ts +14 -13
  3. package/dist/build/ContextCommandBuilder.js +2 -13
  4. package/dist/build/EventBuilder.d.ts +7 -7
  5. package/dist/build/EventBuilder.js +0 -6
  6. package/dist/build/InhibitorBuilder.d.ts +5 -5
  7. package/dist/build/InhibitorBuilder.js +0 -4
  8. package/dist/build/MessageCommandBuilder.d.ts +1 -0
  9. package/dist/build/MessageCommandBuilder.js +2 -16
  10. package/dist/build/SlashCommandBuilder.d.ts +13 -12
  11. package/dist/build/SlashCommandBuilder.js +2 -12
  12. package/dist/client/XernerxClient.d.ts +2 -2
  13. package/dist/client/XernerxClient.js +2 -2
  14. package/dist/handlers/ExtensionHandler.js +3 -1
  15. package/dist/handlers/WebhookHandler.js +1 -1
  16. package/dist/main.d.ts +1 -1
  17. package/dist/main.js +1 -1
  18. package/dist/types/interfaces.d.ts +3 -2
  19. package/dist/utils/ClientUtil.d.ts +1 -0
  20. package/dist/utils/ClientUtil.js +10 -0
  21. package/package.json +2 -2
  22. package/dist/cjs/build/ContextCommandBuilder.d.ts +0 -68
  23. package/dist/cjs/build/ContextCommandBuilder.js +0 -97
  24. package/dist/cjs/build/EventBuilder.d.ts +0 -21
  25. package/dist/cjs/build/EventBuilder.js +0 -44
  26. package/dist/cjs/build/InhibitorBuilder.d.ts +0 -19
  27. package/dist/cjs/build/InhibitorBuilder.js +0 -37
  28. package/dist/cjs/build/MessageCommandBuilder.d.ts +0 -59
  29. package/dist/cjs/build/MessageCommandBuilder.js +0 -100
  30. package/dist/cjs/build/SlashCommandBuilder.d.ts +0 -64
  31. package/dist/cjs/build/SlashCommandBuilder.js +0 -168
  32. package/dist/cjs/client/XernerxClient.d.ts +0 -28
  33. package/dist/cjs/client/XernerxClient.js +0 -116
  34. package/dist/cjs/handlers/CommandHandler.d.ts +0 -27
  35. package/dist/cjs/handlers/CommandHandler.js +0 -45
  36. package/dist/cjs/handlers/EventHandler.d.ts +0 -13
  37. package/dist/cjs/handlers/EventHandler.js +0 -19
  38. package/dist/cjs/handlers/Handler.d.ts +0 -57
  39. package/dist/cjs/handlers/Handler.js +0 -308
  40. package/dist/cjs/handlers/InhibitorHandler.d.ts +0 -18
  41. package/dist/cjs/handlers/InhibitorHandler.js +0 -24
  42. package/dist/cjs/main.d.ts +0 -44
  43. package/dist/cjs/main.js +0 -112
  44. package/dist/cjs/models/CommandArguments.d.ts +0 -17
  45. package/dist/cjs/models/CommandArguments.js +0 -106
  46. package/dist/cjs/models/Events.d.ts +0 -24
  47. package/dist/cjs/models/Events.js +0 -307
  48. package/dist/cjs/models/Extensions.d.ts +0 -7
  49. package/dist/cjs/models/Extensions.js +0 -26
  50. package/dist/cjs/tools/XernerxError.d.ts +0 -5
  51. package/dist/cjs/tools/XernerxError.js +0 -11
  52. package/dist/cjs/tools/package.d.ts +0 -49
  53. package/dist/cjs/tools/package.js +0 -50
  54. package/dist/cjs/types/enums.d.ts +0 -44
  55. package/dist/cjs/types/enums.js +0 -38
  56. package/dist/cjs/types/interfaces.d.ts +0 -25
  57. package/dist/cjs/types/interfaces.js +0 -2
  58. package/dist/cjs/types/options.d.ts +0 -241
  59. package/dist/cjs/types/options.js +0 -2
  60. package/dist/cjs/types/types.d.ts +0 -61
  61. package/dist/cjs/types/types.js +0 -2
  62. package/dist/cjs/utils/ClientUtil.d.ts +0 -25
  63. package/dist/cjs/utils/ClientUtil.js +0 -211
  64. package/dist/cjs/utils/CommandUtil.d.ts +0 -58
  65. package/dist/cjs/utils/CommandUtil.js +0 -247
  66. package/dist/cjs/validators/CommandValidations.d.ts +0 -12
  67. package/dist/cjs/validators/CommandValidations.js +0 -169
  68. package/dist/cjs/validators/InhibitorValidations.d.ts +0 -11
  69. package/dist/cjs/validators/InhibitorValidations.js +0 -40
  70. package/dist/mjs/build/ContextCommandBuilder.d.ts +0 -68
  71. package/dist/mjs/build/ContextCommandBuilder.js +0 -88
  72. package/dist/mjs/build/EventBuilder.d.ts +0 -21
  73. package/dist/mjs/build/EventBuilder.js +0 -34
  74. package/dist/mjs/build/InhibitorBuilder.d.ts +0 -19
  75. package/dist/mjs/build/InhibitorBuilder.js +0 -27
  76. package/dist/mjs/build/MessageCommandBuilder.d.ts +0 -59
  77. package/dist/mjs/build/MessageCommandBuilder.js +0 -90
  78. package/dist/mjs/build/SlashCommandBuilder.d.ts +0 -64
  79. package/dist/mjs/build/SlashCommandBuilder.js +0 -121
  80. package/dist/mjs/client/XernerxClient.d.ts +0 -28
  81. package/dist/mjs/client/XernerxClient.js +0 -108
  82. package/dist/mjs/handlers/CommandHandler.d.ts +0 -27
  83. package/dist/mjs/handlers/CommandHandler.js +0 -42
  84. package/dist/mjs/handlers/EventHandler.d.ts +0 -13
  85. package/dist/mjs/handlers/EventHandler.js +0 -16
  86. package/dist/mjs/handlers/Handler.d.ts +0 -57
  87. package/dist/mjs/handlers/Handler.js +0 -260
  88. package/dist/mjs/handlers/InhibitorHandler.d.ts +0 -18
  89. package/dist/mjs/handlers/InhibitorHandler.js +0 -21
  90. package/dist/mjs/main.d.ts +0 -44
  91. package/dist/mjs/main.js +0 -52
  92. package/dist/mjs/models/CommandArguments.d.ts +0 -17
  93. package/dist/mjs/models/CommandArguments.js +0 -101
  94. package/dist/mjs/models/Events.d.ts +0 -24
  95. package/dist/mjs/models/Events.js +0 -295
  96. package/dist/mjs/models/Extensions.d.ts +0 -7
  97. package/dist/mjs/models/Extensions.js +0 -23
  98. package/dist/mjs/tools/XernerxError.d.ts +0 -5
  99. package/dist/mjs/tools/XernerxError.js +0 -8
  100. package/dist/mjs/tools/package.d.ts +0 -49
  101. package/dist/mjs/tools/package.js +0 -48
  102. package/dist/mjs/types/enums.d.ts +0 -44
  103. package/dist/mjs/types/enums.js +0 -35
  104. package/dist/mjs/types/interfaces.d.ts +0 -25
  105. package/dist/mjs/types/interfaces.js +0 -1
  106. package/dist/mjs/types/options.d.ts +0 -241
  107. package/dist/mjs/types/options.js +0 -1
  108. package/dist/mjs/types/types.d.ts +0 -61
  109. package/dist/mjs/types/types.js +0 -1
  110. package/dist/mjs/utils/ClientUtil.d.ts +0 -25
  111. package/dist/mjs/utils/ClientUtil.js +0 -202
  112. package/dist/mjs/utils/CommandUtil.d.ts +0 -58
  113. package/dist/mjs/utils/CommandUtil.js +0 -232
  114. package/dist/mjs/validators/CommandValidations.d.ts +0 -12
  115. package/dist/mjs/validators/CommandValidations.js +0 -166
  116. package/dist/mjs/validators/InhibitorValidations.d.ts +0 -11
  117. package/dist/mjs/validators/InhibitorValidations.js +0 -36
@@ -1,38 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.EventEmitterType = exports.ContextCommandType = exports.CommandType = exports.InhibitorType = void 0;
4
- var InhibitorType;
5
- (function (InhibitorType) {
6
- InhibitorType['Member'] = 'Member';
7
- InhibitorType['User'] = 'User';
8
- InhibitorType['Guild'] = 'Guild';
9
- InhibitorType['SlashCommand'] = 'SlashCommand';
10
- InhibitorType['MessageCommand'] = 'MessageCommand';
11
- InhibitorType['ContextCommand'] = 'ContextCommand';
12
- InhibitorType['Command'] = 'Command';
13
- InhibitorType['Message'] = 'Message';
14
- InhibitorType['Interaction'] = 'Interaction';
15
- InhibitorType['Channel'] = 'Channel';
16
- })((InhibitorType = exports.InhibitorType || (exports.InhibitorType = {})));
17
- var CommandType;
18
- (function (CommandType) {
19
- CommandType['Message'] = 'MessageCommand';
20
- CommandType['Slash'] = 'SlashCommand';
21
- CommandType['Context'] = 'ContextCommand';
22
- CommandType['Event'] = 'Event';
23
- CommandType['Inhibitor'] = 'Inhibitor';
24
- CommandType['MessageCommand'] = 'MessageCommand';
25
- CommandType['SlashCommand'] = 'SlashCommand';
26
- CommandType['ContextCommand'] = 'ContextCommand';
27
- })((CommandType = exports.CommandType || (exports.CommandType = {})));
28
- var ContextCommandType;
29
- (function (ContextCommandType) {
30
- ContextCommandType[(ContextCommandType['Message'] = 3)] = 'Message';
31
- ContextCommandType[(ContextCommandType['User'] = 2)] = 'User';
32
- })((ContextCommandType = exports.ContextCommandType || (exports.ContextCommandType = {})));
33
- var EventEmitterType;
34
- (function (EventEmitterType) {
35
- EventEmitterType['Client'] = 'client';
36
- EventEmitterType['Rest'] = 'rest';
37
- EventEmitterType['Process'] = 'process';
38
- })((EventEmitterType = exports.EventEmitterType || (exports.EventEmitterType = {})));
@@ -1,25 +0,0 @@
1
- import { Collection } from 'discord.js';
2
- import CommandHandler from '../handlers/CommandHandler.js';
3
- import EventHandler from '../handlers/EventHandler.js';
4
- import InhibitorHandler from '../handlers/InhibitorHandler.js';
5
- import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
6
- import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
7
- import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
8
- export interface ClientCommands {
9
- message: Collection<string, MessageCommandBuilder>;
10
- slash: Collection<string, SlashCommandBuilder>;
11
- context: Collection<string, ContextCommandBuilder>;
12
- }
13
- export interface ClientCache {
14
- messages: Collection<string, object>;
15
- cooldowns: Collection<string, object>;
16
- messageCommands: Collection<string, object>;
17
- slashCommands: Collection<string, object>;
18
- contextCommands: Collection<string, object>;
19
- commands: Collection<string, object>;
20
- }
21
- export interface ClientModules {
22
- commandHandler: CommandHandler;
23
- eventHandler: EventHandler;
24
- inhibitorHandler: InhibitorHandler;
25
- }
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,241 +0,0 @@
1
- import { CacheFactory, ChannelType, ContextMenuCommandType, MessageMentionOptions, Partials, PresenceData, RESTOptions, SweeperOptions, WebSocketOptions } from 'discord.js';
2
- import XernerxExtensionBuilder from 'xernerx-extension-builder';
3
- import { InhibitorType } from './enums.js';
4
- import { EventEmitterType, Localizations, MessageCommandArgsTypes } from './types.js';
5
- export interface DiscordOptions {
6
- shards?: number | number[] | 'auto';
7
- closeTimeout?: number;
8
- shardCount?: number;
9
- makeCache?: CacheFactory;
10
- allowedMentions?: MessageMentionOptions;
11
- partials?: Array<Partials>;
12
- failIfNotExists?: boolean;
13
- presence?: PresenceData;
14
- intents: number[];
15
- waitGuildTimeout?: number;
16
- sweepers?: SweeperOptions;
17
- ws?: WebSocketOptions;
18
- rest?: RESTOptions;
19
- jsonTransformer?: (obj: unknown) => unknown;
20
- }
21
- export interface ClientOptions {
22
- ownerId?: string | string[];
23
- permissions?: {
24
- client?: Array<string>;
25
- user?: Array<string>;
26
- dm?: boolean;
27
- };
28
- ignore?: {
29
- owner?: boolean;
30
- users: Array<string>;
31
- channels: Array<string>;
32
- guilds: Array<string>;
33
- };
34
- log?: {
35
- ready: boolean;
36
- error: boolean;
37
- };
38
- cooldown?: {
39
- command?: number;
40
- cache?: number;
41
- };
42
- }
43
- export interface HandlerOptions {
44
- message?: MessageCommandHandlerOptions;
45
- slash?: SlashCommandHandlerOptions;
46
- context?: ContextCommandHandlerOptions;
47
- events?: EventHandlerOptions;
48
- inhibitors?: InhibitorHandlerOptions;
49
- }
50
- export interface ExtensionOptions {
51
- extensions: Array<XernerxExtensionBuilder>;
52
- logging?: boolean;
53
- }
54
- export interface MessageCommandOptions {
55
- name: string;
56
- aliases?: Array<string>;
57
- separator?: string;
58
- description?: string;
59
- info?: string;
60
- category?: string;
61
- prefix?: Array<string> | string;
62
- regex?: string;
63
- channelType?: Array<number>;
64
- cooldown?: number;
65
- ignore?: {
66
- owner?: boolean;
67
- users?: Array<string>;
68
- channels?: Array<string>;
69
- guilds?: Array<string>;
70
- };
71
- strict?: {
72
- owner?: boolean;
73
- users?: Array<string>;
74
- channels?: Array<string>;
75
- guilds?: Array<string>;
76
- };
77
- permissions?: {
78
- client?: Array<string>;
79
- user?: Array<string>;
80
- dm?: boolean;
81
- };
82
- args?: Array<MessageArgumentOptions>;
83
- }
84
- export interface ContextCommandOptions {
85
- name: string;
86
- type: ContextMenuCommandType;
87
- nameLocalizations: Record<Localizations, string>;
88
- description?: string;
89
- info?: string;
90
- category?: string;
91
- channelType?: Array<number> | number;
92
- cooldown?: number;
93
- ignore?: {
94
- owner?: boolean;
95
- users?: Array<string>;
96
- channels?: Array<string>;
97
- guilds?: Array<string>;
98
- };
99
- strict?: {
100
- owner?: boolean;
101
- users?: Array<string>;
102
- channels?: Array<string>;
103
- guilds?: Array<string>;
104
- };
105
- permissions?: {
106
- client?: Array<string>;
107
- users?: Array<string>;
108
- dm?: boolean;
109
- };
110
- defer?: {
111
- reply?: boolean;
112
- ephemeral?: boolean;
113
- fetch?: boolean;
114
- };
115
- }
116
- export interface MessageArgumentOptions {
117
- type: MessageCommandArgsTypes;
118
- content?: Array<string>;
119
- match?: string;
120
- name: string;
121
- prompt?: {
122
- reply: string;
123
- send: string;
124
- };
125
- default?: string | Function;
126
- }
127
- export interface SlashArgumentOptions {
128
- type: 'string' | 'number' | 'boolean' | 'user' | 'channel' | 'role' | 'mentionable' | 'integer';
129
- name: string;
130
- choices: Array<{
131
- name: string;
132
- value: string;
133
- }>;
134
- required: boolean;
135
- description: string;
136
- }
137
- export interface SlashSubcommandOptions {
138
- name: string;
139
- description: string;
140
- args: Array<SlashArgumentOptions>;
141
- }
142
- export interface SlashGroupOptions {
143
- name: string;
144
- description: string;
145
- subcommands: Array<SlashSubcommandOptions>;
146
- }
147
- export interface SlashCommandOptions {
148
- name: string;
149
- description: string;
150
- info?: string;
151
- category?: string;
152
- owner?: boolean;
153
- channelType?: ChannelType;
154
- cooldown?: number;
155
- ignore?: {
156
- owner?: boolean;
157
- users?: Array<string>;
158
- channels?: Array<string>;
159
- guilds?: Array<string>;
160
- };
161
- strict?: {
162
- owner?: boolean;
163
- users?: Array<string>;
164
- channels?: Array<string>;
165
- guilds?: Array<string>;
166
- };
167
- permissions: {
168
- client?: Array<string>;
169
- users?: Array<string>;
170
- dm?: boolean;
171
- };
172
- defer?: {
173
- reply?: boolean;
174
- ephemeral?: boolean;
175
- fetchReply?: boolean;
176
- };
177
- args?: Array<SlashArgumentOptions>;
178
- subcommands?: Array<SlashSubcommandOptions>;
179
- groups?: Array<SlashGroupOptions>;
180
- }
181
- export interface MessageCommandHandlerOptions {
182
- directory: string;
183
- prefix: string[] | string;
184
- allowMention?: boolean;
185
- cooldown?: number;
186
- userPermissions?: bigint[];
187
- clientPermissions?: bigint[];
188
- handleEdits?: boolean;
189
- handleDeletes?: boolean;
190
- handleTyping?: boolean;
191
- util?: boolean;
192
- logging?: boolean;
193
- }
194
- export interface SlashCommandHandlerOptions {
195
- directory: string;
196
- guildId: string;
197
- global: boolean;
198
- cooldown?: number;
199
- userPermissions?: bigint[];
200
- clientPermissions?: bigint[];
201
- util?: boolean;
202
- logging?: boolean;
203
- defer?: {
204
- reply?: boolean;
205
- ephemeral?: boolean;
206
- fetchReply?: boolean;
207
- };
208
- }
209
- export interface ContextCommandHandlerOptions {
210
- directory: string;
211
- guildId: string;
212
- global: boolean;
213
- cooldown?: number;
214
- userPermissions?: bigint[];
215
- clientPermissions?: bigint[];
216
- util?: boolean;
217
- logging?: boolean;
218
- defer?: {
219
- reply?: boolean;
220
- ephemeral?: boolean;
221
- fetchReply?: boolean;
222
- };
223
- }
224
- export interface EventHandlerOptions {
225
- directory: string;
226
- logging?: boolean;
227
- }
228
- export interface EventOptions {
229
- name: string;
230
- emitter?: EventEmitterType | string;
231
- type?: 'discord' | string;
232
- once?: boolean;
233
- }
234
- export interface InhibitorHandlerOptions {
235
- directory: string;
236
- logging?: boolean;
237
- }
238
- export interface InhibitorOptions {
239
- name: string;
240
- type: InhibitorType;
241
- }
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,61 +0,0 @@
1
- import { TextChannel, Message, User, Guild, GuildMember, Channel, Role, InteractionResponse } from 'discord.js';
2
- import { InteractionCommandUtil, MessageCommandUtil } from '../utils/CommandUtil.js';
3
- export interface XernerxMessage extends Message {
4
- util?: MessageCommandUtil;
5
- response?: string;
6
- }
7
- export interface XernerxInteraction extends InteractionResponse {
8
- util: InteractionCommandUtil;
9
- options?: {
10
- _group: string;
11
- _subcommand: string;
12
- _hoistedOptions: Array<{
13
- name: string;
14
- channel: Channel;
15
- user: XernerxUser;
16
- role: XernerxRole;
17
- value: string;
18
- }>;
19
- };
20
- }
21
- export interface XernerxUser extends User {
22
- isOwner: boolean;
23
- }
24
- export interface XernerxRole extends Role {}
25
- export interface XernerxTextChannel extends TextChannel {}
26
- export interface XernerxGuild extends Guild {}
27
- export interface XernerxMember extends GuildMember {}
28
- export type MessageCommandArgsTypes = 'rest' | 'option' | 'flag' | 'string' | 'number' | 'channel' | 'user' | 'member' | 'boolean' | 'role';
29
- export type Localizations =
30
- | 'id'
31
- | 'da'
32
- | 'de'
33
- | 'en-GB'
34
- | 'en-US'
35
- | 'es-ES'
36
- | 'fr'
37
- | 'hr'
38
- | 'it'
39
- | 'lt'
40
- | 'hu'
41
- | 'nl'
42
- | 'no'
43
- | 'pl'
44
- | 'pt-BR'
45
- | 'ro'
46
- | 'fi'
47
- | 'sv-SE'
48
- | 'vi'
49
- | 'tr'
50
- | 'cs'
51
- | 'el'
52
- | 'bg'
53
- | 'ru'
54
- | 'uk'
55
- | 'hi'
56
- | 'th'
57
- | 'zh-CN'
58
- | 'ja'
59
- | 'zh-TW'
60
- | 'ko';
61
- export type EventEmitterType = 'client' | 'process';
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,25 +0,0 @@
1
- import { ActivityType, ClientPresenceStatus } from 'discord.js';
2
- import XernerxClient from '../client/XernerxClient.js';
3
- interface Presence {
4
- text?: string;
5
- type?: ActivityType.Playing | ActivityType.Streaming | ActivityType.Listening | ActivityType.Watching | ActivityType.Competing;
6
- link?: string;
7
- status?: ClientPresenceStatus;
8
- interval?: number;
9
- }
10
- export declare class ClientUtil {
11
- client: XernerxClient;
12
- constructor(client: XernerxClient);
13
- uptime(timestamp: number | null): string;
14
- getSubcommands(name: string): object[];
15
- isOwner(userId: string): boolean;
16
- getAllCommands(): object[];
17
- getAllMessageCommands(): object[];
18
- getAllSlashCommands(): object[];
19
- getAllContextCommands(): object[];
20
- setPresence(options: Presence): void;
21
- getCooldowns(id: string, command?: string): any;
22
- getCooldownTimers(id: string, command?: string): any;
23
- defer(time: number): Promise<unknown>;
24
- }
25
- export {};
@@ -1,211 +0,0 @@
1
- 'use strict';
2
- var __importDefault =
3
- (this && this.__importDefault) ||
4
- function (mod) {
5
- return mod && mod.__esModule ? mod : { default: mod };
6
- };
7
- Object.defineProperty(exports, '__esModule', { value: true });
8
- exports.ClientUtil = void 0;
9
- const XernerxError_js_1 = __importDefault(require('../tools/XernerxError.js'));
10
- class ClientUtil {
11
- client;
12
- constructor(client) {
13
- this.client = client;
14
- }
15
- uptime(timestamp) {
16
- if (!timestamp) timestamp = this.client.uptime || 0;
17
- let totalSeconds = timestamp / 1000;
18
- let years = Math.floor(totalSeconds / 31536000);
19
- totalSeconds %= 31536000;
20
- let days = Math.floor(totalSeconds / 86400);
21
- totalSeconds %= 86400;
22
- let hours = Math.floor(totalSeconds / 3600);
23
- totalSeconds %= 3600;
24
- let minutes = Math.floor(totalSeconds / 60);
25
- let seconds = Math.floor(totalSeconds % 60);
26
- if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`;
27
- else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;
28
- else if (hours >= 1) return `${hours}h ${minutes}m`;
29
- else if (minutes >= 1) return `${minutes}m ${seconds}s`;
30
- else return `${seconds}s`;
31
- }
32
- getSubcommands(name) {
33
- if (!name || typeof name !== 'string') throw new XernerxError_js_1.default(`Expected name to be of type string, received ${typeof name} instead!`);
34
- const commands = [];
35
- this.getAllCommands()
36
- .filter((c) => (c.data?.name?.toLowerCase() || c.name?.toLowerCase()) == name?.toLowerCase())
37
- .map((c) => {
38
- if (c?.data?.options?.length > 0) {
39
- c?.data?.options?.map((option) => {
40
- if (!option?.type) {
41
- if (option?.options?.length > 0) {
42
- option?.options?.map((opt) => {
43
- if (!opt.type) {
44
- commands.push({
45
- name: c.data.name,
46
- formattedName: `${c.data.name} ${option.name} ${opt.name}`,
47
- description: opt.description,
48
- category: c.category || null,
49
- commandType: c.commandType,
50
- });
51
- } else {
52
- commands.push({
53
- name: c.data.name,
54
- formattedName: `${c.data.name} ${option.name}`,
55
- description: option.description,
56
- category: c.category || null,
57
- commandType: c.commandType,
58
- });
59
- }
60
- });
61
- } else {
62
- commands.push({
63
- name: c.data.name,
64
- formattedName: `${c.data.name} ${option.name}`,
65
- description: option.description,
66
- category: c.category || null,
67
- commandType: c.commandType,
68
- });
69
- }
70
- } else {
71
- commands.push({
72
- name: c.data.name,
73
- formattedName: `${c.data.name}`,
74
- description: c.data.description,
75
- category: c.category || null,
76
- commandType: c.commandType,
77
- });
78
- }
79
- });
80
- } else {
81
- commands.push({
82
- name: c.data?.name || c.name,
83
- formattedName: `${c.data?.name || c.name}`,
84
- description: c.data?.description || c.description,
85
- category: c.category || null,
86
- commandType: c.commandType,
87
- });
88
- }
89
- });
90
- return commands;
91
- }
92
- isOwner(userId) {
93
- if (!userId) throw new XernerxError_js_1.default('No ID specified');
94
- let owners = this.client.settings.ownerId;
95
- if (!owners) return false;
96
- if (typeof owners === 'string') owners = [owners];
97
- return owners.includes(userId);
98
- }
99
- getAllCommands() {
100
- const cmds = [];
101
- for (const commands of Object.values(this.client.commands)) {
102
- commands.map((cmd) => cmds.push(cmd));
103
- }
104
- return cmds;
105
- }
106
- getAllMessageCommands() {
107
- const cmds = [];
108
- this.client.commands.message.map((cmd) => cmds.push(cmd));
109
- return cmds;
110
- }
111
- getAllSlashCommands() {
112
- const cmds = [];
113
- this.client.commands.slash.map((cmd) => cmds.push(cmd));
114
- return cmds;
115
- }
116
- getAllContextCommands() {
117
- const cmds = [];
118
- this.client.commands.context.map((cmd) => cmds.push(cmd));
119
- return cmds;
120
- }
121
- setPresence(options) {
122
- const client = this.client;
123
- function pres() {
124
- client.user?.setPresence({
125
- activities: [
126
- {
127
- name: options.text || undefined,
128
- type: options.type || undefined,
129
- url: options.link || undefined,
130
- },
131
- ],
132
- status: options.status || undefined,
133
- });
134
- }
135
- pres();
136
- if (options.interval) {
137
- setInterval(() => {
138
- pres();
139
- }, options.interval);
140
- }
141
- }
142
- getCooldowns(id, command) {
143
- let cooldowns = [];
144
- for (const [key, value] of Object.entries(this.client.cache)) {
145
- if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
146
- if (key === 'commands') {
147
- if (command) {
148
- value.map((x) => {
149
- const name = x.name.split(/-/);
150
- name.pop();
151
- if (name.join('-') === id + '-' + command) {
152
- cooldowns.push(x);
153
- }
154
- });
155
- } else {
156
- value.map((x) => {
157
- if (x.name.split(/-/).shift() === id) {
158
- cooldowns.push(x);
159
- }
160
- });
161
- }
162
- } else {
163
- if (value.has(id)) {
164
- const x = value.get(id);
165
- cooldowns.push(x);
166
- }
167
- }
168
- }
169
- return cooldowns;
170
- }
171
- getCooldownTimers(id, command) {
172
- let cooldowns = [];
173
- for (const [key, value] of Object.entries(this.client.cache)) {
174
- if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
175
- if (key === 'commands') {
176
- if (command) {
177
- value.map((x) => {
178
- const name = x.name.split(/-/);
179
- name.pop();
180
- if (name.join('-') === id + '-' + command) {
181
- cooldowns.push({
182
- [x.commandName]: x.endsAt - Date.now(),
183
- });
184
- }
185
- });
186
- } else {
187
- value.map((x) => {
188
- if (x.name.split(/-/).shift() === id) {
189
- cooldowns.push({
190
- [x.commandName]: x.endsAt - Date.now(),
191
- });
192
- }
193
- });
194
- }
195
- } else {
196
- if (value.has(id)) {
197
- const x = value.get(id);
198
- cooldowns.push({ [key]: x.endsAt - Date.now() });
199
- }
200
- }
201
- }
202
- const sort = cooldowns.map((x) => Object.entries(x).shift()).sort((a, b) => b[1] - a[1]);
203
- cooldowns = [];
204
- sort.map(([key, value]) => cooldowns.push({ [key]: value }));
205
- return cooldowns;
206
- }
207
- async defer(time) {
208
- return new Promise((resolve) => setTimeout(resolve, time || 0));
209
- }
210
- }
211
- exports.ClientUtil = ClientUtil;
@@ -1,58 +0,0 @@
1
- import { ActionRowBuilder, ButtonBuilder, EmbedBuilder, Interaction, Message, MessagePayload, StringSelectMenuBuilder } from 'discord.js';
2
- import XernerxClient from '../client/XernerxClient.js';
3
- import { XernerxMessage } from '../types/types.js';
4
- interface SelectMenuOptions {
5
- index?: EmbedBuilder;
6
- row?: ActionRowBuilder;
7
- component?: StringSelectMenuBuilder;
8
- components?: object[];
9
- reply?: boolean;
10
- id?: string;
11
- filter?: Function;
12
- time?: number;
13
- ephemeral?: boolean;
14
- }
15
- interface ButtonOptions {
16
- index?: number;
17
- buttons?: Array<string>;
18
- reply?: boolean;
19
- row?: ActionRowBuilder;
20
- component?: ButtonBuilder;
21
- components?: object[];
22
- id?: string;
23
- filter?: any;
24
- time?: number;
25
- ephemeral?: boolean;
26
- }
27
- export declare class MessageCommandUtil {
28
- client: XernerxClient;
29
- message: XernerxMessage;
30
- constructor(client: XernerxClient, message: Message & XernerxMessage);
31
- reply(content: MessagePayload | string): Promise<Message<boolean> | undefined>;
32
- send(content: MessagePayload | string): Promise<Message<true> | Message<false> | undefined>;
33
- defer(time: number): Promise<unknown>;
34
- getCommands(): import('@discordjs/collection').Collection<string, import('../main.js').MessageCommandBuilder>;
35
- getCommandName(): void;
36
- selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
37
- buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
38
- buttonMenuPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions & SelectMenuOptions): void;
39
- isOwner(): boolean;
40
- createModal(): void;
41
- }
42
- export declare class InteractionCommandUtil {
43
- client: XernerxClient;
44
- interaction: any;
45
- constructor(client: XernerxClient, interaction: Interaction);
46
- reply(content: MessagePayload | string): any;
47
- defer(time: number): Promise<unknown>;
48
- getCommands():
49
- | import('@discordjs/collection').Collection<string, import('../main.js').SlashCommandBuilder>
50
- | import('@discordjs/collection').Collection<string, import('../main.js').ContextCommandBuilder>;
51
- getCommandName(): void;
52
- selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
53
- buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
54
- buttonMenuPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions & SelectMenuOptions): void;
55
- isOwner(): boolean;
56
- createModal(): void;
57
- }
58
- export {};