xernerx 2.7.5 → 3.0.1

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 (76) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +0 -0
  3. package/dist/build/ContextCommand.d.ts +39 -0
  4. package/dist/build/ContextCommand.js +86 -0
  5. package/dist/build/Event.d.ts +15 -0
  6. package/dist/build/Event.js +31 -0
  7. package/dist/build/Inhibitor.d.ts +12 -0
  8. package/dist/build/Inhibitor.js +20 -0
  9. package/dist/build/MessageCommand.d.ts +39 -0
  10. package/dist/build/MessageCommand.js +77 -0
  11. package/dist/build/SlashCommand.d.ts +32 -0
  12. package/dist/build/SlashCommand.js +119 -0
  13. package/dist/client/XernerxClient.d.ts +22 -0
  14. package/dist/client/XernerxClient.js +76 -0
  15. package/dist/handlers/CommandHandler.d.ts +27 -0
  16. package/dist/handlers/CommandHandler.js +42 -0
  17. package/dist/handlers/EventHandler.d.ts +13 -0
  18. package/dist/handlers/EventHandler.js +16 -0
  19. package/dist/handlers/Handler.d.ts +37 -0
  20. package/dist/handlers/Handler.js +242 -0
  21. package/dist/handlers/InhibitorHandler.d.ts +18 -0
  22. package/dist/handlers/InhibitorHandler.js +21 -0
  23. package/dist/interfaces/ClientInterfaces.d.ts +58 -0
  24. package/dist/interfaces/ClientInterfaces.js +1 -0
  25. package/dist/interfaces/CommandInterfaces.d.ts +94 -0
  26. package/dist/interfaces/CommandInterfaces.js +1 -0
  27. package/dist/interfaces/HandlerInterfaces.d.ts +70 -0
  28. package/dist/interfaces/HandlerInterfaces.js +1 -0
  29. package/dist/main.d.ts +26 -0
  30. package/dist/main.js +40 -0
  31. package/dist/models/CommandArguments.d.ts +9 -0
  32. package/dist/models/CommandArguments.js +128 -0
  33. package/dist/models/CommandValidations.d.ts +3 -0
  34. package/dist/models/CommandValidations.js +193 -0
  35. package/dist/models/Events.d.ts +23 -0
  36. package/dist/models/Events.js +328 -0
  37. package/dist/models/Functions.d.ts +1 -0
  38. package/dist/models/Functions.js +30 -0
  39. package/dist/models/InhibitorValidations.d.ts +17 -0
  40. package/dist/models/InhibitorValidations.js +42 -0
  41. package/dist/types/EventTypes.d.ts +1 -0
  42. package/dist/types/EventTypes.js +1 -0
  43. package/dist/types/InhibitorTypes.d.ts +12 -0
  44. package/dist/types/InhibitorTypes.js +13 -0
  45. package/dist/types/Types.d.ts +24 -0
  46. package/dist/types/Types.js +21 -0
  47. package/dist/utils/ClientUtil.d.ts +25 -0
  48. package/dist/utils/ClientUtil.js +232 -0
  49. package/dist/utils/CommandUtil.d.ts +38 -0
  50. package/dist/utils/CommandUtil.js +238 -0
  51. package/package.json +5 -8
  52. package/main.js +0 -49
  53. package/models/Client.js +0 -60
  54. package/models/commands/ContextMenuCommand.js +0 -68
  55. package/models/commands/Event.js +0 -33
  56. package/models/commands/Inhibitor.js +0 -31
  57. package/models/commands/InteractionCommand.js +0 -142
  58. package/models/commands/MessageCommand.js +0 -86
  59. package/models/data/colors.json +0 -16
  60. package/models/data/options.json +0 -27
  61. package/models/events/interactionCreate.js +0 -84
  62. package/models/events/messageCreate.js +0 -84
  63. package/models/events/messageUpdate.js +0 -83
  64. package/models/events/readyOnce.js +0 -58
  65. package/models/handlers/CommandHandler.js +0 -37
  66. package/models/handlers/EventHandler.js +0 -67
  67. package/models/handlers/Handler.js +0 -111
  68. package/models/handlers/InhibitorHandler.js +0 -16
  69. package/models/handlers/LanguageHandler.js +0 -37
  70. package/models/utils/Arguments.js +0 -120
  71. package/models/utils/CommandValidation.js +0 -96
  72. package/models/utils/CommandsUtil.js +0 -70
  73. package/models/utils/Functions.js +0 -266
  74. package/models/utils/InhibitorsUtil.js +0 -24
  75. package/models/utils/InhibitorsValidation.js +0 -40
  76. package/models/utils/Util.js +0 -96
@@ -0,0 +1,232 @@
1
+ export class ClientUtil {
2
+ client;
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ uptime(timestamp) {
7
+ if (!timestamp)
8
+ timestamp = this.client.uptime || 0;
9
+ let totalSeconds = timestamp / 1000;
10
+ let years = Math.floor(totalSeconds / 31536000);
11
+ totalSeconds %= 31536000;
12
+ let days = Math.floor(totalSeconds / 86400);
13
+ totalSeconds %= 86400;
14
+ let hours = Math.floor(totalSeconds / 3600);
15
+ totalSeconds %= 3600;
16
+ let minutes = Math.floor(totalSeconds / 60);
17
+ let seconds = Math.floor(totalSeconds % 60);
18
+ if (years >= 1)
19
+ return `${years}y ${days}d ${hours}h ${minutes}m`;
20
+ else if (days >= 1)
21
+ return `${days}d ${hours}h ${minutes}m`;
22
+ else if (hours >= 1)
23
+ return `${hours}h ${minutes}m`;
24
+ else if (minutes >= 1)
25
+ return `${minutes}m ${seconds}s`;
26
+ else
27
+ return `${seconds}s`;
28
+ }
29
+ getSubcommands(name) {
30
+ if (!name || typeof name !== "string")
31
+ throw new Error(`Expected name to be of type string, received ${typeof name} instead!`);
32
+ const commands = [];
33
+ this.getAllCommands()
34
+ .filter((c) => (c.data?.name?.toLowerCase() || c.name?.toLowerCase()) ==
35
+ name?.toLowerCase())
36
+ .map((c) => {
37
+ if (c?.data?.options?.length > 0) {
38
+ c?.data?.options?.map((option) => {
39
+ if (!option?.type) {
40
+ if (option?.options?.length > 0) {
41
+ option?.options?.map((opt) => {
42
+ if (!opt.type) {
43
+ commands.push({
44
+ name: c.data.name,
45
+ formattedName: `${c.data.name} ${option.name} ${opt.name}`,
46
+ description: opt.description,
47
+ category: c.category || null,
48
+ commandType: c.commandType,
49
+ });
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
+ }
62
+ else {
63
+ commands.push({
64
+ name: c.data.name,
65
+ formattedName: `${c.data.name} ${option.name}`,
66
+ description: option.description,
67
+ category: c.category || null,
68
+ commandType: c.commandType,
69
+ });
70
+ }
71
+ }
72
+ else {
73
+ commands.push({
74
+ name: c.data.name,
75
+ formattedName: `${c.data.name}`,
76
+ description: c.data.description,
77
+ category: c.category || null,
78
+ commandType: c.commandType,
79
+ });
80
+ }
81
+ });
82
+ }
83
+ else {
84
+ commands.push({
85
+ name: c.data?.name || c.name,
86
+ formattedName: `${c.data?.name || c.name}`,
87
+ description: c.data?.description || c.description,
88
+ category: c.category || null,
89
+ commandType: c.commandType,
90
+ });
91
+ }
92
+ });
93
+ return commands;
94
+ }
95
+ isOwner(userId) {
96
+ if (!userId)
97
+ throw new Error("No ID specified");
98
+ let owners = this.client.settings.ownerId;
99
+ if (!owners)
100
+ return false;
101
+ if (typeof owners === "string")
102
+ owners = [owners];
103
+ return owners.includes(userId);
104
+ }
105
+ getAllCommands() {
106
+ const cmds = [];
107
+ for (const commands of Object.values(this.client.commands)) {
108
+ commands.map((cmd) => cmds.push(cmd));
109
+ }
110
+ return cmds;
111
+ }
112
+ getAllMessageCommands() {
113
+ const cmds = [];
114
+ this.client.commands.message.map((cmd) => cmds.push(cmd));
115
+ return cmds;
116
+ }
117
+ getAllSlashCommands() {
118
+ const cmds = [];
119
+ this.client.commands.slash.map((cmd) => cmds.push(cmd));
120
+ return cmds;
121
+ }
122
+ getAllContextCommands() {
123
+ const cmds = [];
124
+ this.client.commands.context.map((cmd) => cmds.push(cmd));
125
+ return cmds;
126
+ }
127
+ setPresence(options) {
128
+ const client = this.client;
129
+ function pres() {
130
+ client.user?.setPresence({
131
+ activities: [
132
+ {
133
+ name: options.text || undefined,
134
+ type: options.type || undefined,
135
+ url: options.link || undefined,
136
+ },
137
+ ],
138
+ status: options.status || undefined,
139
+ });
140
+ }
141
+ pres();
142
+ if (options.interval) {
143
+ setInterval(() => {
144
+ pres();
145
+ }, options.interval);
146
+ }
147
+ }
148
+ getCooldowns(id, command) {
149
+ let cooldowns = [];
150
+ for (const [key, value] of Object.entries(this.client.cache)) {
151
+ if (![
152
+ "cooldowns",
153
+ "messageCommands",
154
+ "slashCommands",
155
+ "contextCommands",
156
+ "commands",
157
+ ].includes(key))
158
+ continue;
159
+ if (key === "commands") {
160
+ if (command) {
161
+ value.map((x) => {
162
+ const name = x.name.split(/-/);
163
+ name.pop();
164
+ if (name.join("-") === id + "-" + command) {
165
+ cooldowns.push(x);
166
+ }
167
+ });
168
+ }
169
+ else {
170
+ value.map((x) => {
171
+ if (x.name.split(/-/).shift() === id) {
172
+ cooldowns.push(x);
173
+ }
174
+ });
175
+ }
176
+ }
177
+ else {
178
+ if (value.has(id)) {
179
+ const x = value.get(id);
180
+ cooldowns.push(x);
181
+ }
182
+ }
183
+ }
184
+ return cooldowns;
185
+ }
186
+ getCooldownTimers(id, command) {
187
+ let cooldowns = [];
188
+ for (const [key, value] of Object.entries(this.client.cache)) {
189
+ if (![
190
+ "cooldowns",
191
+ "messageCommands",
192
+ "slashCommands",
193
+ "contextCommands",
194
+ "commands",
195
+ ].includes(key))
196
+ continue;
197
+ if (key === "commands") {
198
+ if (command) {
199
+ value.map((x) => {
200
+ const name = x.name.split(/-/);
201
+ name.pop();
202
+ if (name.join("-") === id + "-" + command) {
203
+ cooldowns.push({ [x.commandName]: x.endsAt - Date.now() });
204
+ }
205
+ });
206
+ }
207
+ else {
208
+ value.map((x) => {
209
+ if (x.name.split(/-/).shift() === id) {
210
+ cooldowns.push({ [x.commandName]: x.endsAt - Date.now() });
211
+ }
212
+ });
213
+ }
214
+ }
215
+ else {
216
+ if (value.has(id)) {
217
+ const x = value.get(id);
218
+ cooldowns.push({ [key]: x.endsAt - Date.now() });
219
+ }
220
+ }
221
+ }
222
+ const sort = cooldowns
223
+ .map((x) => Object.entries(x).shift())
224
+ .sort((a, b) => b[1] - a[1]);
225
+ cooldowns = [];
226
+ sort.map(([key, value]) => cooldowns.push({ [key]: value }));
227
+ return cooldowns;
228
+ }
229
+ async defer(time) {
230
+ return new Promise((resolve) => setTimeout(resolve, time || 0));
231
+ }
232
+ }
@@ -0,0 +1,38 @@
1
+ import { ActionRowBuilder, ButtonBuilder, EmbedBuilder, Interaction, Message, MessagePayload } from "discord.js";
2
+ import XernerxClient from "../client/XernerxClient.js";
3
+ import { XernerxMessage } from "../interfaces/HandlerInterfaces.js";
4
+ interface ButtonOptions {
5
+ index?: number;
6
+ buttons?: Array<string>;
7
+ reply?: boolean;
8
+ row?: ActionRowBuilder;
9
+ component?: ButtonBuilder;
10
+ components?: object[];
11
+ id?: string;
12
+ filter?: any;
13
+ time?: number;
14
+ ephemeral?: boolean;
15
+ }
16
+ export declare class MessageCommandUtil {
17
+ #private;
18
+ client: XernerxClient;
19
+ message: XernerxMessage;
20
+ constructor(client: XernerxClient, message: Message & XernerxMessage);
21
+ reply(content: MessagePayload | string): Promise<Message<boolean> | undefined>;
22
+ send(content: MessagePayload | string): Promise<Message<true> | Message<false> | undefined>;
23
+ defer(time: number): Promise<unknown>;
24
+ getCommands(): import("@discordjs/collection").Collection<string, import("../main.js").MessageCommand>;
25
+ isOwner(): boolean;
26
+ }
27
+ export declare class InteractionCommandUtil {
28
+ #private;
29
+ client: XernerxClient;
30
+ interaction: any;
31
+ constructor(client: XernerxClient, interaction: Interaction);
32
+ reply(content: MessagePayload | string): any;
33
+ defer(time: number): Promise<unknown>;
34
+ getCommands(): import("@discordjs/collection").Collection<string, object>;
35
+ buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
36
+ isOwner(): boolean;
37
+ }
38
+ export {};
@@ -0,0 +1,238 @@
1
+ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, SelectMenuBuilder, } from "discord.js";
2
+ export class MessageCommandUtil {
3
+ client;
4
+ message;
5
+ constructor(client, message) {
6
+ this.client = client;
7
+ this.message = message;
8
+ }
9
+ async reply(content) {
10
+ if (this.client.cache.messages.has(this.message.id))
11
+ 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 ||
16
+ this.client.handlerOptions.message?.handleDeletes) {
17
+ this.client.cache.messages.set(this.message.id, this.message);
18
+ setInterval(() => {
19
+ this.client.cache.messages.delete(this.message.id);
20
+ }, this.client.settings.cooldown?.cache || 300000);
21
+ }
22
+ return msg;
23
+ }
24
+ if (existingMessage && this.client.handlerOptions.message?.handleEdits) {
25
+ try {
26
+ const msg = await this.message.channel.messages.fetch(existingMessage.response);
27
+ msg.edit(content);
28
+ return msg;
29
+ }
30
+ catch {
31
+ const msg = await this.message.reply(content);
32
+ this.message.response = msg.id;
33
+ if (this.client.handlerOptions.message?.handleEdits ||
34
+ this.client.handlerOptions.message?.handleDeletes) {
35
+ this.client.cache.messages.set(this.message.id, this.message);
36
+ setInterval(() => {
37
+ this.client.cache.messages.delete(this.message.id);
38
+ }, this.client.settings.cooldown?.cache || 300000);
39
+ }
40
+ }
41
+ }
42
+ }
43
+ async send(content) {
44
+ if (this.client.cache.messages.has(this.message.id))
45
+ var existingMessage = this.client.cache.messages.get(this.message.id);
46
+ if (!existingMessage) {
47
+ const msg = await this.message.channel.send(content);
48
+ this.message.response = msg.id;
49
+ if (this.client.handlerOptions.message?.handleEdits ||
50
+ this.client.handlerOptions.message?.handleDeletes) {
51
+ this.client.cache.messages.set(this.message.id, this.message);
52
+ setInterval(() => {
53
+ this.client.cache.messages.delete(this.message.id);
54
+ }, this.client.settings.cooldown?.cache || 300000);
55
+ }
56
+ return msg;
57
+ }
58
+ if (existingMessage && this.client.handlerOptions.message?.handleEdits) {
59
+ try {
60
+ const msg = await this.message.channel.messages.fetch(existingMessage.response);
61
+ msg.edit(content);
62
+ return msg;
63
+ }
64
+ catch {
65
+ const msg = await this.message.channel.send(content);
66
+ this.message.response = msg.id;
67
+ if (this.client.handlerOptions.message?.handleEdits ||
68
+ this.client.handlerOptions.message?.handleDeletes) {
69
+ this.client.cache.messages.set(this.message.id, this.message);
70
+ setInterval(() => {
71
+ this.client.cache.messages.delete(this.message.id);
72
+ }, this.client.settings.cooldown?.cache || 300000);
73
+ }
74
+ }
75
+ }
76
+ }
77
+ async defer(time) {
78
+ return new Promise((resolve) => setTimeout(resolve, time));
79
+ }
80
+ getCommands() {
81
+ return this.client.commands.message;
82
+ }
83
+ #getCommandName() { }
84
+ #selectMenuPaginator(embeds, options) { }
85
+ #buttonPaginator(embeds, options) { }
86
+ #buttonMenuPaginator(embeds, options) { }
87
+ isOwner() {
88
+ return this.client.util.isOwner(this.message.author.id);
89
+ }
90
+ #createModal() { }
91
+ }
92
+ export class InteractionCommandUtil {
93
+ client;
94
+ interaction;
95
+ constructor(client, interaction) {
96
+ this.client = client;
97
+ this.interaction = interaction;
98
+ }
99
+ reply(content) {
100
+ return this.interaction.replied || this.interaction.deferred
101
+ ? this.interaction.editReply(content)
102
+ : this.interaction.reply(content);
103
+ }
104
+ async defer(time) {
105
+ return new Promise((resolve) => setTimeout(resolve, time));
106
+ }
107
+ getCommands() {
108
+ if (this.interaction.commandType === 1)
109
+ return this.client.commands.slash;
110
+ else
111
+ return this.client.commands.context;
112
+ }
113
+ #getCommandName() { }
114
+ #selectMenuPaginator(embeds, options) {
115
+ if (!Array.isArray(embeds))
116
+ throw new Error(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
117
+ if (embeds.length > 25)
118
+ throw new Error(`Max select menu length is 25.`);
119
+ if (typeof options !== "object")
120
+ options = {};
121
+ if (!Array.isArray(options.components))
122
+ options.components = [];
123
+ if (!options.index) {
124
+ options.index = new EmbedBuilder().setTitle("Index").setColor("Random");
125
+ for (const embed of embeds) {
126
+ options.index.addFields([
127
+ {
128
+ name: embed.data.title || "No Name",
129
+ value: embed.data.description || "Page",
130
+ inline: embeds.length > 25 / 2 ? true : false,
131
+ },
132
+ ]);
133
+ }
134
+ }
135
+ if (!options.row) {
136
+ options.row = new ActionRowBuilder();
137
+ if (!options.id)
138
+ options.id = `${this.interaction.id}-menu`;
139
+ options.component = new SelectMenuBuilder()
140
+ .setCustomId(options.id)
141
+ .setMaxValues(1)
142
+ .setMinValues(1)
143
+ .setPlaceholder("Select a page.")
144
+ .addOptions({ label: "index", value: "index" });
145
+ embeds.map((embed, i = 0) => { });
146
+ options.row.addComponents(options.component);
147
+ }
148
+ const content = {
149
+ embeds: [options.index],
150
+ components: [options.component, ...options.components],
151
+ ephemeral: !!options.ephemeral,
152
+ };
153
+ options.reply === undefined || options.reply === true
154
+ ? this.interaction.util.reply(content)
155
+ : this.interaction.channel.send(content);
156
+ }
157
+ buttonPaginator(embeds, options) {
158
+ if (!Array.isArray(embeds))
159
+ throw new Error(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
160
+ if (embeds.length <= 0)
161
+ throw new Error(`The minimum embeds is 1.`);
162
+ if (typeof options !== "object")
163
+ options = {};
164
+ if (!Array.isArray(options.components))
165
+ options.components = [];
166
+ if (!options.row) {
167
+ options.row = new ActionRowBuilder();
168
+ if (!options.id)
169
+ options.id = `${this.interaction.id}-menu`;
170
+ }
171
+ if (!options.buttons)
172
+ options.buttons = ["⏮️", "◀️", "⏹️", "▶️", "⏭️"];
173
+ for (const button of options.buttons) {
174
+ options.row.addComponents(new ButtonBuilder()
175
+ .setCustomId(`${this.interaction.id}-${options.buttons.indexOf(button)}`)
176
+ .setEmoji(button)
177
+ .setStyle(ButtonStyle.Primary));
178
+ }
179
+ let embed = embeds[options.index || 0];
180
+ const content = {
181
+ embeds: [embed],
182
+ components: [options.row, ...options.components],
183
+ ephemeral: !!options.ephemeral,
184
+ };
185
+ (options.reply === undefined || options.reply === true
186
+ ? this.interaction.util.reply(content)
187
+ : this.interaction.channel.send(content)).then((message) => {
188
+ const collector = message.channel
189
+ .createMessageComponentCollector({
190
+ filter: options.filter,
191
+ time: options?.time || 60000,
192
+ })
193
+ .on("collect", (interaction) => {
194
+ let stop = false;
195
+ if (interaction.customId.startsWith(this.interaction.id)) {
196
+ switch (Number(interaction.customId.split(/-/).pop())) {
197
+ case 0: {
198
+ embed = embeds[0];
199
+ break;
200
+ }
201
+ case 1: {
202
+ embed =
203
+ embeds[embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0];
204
+ break;
205
+ }
206
+ case 2: {
207
+ collector.stop();
208
+ stop = true;
209
+ break;
210
+ }
211
+ case 3: {
212
+ embed =
213
+ embeds[embeds.indexOf(embed) < embeds.length - 1
214
+ ? embeds.indexOf(embed) + 1
215
+ : embeds.length - 1];
216
+ break;
217
+ }
218
+ case 4: {
219
+ embed = embeds[embeds.length - 1];
220
+ break;
221
+ }
222
+ }
223
+ stop
224
+ ? interaction.update({ embeds: [embed], components: [] })
225
+ : interaction.update({ embeds: [embed] });
226
+ }
227
+ })
228
+ .on("end", () => {
229
+ this.interaction.editReply({ components: [] });
230
+ });
231
+ });
232
+ }
233
+ #buttonMenuPaginator(embeds, options) { }
234
+ isOwner() {
235
+ return this.client.util.isOwner(this.interaction.user.id);
236
+ }
237
+ #createModal() { }
238
+ }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
+ "type": "module",
2
3
  "name": "xernerx",
3
- "version": "2.7.5",
4
+ "version": "3.0.1",
4
5
  "description": "A bot framework for discord.js. [BETA]",
5
- "main": "main.js",
6
+ "main": "dist/main.js",
6
7
  "scripts": {
7
8
  "test": "echo Setup a bot then start the bot."
8
9
  },
@@ -17,12 +18,8 @@
17
18
  },
18
19
  "homepage": "https://github.com/TheDummi/xernerx#readme",
19
20
  "dependencies": {
20
- "@discordjs/rest": "1.2.0",
21
- "@sapphire/shapeshift": "3.6.0",
22
- "discord-api-types": "^0.37.11",
23
- "discord.js": "^14.5.0",
24
- "dumfunctions": "^1.0.7",
25
- "i18next": "^21.9.2"
21
+ "@sapphire/shapeshift": "^3.7.0",
22
+ "discord.js": "^14.6.0"
26
23
  },
27
24
  "packageManager": "npm@8.5.5"
28
25
  }
package/main.js DELETED
@@ -1,49 +0,0 @@
1
- const { Client } = require('./models/Client.js'),
2
- { CommandHandler } = require('./models/handlers/CommandHandler.js'),
3
- { EventHandler } = require('./models/handlers/EventHandler.js'),
4
- { MessageCommand } = require('./models/commands/MessageCommand.js'),
5
- { InteractionCommand } = require('./models/commands/InteractionCommand.js'),
6
- { Event } = require('./models/commands/Event.js'),
7
- { Inhibitor } = require('./models/commands/Inhibitor.js'),
8
- { LanguageHandler } = require('./models/handlers/LanguageHandler.js'),
9
- { ContextMenuCommand } = require('./models/commands/ContextMenuCommand.js'),
10
- pkg = require('./package.json'),
11
- Dumfunctions = require('dumfunctions'),
12
- Discord = require('discord.js'),
13
- i18next = require('i18next');
14
-
15
- const exp = {
16
- // Client
17
- XernerxClient: Client,
18
-
19
- // Handlers
20
- CommandHandler,
21
- EventHandler,
22
- LanguageHandler,
23
-
24
- // Commands
25
- MessageCommand,
26
- InteractionCommand,
27
- ContextMenuCommand,
28
-
29
- // Events
30
- Event,
31
-
32
- Inhibitor,
33
-
34
- // Discord
35
- Discord,
36
- i18next,
37
- functions: Dumfunctions,
38
-
39
- // Details
40
- version: pkg.version,
41
- }
42
-
43
- for (const [key, val] of Object.entries(Discord)) {
44
- if (key == 'version') continue;
45
-
46
- exp[key] = val;
47
- }
48
-
49
- module.exports = exp;
package/models/Client.js DELETED
@@ -1,60 +0,0 @@
1
- const Discord = require('discord.js');
2
- const { s } = require('@sapphire/shapeshift');
3
- const { color } = require('./utils/Functions.js');
4
- const { CommandHandler } = require('./handlers/CommandHandler.js');
5
- const { EventHandler } = require('./handlers/EventHandler.js');
6
- const { LanguageHandler } = require('./handlers/LanguageHandler.js');
7
- const InhibitorHandler = require('./handlers/InhibitorHandler.js');
8
- const Handler = require('./handlers/Handler.js');
9
-
10
- class Client extends Discord.Client {
11
- constructor(options = {}, settings = {}, i18next = {}, config = {}) {
12
- super(options)
13
-
14
- this.client = new Discord.Client({ intents: options.intents });
15
-
16
- this.client.settings = s.object({
17
- guildId: s.string.default(undefined),
18
- global: s.boolean.default(false),
19
- prefix: s.array(s.string).default([]),
20
- mentionPrefix: s.boolean.optional,
21
- ownerId: s.array(s.string).default([]),
22
- ignoreOwner: s.boolean.default(false),
23
- defaultCooldown: s.number.default(0),
24
- cacheTime: s.number.default(300000),
25
- userPermissions: s.array(s.string).default([]),
26
- clientPermissions: s.array(s.string).default([]),
27
- logging: s.union(s.boolean, s.array(s.string)).default(false),
28
- }).parse(settings);
29
-
30
- this.client.language = i18next;
31
-
32
- this.client.color = color({ client: this.client, options: settings });
33
-
34
- this.client.config = config;
35
-
36
- this.client.data = {
37
- messages: {},
38
-
39
- cooldowns: {}
40
- };
41
-
42
- this.client.modules = {
43
- commandHandler: new CommandHandler({ client: this.client }),
44
-
45
- eventHandler: new EventHandler({ client: this.client }),
46
-
47
- inhibitorHandler: new InhibitorHandler(this.client),
48
-
49
- languageHandler: new LanguageHandler(this.client)
50
- }
51
-
52
- this.client.util = {
53
- handler: new Handler(this.client)
54
- }
55
-
56
- return this.client;
57
- }
58
- }
59
-
60
- module.exports = { Client };