xernerx 4.0.5 → 4.1.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 (62) hide show
  1. package/dist/build/SlashCommandBuilder.d.ts +1 -0
  2. package/dist/build/SlashCommandBuilder.js +1 -0
  3. package/dist/functions/deploy.js +5 -1
  4. package/dist/handlers/CommandHandler.js +13 -5
  5. package/dist/handlers/EventHandler.js +1 -1
  6. package/dist/handlers/ExtensionHandler.js +1 -1
  7. package/dist/handlers/InhibitorHandler.js +1 -1
  8. package/dist/main.d.ts +3 -2
  9. package/dist/main.js +3 -2
  10. package/package.json +1 -1
  11. package/dist/build copy/ContextCommandBuilder.d.ts +0 -37
  12. package/dist/build copy/ContextCommandBuilder.js +0 -88
  13. package/dist/build copy/EventBuilder.d.ts +0 -21
  14. package/dist/build copy/EventBuilder.js +0 -34
  15. package/dist/build copy/InhibitorBuilder.d.ts +0 -19
  16. package/dist/build copy/InhibitorBuilder.js +0 -27
  17. package/dist/build copy/MessageCommandBuilder.d.ts +0 -39
  18. package/dist/build copy/MessageCommandBuilder.js +0 -90
  19. package/dist/build copy/SlashCommandBuilder.d.ts +0 -41
  20. package/dist/build copy/SlashCommandBuilder.js +0 -122
  21. package/dist/client/DBLClient.d.ts +0 -8
  22. package/dist/client/DBLClient.js +0 -15
  23. package/dist/client/Top.ggClient.d.ts +0 -1
  24. package/dist/client/Top.ggClient.js +0 -1
  25. package/dist/events/messageCreate.d.ts +0 -1
  26. package/dist/events/messageCreate.js +0 -1
  27. package/dist/functions/AsyncFunctions.d.ts +0 -1
  28. package/dist/functions/AsyncFunctions.js +0 -1
  29. package/dist/functions/getPermissionBitField.d.ts +0 -2
  30. package/dist/functions/getPermissionBitField.js +0 -17
  31. package/dist/functions/hasVoted.d.ts +0 -1
  32. package/dist/functions/hasVoted.js +0 -1
  33. package/dist/functions/voted.d.ts +0 -1
  34. package/dist/functions/voted.js +0 -1
  35. package/dist/models/CommandArguments.d.ts +0 -17
  36. package/dist/models/CommandArguments.js +0 -101
  37. package/dist/models/Events.d.ts +0 -24
  38. package/dist/models/Events.js +0 -297
  39. package/dist/models/Extensions.d.ts +0 -7
  40. package/dist/models/Extensions.js +0 -23
  41. package/dist/models/XernerxUser.d.ts +0 -2
  42. package/dist/models/XernerxUser.js +0 -9
  43. package/dist/tools/classes.d.ts +0 -6
  44. package/dist/tools/classes.js +0 -10
  45. package/dist/tools/loggers.d.ts +0 -4
  46. package/dist/tools/loggers.js +0 -4
  47. package/dist/tools/package.d.ts +0 -42
  48. package/dist/tools/package.js +0 -41
  49. package/dist/types/enums.d.ts +0 -44
  50. package/dist/types/enums.js +0 -35
  51. package/dist/types/options.d.ts +0 -254
  52. package/dist/types/options.js +0 -1
  53. package/dist/utils/CommandUtil.d.ts +0 -58
  54. package/dist/utils/CommandUtil.js +0 -232
  55. package/dist/utils/InteractionArguments.d.ts +0 -1
  56. package/dist/utils/InteractionArguments.js +0 -1
  57. package/dist/validators/CommandValidations.d.ts +0 -12
  58. package/dist/validators/CommandValidations.js +0 -166
  59. package/dist/validators/commands.d.ts +0 -4
  60. package/dist/validators/commands.js +0 -25
  61. /package/dist/validators/{InhibitorValidations.d.ts → inhibitorValidations.d.ts} +0 -0
  62. /package/dist/validators/{InhibitorValidations.js → inhibitorValidations.js} +0 -0
@@ -1,41 +0,0 @@
1
- export default {
2
- name: 'xernerx',
3
- version: '4.0.1',
4
- description: 'A bot framework for discord.js.',
5
- main: 'dist/main.js',
6
- type: 'module',
7
- keywords: ['discord.js', 'discord', 'framework', 'mjs', 'esm', 'cjs', 'ts'],
8
- author: 'Dummi',
9
- license: 'MIT',
10
- homepage: 'https://xernerx.github.io/xernerx',
11
- packageManager: 'npm@8.5.5',
12
- scripts: {
13
- start: 'npm i && npm fund && npm audit fix --force && npm link && tsc -w',
14
- patch: 'npm run write && git add . && npm run commit && npm version patch && npm publish && git push',
15
- minor: 'npm run write && git add . && npm run commit && npm version minor && npm publish && git push',
16
- major: 'npm run write && git add . && npm run commit && npm version major && npm publish && git push',
17
- site: 'git add docs && npm run commit && git push',
18
- commit: 'node ../.scripts/commit.js',
19
- write: 'npm run build && npm run format && node ../.scripts/rewritePackage.js ',
20
- format: 'npx prettier --write src dist',
21
- build: 'tsc && npm run format',
22
- },
23
- repository: {
24
- type: 'git',
25
- url: 'git+https://github.com/xernerx/xernerx.git',
26
- },
27
- bugs: {
28
- url: 'https://github.com/xernerx/xernerx/issues',
29
- },
30
- dependencies: {
31
- 'dbl-sdk': '^1.2.0',
32
- 'discord.js': '^14.9.0',
33
- dumfunctions: '^2.1.2',
34
- 'xernerx-extension-builder': '^0.0.12',
35
- zod: '^3.21.4',
36
- },
37
- devDependencies: {
38
- prettier: '^2.8.7',
39
- typescript: '^5.0.3',
40
- },
41
- };
@@ -1,44 +0,0 @@
1
- import {
2
- SlashCommandStringOption,
3
- SlashCommandNumberOption,
4
- SlashCommandIntegerOption,
5
- SlashCommandBooleanOption,
6
- SlashCommandUserOption,
7
- SlashCommandChannelOption,
8
- SlashCommandRoleOption,
9
- SlashCommandMentionableOption,
10
- } from 'discord.js';
11
- export declare enum InhibitorType {
12
- Member = 'Member',
13
- User = 'User',
14
- Guild = 'Guild',
15
- SlashCommand = 'SlashCommand',
16
- MessageCommand = 'MessageCommand',
17
- ContextCommand = 'ContextCommand',
18
- Command = 'Command',
19
- Message = 'Message',
20
- Interaction = 'Interaction',
21
- Channel = 'Channel',
22
- }
23
- export declare enum CommandType {
24
- Message = 'MessageCommand',
25
- Slash = 'SlashCommand',
26
- Context = 'ContextCommand',
27
- Event = 'Event',
28
- Inhibitor = 'Inhibitor',
29
- MessageCommand = 'MessageCommand',
30
- SlashCommand = 'SlashCommand',
31
- ContextCommand = 'ContextCommand',
32
- }
33
- export declare enum ContextCommandType {
34
- Message = 3,
35
- User = 2,
36
- }
37
- export declare enum EventEmitterType {
38
- Client = 'client',
39
- Rest = 'rest',
40
- Process = 'process',
41
- }
42
- export type SlashCommandOptionChoices = SlashCommandStringOption | SlashCommandNumberOption | SlashCommandIntegerOption;
43
- export type SlashCommandOption = SlashCommandOptionChoices | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption;
44
- export type SlashArgumentTypes = 'String' | 'Number' | 'Boolean' | 'User' | 'Channel' | 'Role' | 'Mentionable' | 'Integer';
@@ -1,35 +0,0 @@
1
- export var InhibitorType;
2
- (function (InhibitorType) {
3
- InhibitorType['Member'] = 'Member';
4
- InhibitorType['User'] = 'User';
5
- InhibitorType['Guild'] = 'Guild';
6
- InhibitorType['SlashCommand'] = 'SlashCommand';
7
- InhibitorType['MessageCommand'] = 'MessageCommand';
8
- InhibitorType['ContextCommand'] = 'ContextCommand';
9
- InhibitorType['Command'] = 'Command';
10
- InhibitorType['Message'] = 'Message';
11
- InhibitorType['Interaction'] = 'Interaction';
12
- InhibitorType['Channel'] = 'Channel';
13
- })((InhibitorType = InhibitorType || (InhibitorType = {})));
14
- export var CommandType;
15
- (function (CommandType) {
16
- CommandType['Message'] = 'MessageCommand';
17
- CommandType['Slash'] = 'SlashCommand';
18
- CommandType['Context'] = 'ContextCommand';
19
- CommandType['Event'] = 'Event';
20
- CommandType['Inhibitor'] = 'Inhibitor';
21
- CommandType['MessageCommand'] = 'MessageCommand';
22
- CommandType['SlashCommand'] = 'SlashCommand';
23
- CommandType['ContextCommand'] = 'ContextCommand';
24
- })((CommandType = CommandType || (CommandType = {})));
25
- export var ContextCommandType;
26
- (function (ContextCommandType) {
27
- ContextCommandType[(ContextCommandType['Message'] = 3)] = 'Message';
28
- ContextCommandType[(ContextCommandType['User'] = 2)] = 'User';
29
- })((ContextCommandType = ContextCommandType || (ContextCommandType = {})));
30
- export var EventEmitterType;
31
- (function (EventEmitterType) {
32
- EventEmitterType['Client'] = 'client';
33
- EventEmitterType['Rest'] = 'rest';
34
- EventEmitterType['Process'] = 'process';
35
- })((EventEmitterType = EventEmitterType || (EventEmitterType = {})));
@@ -1,254 +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
- webhook?: WebhookOptions;
50
- }
51
- export interface ExtensionOptions {
52
- extensions: Array<XernerxExtensionBuilder>;
53
- logging?: boolean;
54
- }
55
- export interface MessageCommandOptions {
56
- name: string;
57
- aliases?: Array<string>;
58
- separator?: string;
59
- description?: string;
60
- info?: string;
61
- category?: string;
62
- prefix?: Array<string> | string;
63
- regex?: string;
64
- channelType?: Array<number>;
65
- cooldown?: number;
66
- ignore?: {
67
- owner?: boolean;
68
- users?: Array<string>;
69
- channels?: Array<string>;
70
- guilds?: Array<string>;
71
- };
72
- strict?: {
73
- owner?: boolean;
74
- users?: Array<string>;
75
- channels?: Array<string>;
76
- guilds?: Array<string>;
77
- };
78
- permissions?: {
79
- client?: Array<string>;
80
- user?: Array<string>;
81
- dm?: boolean;
82
- };
83
- args?: Array<MessageArgumentOptions>;
84
- }
85
- export interface ContextCommandOptions {
86
- name: string;
87
- type: ContextMenuCommandType;
88
- nameLocalizations: Record<Localizations, string>;
89
- description?: string;
90
- info?: string;
91
- category?: string;
92
- channelType?: Array<number> | number;
93
- cooldown?: number;
94
- ignore?: {
95
- owner?: boolean;
96
- users?: Array<string>;
97
- channels?: Array<string>;
98
- guilds?: Array<string>;
99
- };
100
- strict?: {
101
- owner?: boolean;
102
- users?: Array<string>;
103
- channels?: Array<string>;
104
- guilds?: Array<string>;
105
- };
106
- permissions?: {
107
- client?: Array<string>;
108
- users?: Array<string>;
109
- dm?: boolean;
110
- };
111
- defer?: {
112
- reply?: boolean;
113
- ephemeral?: boolean;
114
- fetch?: boolean;
115
- };
116
- }
117
- export interface MessageArgumentOptions {
118
- type: MessageCommandArgsTypes;
119
- content?: Array<string>;
120
- match?: string;
121
- name: string;
122
- prompt?: {
123
- reply: string;
124
- send: string;
125
- };
126
- default?: string | Function;
127
- }
128
- export interface SlashArgumentOptions {
129
- type: 'string' | 'number' | 'boolean' | 'user' | 'channel' | 'role' | 'mentionable' | 'integer';
130
- name: string;
131
- choices: Array<{
132
- name: string;
133
- value: string;
134
- }>;
135
- required: boolean;
136
- description: string;
137
- }
138
- export interface SlashSubcommandOptions {
139
- name: string;
140
- description: string;
141
- args: Array<SlashArgumentOptions>;
142
- }
143
- export interface SlashGroupOptions {
144
- name: string;
145
- description: string;
146
- subcommands: Array<SlashSubcommandOptions>;
147
- }
148
- export interface SlashCommandOptions {
149
- name: string;
150
- description: string;
151
- info?: string;
152
- category?: string;
153
- owner?: boolean;
154
- channelType?: ChannelType;
155
- cooldown?: number;
156
- ignore?: {
157
- owner?: boolean;
158
- users?: Array<string>;
159
- channels?: Array<string>;
160
- guilds?: Array<string>;
161
- };
162
- strict?: {
163
- owner?: boolean;
164
- users?: Array<string>;
165
- channels?: Array<string>;
166
- guilds?: Array<string>;
167
- };
168
- permissions: {
169
- client?: Array<string>;
170
- users?: Array<string>;
171
- dm?: boolean;
172
- };
173
- defer?: {
174
- reply?: boolean;
175
- ephemeral?: boolean;
176
- fetchReply?: boolean;
177
- };
178
- args?: Array<SlashArgumentOptions>;
179
- subcommands?: Array<SlashSubcommandOptions>;
180
- groups?: Array<SlashGroupOptions>;
181
- }
182
- export interface MessageCommandHandlerOptions {
183
- directory: string;
184
- prefix: string[] | string;
185
- allowMention?: boolean;
186
- cooldown?: number;
187
- userPermissions?: bigint[];
188
- clientPermissions?: bigint[];
189
- handleEdits?: boolean;
190
- handleDeletes?: boolean;
191
- handleTyping?: boolean;
192
- util?: boolean;
193
- logging?: boolean;
194
- }
195
- export interface SlashCommandHandlerOptions {
196
- directory: string;
197
- guildId: string;
198
- global: boolean;
199
- cooldown?: number;
200
- userPermissions?: bigint[];
201
- clientPermissions?: bigint[];
202
- util?: boolean;
203
- logging?: boolean;
204
- defer?: {
205
- reply?: boolean;
206
- ephemeral?: boolean;
207
- fetchReply?: boolean;
208
- };
209
- }
210
- export interface ContextCommandHandlerOptions {
211
- directory: string;
212
- guildId: string;
213
- global: boolean;
214
- cooldown?: number;
215
- userPermissions?: bigint[];
216
- clientPermissions?: bigint[];
217
- util?: boolean;
218
- logging?: boolean;
219
- defer?: {
220
- reply?: boolean;
221
- ephemeral?: boolean;
222
- fetchReply?: boolean;
223
- };
224
- }
225
- export interface EventHandlerOptions {
226
- directory: string;
227
- logging?: boolean;
228
- }
229
- export interface EventOptions {
230
- name: string;
231
- emitter?: EventEmitterType | string;
232
- type?: 'discord' | string;
233
- once?: boolean;
234
- }
235
- export interface InhibitorHandlerOptions {
236
- directory: string;
237
- logging?: boolean;
238
- }
239
- export interface InhibitorOptions {
240
- name: string;
241
- type: InhibitorType;
242
- }
243
- export interface WebhookOptions {
244
- topgg: {
245
- token: string;
246
- };
247
- dbl: {
248
- token: string;
249
- };
250
- config: {
251
- emits: boolean;
252
- logs: boolean;
253
- };
254
- }
@@ -1 +0,0 @@
1
- export {};
@@ -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 {};
@@ -1,232 +0,0 @@
1
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder } from 'discord.js';
2
- import XernerxError from '../tools/XernerxError.js';
3
- export class MessageCommandUtil {
4
- client;
5
- message;
6
- constructor(client, message) {
7
- this.client = client;
8
- this.message = message;
9
- }
10
- async reply(content) {
11
- if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
12
- if (!existingMessage) {
13
- const msg = await this.message.reply(content);
14
- this.message.response = msg.id;
15
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
16
- this.client.cache.messages.set(this.message.id, this.message);
17
- setInterval(() => {
18
- this.client.cache.messages.delete(this.message.id);
19
- }, this.client.settings.cooldown?.cache || 300000);
20
- }
21
- return msg;
22
- }
23
- if (existingMessage && this.client.handlerOptions.message?.handleEdits) {
24
- try {
25
- const msg = await this.message.channel.messages.fetch(existingMessage.response);
26
- msg.edit(content);
27
- return msg;
28
- } catch {
29
- const msg = await this.message.reply(content);
30
- this.message.response = msg.id;
31
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
32
- this.client.cache.messages.set(this.message.id, this.message);
33
- setInterval(() => {
34
- this.client.cache.messages.delete(this.message.id);
35
- }, this.client.settings.cooldown?.cache || 300000);
36
- }
37
- }
38
- }
39
- }
40
- async send(content) {
41
- if (this.client.cache.messages.has(this.message.id)) var existingMessage = this.client.cache.messages.get(this.message.id);
42
- if (!existingMessage) {
43
- const msg = await this.message.channel.send(content);
44
- this.message.response = msg.id;
45
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
46
- this.client.cache.messages.set(this.message.id, this.message);
47
- setInterval(() => {
48
- this.client.cache.messages.delete(this.message.id);
49
- }, this.client.settings.cooldown?.cache || 300000);
50
- }
51
- return msg;
52
- }
53
- if (existingMessage && this.client.handlerOptions.message?.handleEdits) {
54
- try {
55
- const msg = await this.message.channel.messages.fetch(existingMessage.response);
56
- msg.edit(content);
57
- return msg;
58
- } catch {
59
- const msg = await this.message.channel.send(content);
60
- this.message.response = msg.id;
61
- if (this.client.handlerOptions.message?.handleEdits || this.client.handlerOptions.message?.handleDeletes) {
62
- this.client.cache.messages.set(this.message.id, this.message);
63
- setInterval(() => {
64
- this.client.cache.messages.delete(this.message.id);
65
- }, this.client.settings.cooldown?.cache || 300000);
66
- }
67
- }
68
- }
69
- }
70
- async defer(time) {
71
- return new Promise((resolve) => setTimeout(resolve, time));
72
- }
73
- getCommands() {
74
- return this.client.commands.message;
75
- }
76
- getCommandName() {}
77
- selectMenuPaginator(embeds, options) {}
78
- buttonPaginator(embeds, options) {}
79
- buttonMenuPaginator(embeds, options) {}
80
- isOwner() {
81
- return this.client.util.isOwner(this.message.author.id);
82
- }
83
- createModal() {}
84
- }
85
- export class InteractionCommandUtil {
86
- client;
87
- interaction;
88
- constructor(client, interaction) {
89
- this.client = client;
90
- this.interaction = interaction;
91
- }
92
- reply(content) {
93
- return this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content);
94
- }
95
- async defer(time) {
96
- return new Promise((resolve) => setTimeout(resolve, time));
97
- }
98
- getCommands() {
99
- if (this.interaction.commandType === 1) return this.client.commands.slash;
100
- else return this.client.commands.context;
101
- }
102
- getCommandName() {}
103
- selectMenuPaginator(embeds, options) {
104
- if (!Array.isArray(embeds)) throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
105
- if (embeds.length > 25) throw new XernerxError(`Max select menu length is 25.`);
106
- if (typeof options !== 'object') options = {};
107
- if (!Array.isArray(options.components)) options.components = [];
108
- if (!options.index) {
109
- options.index = new EmbedBuilder().setTitle('Index').setColor('Random');
110
- for (const embed of embeds) {
111
- options.index.addFields([
112
- {
113
- name: embed.data.title || 'No Name',
114
- value: embed.data.description || 'Page',
115
- inline: embeds.length > 25 / 2 ? true : false,
116
- },
117
- ]);
118
- }
119
- }
120
- if (!options.row) {
121
- options.row = new ActionRowBuilder();
122
- if (!options.id) options.id = `${this.interaction.id}-menu`;
123
- options.component = new StringSelectMenuBuilder().setCustomId(options.id).setMaxValues(1).setMinValues(1).setPlaceholder('Select a page.').addOptions({ label: 'index', value: '0' });
124
- embeds.map((embed, i = 0) => {
125
- options?.component?.addOptions({
126
- label: embed.data.title || 'No Name',
127
- description: embed.data.description || `Page ${i}`,
128
- value: String(i + 1),
129
- });
130
- });
131
- options.row.addComponents(options.component);
132
- }
133
- embeds.unshift(options.index);
134
- const content = {
135
- embeds: [options.index],
136
- components: [options.row, ...options.components],
137
- ephemeral: !!options.ephemeral,
138
- };
139
- (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then(() => {
140
- const collector = this.interaction.channel
141
- .createMessageComponentCollector({
142
- filter: options?.filter,
143
- time: options?.time || 60000,
144
- })
145
- .on('collect', (interaction) => {
146
- if (!interaction.customId.startsWith(this.interaction.id)) return;
147
- interaction.update({
148
- embeds: [embeds[parseInt(interaction.values[0])]],
149
- });
150
- })
151
- .on('end', () => {
152
- this.interaction.editReply({ components: [] });
153
- });
154
- });
155
- }
156
- buttonPaginator(embeds, options) {
157
- if (!Array.isArray(embeds)) throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
158
- if (embeds.length <= 0) throw new XernerxError(`The minimum embeds is 1.`);
159
- if (typeof options !== 'object') options = {};
160
- if (!Array.isArray(options.components)) options.components = [];
161
- if (!options.row) {
162
- options.row = new ActionRowBuilder();
163
- if (!options.id) options.id = `${this.interaction.id}-menu`;
164
- }
165
- if (!options.buttons) options.buttons = ['⏮️', '◀️', '⏹️', '▶️', '⏭️'];
166
- for (const button of options.buttons) {
167
- options.row.addComponents(
168
- new ButtonBuilder()
169
- .setCustomId(`${this.interaction.id}-${options.buttons.indexOf(button)}`)
170
- .setEmoji(button)
171
- .setStyle(ButtonStyle.Primary)
172
- );
173
- }
174
- let embed = embeds[options.index || 0];
175
- const content = {
176
- embeds: [embed],
177
- components: [options.row, ...options.components],
178
- ephemeral: !!options.ephemeral,
179
- };
180
- (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then((message) => {
181
- const collector = message.channel
182
- .createMessageComponentCollector({
183
- filter: options.filter,
184
- time: options?.time || 60000,
185
- })
186
- .on('collect', (interaction) => {
187
- let stop = false;
188
- if (interaction.customId.startsWith(this.interaction.id)) {
189
- switch (Number(interaction.customId.split(/-/).pop())) {
190
- case 0: {
191
- embed = embeds[0];
192
- break;
193
- }
194
- case 1: {
195
- embed = embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
196
- break;
197
- }
198
- case 2: {
199
- collector.stop();
200
- stop = true;
201
- break;
202
- }
203
- case 3: {
204
- embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
205
- break;
206
- }
207
- case 4: {
208
- embed = embeds[embeds.length - 1];
209
- break;
210
- }
211
- }
212
- stop
213
- ? interaction.update({
214
- embeds: [embed],
215
- components: [],
216
- })
217
- : interaction.update({
218
- embeds: [embed],
219
- });
220
- }
221
- })
222
- .on('end', () => {
223
- this.interaction.editReply({ components: [] });
224
- });
225
- });
226
- }
227
- buttonMenuPaginator(embeds, options) {}
228
- isOwner() {
229
- return this.client.util.isOwner(this.interaction.user.id);
230
- }
231
- createModal() {}
232
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import { Interaction } from 'discord.js';
2
- import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
3
- import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
4
- import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
5
- import XernerxClient from '../client/XernerxClient.js';
6
- import { XernerxMessage } from '../types/types.js';
7
- export default function commandValidation(
8
- action: XernerxMessage | Interaction,
9
- command: SlashCommandBuilder | MessageCommandBuilder | ContextCommandBuilder | any,
10
- client: XernerxClient,
11
- res?: boolean
12
- ): boolean;