xernerx 3.3.2 → 3.3.4

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.
@@ -1,9 +1,9 @@
1
1
  import { Client, Collection } from 'discord.js';
2
+ import ExtensionBuilder from 'xernerx-extension-builder';
2
3
  import { ClientUtil } from '../utils/ClientUtil.js';
3
4
  import { ClientOptions, DiscordOptions, ExtensionOptions, HandlerOptions } from '../types/options.js';
4
5
  import { ClientCache, ClientCommands, ClientModules } from '../types/interfaces.js';
5
6
  import EventBuilder from '../build/EventBuilder.js';
6
- import ExtensionBuilder from '../build/ExtensionBuilder.js';
7
7
  import InhibitorBuilder from '../build/InhibitorBuilder.js';
8
8
  /**
9
9
  * @description - The Client.
@@ -1,10 +1,10 @@
1
1
  import { Client, Collection } from 'discord.js';
2
2
  import { s } from '@sapphire/shapeshift';
3
+ import { Style } from 'dumfunctions';
4
+ import { ClientUtil } from '../utils/ClientUtil.js';
3
5
  import CommandHandler from '../handlers/CommandHandler.js';
4
6
  import EventHandler from '../handlers/EventHandler.js';
5
7
  import InhibitorHandler from '../handlers/InhibitorHandler.js';
6
- import { ClientUtil } from '../utils/ClientUtil.js';
7
- import { Style } from 'dumfunctions';
8
8
  import Extensions from '../models/Extensions.js';
9
9
  /**
10
10
  * @description - The Client.
package/dist/main.d.ts CHANGED
@@ -8,7 +8,7 @@ import ContextCommandBuilder from './build/ContextCommandBuilder.js';
8
8
  import SlashCommandBuilder from './build/SlashCommandBuilder.js';
9
9
  import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from './types/enums.js';
10
10
  import XernerxError from './tools/XernerxError.js';
11
- import ExtensionBuilder from './build/ExtensionBuilder.js';
11
+ import ExtensionBuilder from 'xernerx-extension-builder';
12
12
  declare const version: string;
13
13
  declare const _default: {
14
14
  Discord: typeof Discord;
package/dist/main.js CHANGED
@@ -8,8 +8,8 @@ import ContextCommandBuilder from './build/ContextCommandBuilder.js';
8
8
  import SlashCommandBuilder from './build/SlashCommandBuilder.js';
9
9
  import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from './types/enums.js';
10
10
  import XernerxError from './tools/XernerxError.js';
11
- import ExtensionBuilder from './build/ExtensionBuilder.js';
12
- import pkg from '../package.js';
11
+ import ExtensionBuilder from 'xernerx-extension-builder';
12
+ import pkg from '../scripts/package.js';
13
13
  const version = pkg.version;
14
14
  export default {
15
15
  // Imported methods
@@ -1,4 +1,4 @@
1
- import XernerxClient from "../client/XernerxClient.js";
1
+ import XernerxClient from '../client/XernerxClient.js';
2
2
  export declare class MessageCommandEvents {
3
3
  client: XernerxClient;
4
4
  constructor(client: XernerxClient);
@@ -1,30 +1,28 @@
1
- import { GatewayVersion, InteractionType, REST, Routes, } from "discord.js";
2
- import { InteractionCommandUtil, MessageCommandUtil, } from "../utils/CommandUtil.js";
3
- import { InteractionArguments, messageArguments } from "./CommandArguments.js";
4
- import commandValidation from "./CommandValidations.js";
5
- import { Style } from "dumfunctions";
6
- import { InhibitorValidation } from "./InhibitorValidations.js";
1
+ import { GatewayVersion, InteractionType, REST, Routes } from 'discord.js';
2
+ import { InteractionCommandUtil, MessageCommandUtil } from '../utils/CommandUtil.js';
3
+ import { InteractionArguments, messageArguments } from './CommandArguments.js';
4
+ import commandValidation from './CommandValidations.js';
5
+ import { Style } from 'dumfunctions';
6
+ import { InhibitorValidation } from './InhibitorValidations.js';
7
7
  export class MessageCommandEvents {
8
8
  client;
9
9
  constructor(client) {
10
10
  this.client = client;
11
11
  }
12
12
  messageCreate() {
13
- this.client.on("messageCreate", async (message) => {
13
+ this.client.on('messageCreate', async (message) => {
14
14
  if (!message.author.bot) {
15
15
  let command = undefined, px = undefined;
16
- if (this.client.handlerOptions.message?.handleTyping)
17
- message.channel.sendTyping();
18
16
  message.author.isOwner = this.client.util.isOwner(message.author.id);
19
17
  message.util = new MessageCommandUtil(this.client, message);
20
18
  const commands = this.client.commands.message;
21
19
  commands
22
- .filter(c => !c.regex)
20
+ .filter((c) => !c.regex)
23
21
  .map(async (cmd) => {
24
22
  if (cmd.prefix) {
25
- cmd.prefix.map(prefix => {
23
+ cmd.prefix.map((prefix) => {
26
24
  if (message.content.startsWith(prefix)) {
27
- command = message.content.replace(prefix, "").split(/ +/).shift();
25
+ command = message.content.replace(prefix, '').split(/ +/).shift();
28
26
  px = prefix;
29
27
  }
30
28
  });
@@ -33,32 +31,35 @@ export class MessageCommandEvents {
33
31
  const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
34
32
  prefix.map((prefix) => {
35
33
  if (message.content.startsWith(prefix)) {
36
- command = message.content.replace(prefix, "").split(/ +/).shift();
34
+ command = message.content.replace(prefix, '').split(/ +/).shift();
37
35
  px = prefix;
38
36
  }
39
37
  });
40
38
  }
41
39
  if (this.client.handlerOptions.message?.allowMention) {
42
40
  if (message.mentions.users.has(this.client.user?.id) || message.mentions.repliedUser?.id === this.client.user?.id) {
43
- command = message.content.replace(`<@${this.client.user?.id}>`, "").trim().split(/ +/).shift();
44
- px = "MentionPrefix";
41
+ command = message.content.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
42
+ px = 'MentionPrefix';
45
43
  }
46
44
  }
47
45
  const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
48
- if ((cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) && (cmd.prefix.includes(px) || prefix?.includes(px) || px === "MentionPrefix")) {
46
+ if ((cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
47
+ (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')) {
49
48
  try {
49
+ if (this.client.handlerOptions.message?.handleTyping)
50
+ message.channel.sendTyping();
50
51
  const inhibitor = new InhibitorValidation(this.client, message, command);
51
52
  if (commandValidation(message, cmd, this.client))
52
53
  return;
53
54
  if (await inhibitor.inhibit())
54
55
  return;
55
- if (cmd.conditions && await cmd.conditions(message, await messageArguments(message, cmd)))
56
+ if (cmd.conditions && (await cmd.conditions(message, (await messageArguments(message, cmd)))))
56
57
  return;
57
- await cmd.exec(message, await messageArguments(message, cmd));
58
- this.client.emit("commandRun", message, cmd);
58
+ await cmd.exec(message, (await messageArguments(message, cmd)));
59
+ this.client.emit('commandRun', message, cmd);
59
60
  }
60
61
  catch (error) {
61
- return this.client.emit("commandError", message, error, cmd);
62
+ return this.client.emit('commandError', message, error, cmd);
62
63
  }
63
64
  }
64
65
  });
@@ -66,12 +67,10 @@ export class MessageCommandEvents {
66
67
  });
67
68
  }
68
69
  messageUpdate() {
69
- this.client.on("messageUpdate", async (old, message) => {
70
+ this.client.on('messageUpdate', async (old, message) => {
70
71
  message = message;
71
72
  if (!message.author?.bot) {
72
73
  let command = undefined, px = undefined;
73
- if (this.client.handlerOptions.message?.handleTyping)
74
- message.channel.sendTyping();
75
74
  if (message.author)
76
75
  message.author.isOwner = this.client.util.isOwner(message.author.id);
77
76
  message.util = new MessageCommandUtil(this.client, message);
@@ -82,7 +81,7 @@ export class MessageCommandEvents {
82
81
  if (cmd.prefix) {
83
82
  cmd.prefix.map((prefix) => {
84
83
  if (message?.content?.startsWith(prefix)) {
85
- command = message.content.replace(prefix, "").split(/ +/).shift();
84
+ command = message.content.replace(prefix, '').split(/ +/).shift();
86
85
  px = prefix;
87
86
  }
88
87
  });
@@ -91,33 +90,36 @@ export class MessageCommandEvents {
91
90
  const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
92
91
  prefix.map((prefix) => {
93
92
  if (message?.content?.startsWith(prefix)) {
94
- command = message.content.replace(prefix, "").split(/ +/).shift();
93
+ command = message.content.replace(prefix, '').split(/ +/).shift();
95
94
  px = prefix;
96
95
  }
97
96
  });
98
97
  }
99
98
  if (this.client.handlerOptions.message?.allowMention) {
100
- if (message.mentions.users.has(this.client.user?.id || "") || message.mentions.repliedUser?.id === this.client.user?.id) {
101
- command = message?.content?.replace(`<@${this.client.user?.id}>`, "").trim().split(/ +/).shift();
102
- px = "MentionPrefix";
99
+ if (message.mentions.users.has(this.client.user?.id || '') || message.mentions.repliedUser?.id === this.client.user?.id) {
100
+ command = message?.content?.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
101
+ px = 'MentionPrefix';
103
102
  }
104
103
  }
105
104
  const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
106
- if ((cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) && (cmd.prefix.includes(px) || prefix?.includes(px) || px === "MentionPrefix")) {
105
+ if ((cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
106
+ (cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')) {
107
107
  try {
108
+ if (this.client.handlerOptions.message?.handleTyping)
109
+ message.channel.sendTyping();
108
110
  message = message;
109
111
  const inhibitor = new InhibitorValidation(this.client, message, command);
110
112
  if (commandValidation(message, cmd, this.client))
111
113
  return;
112
114
  if (await inhibitor.inhibit())
113
115
  return;
114
- if (cmd.conditions && await cmd.conditions(message, await messageArguments(message, cmd)))
116
+ if (cmd.conditions && (await cmd.conditions(message, (await messageArguments(message, cmd)))))
115
117
  return;
116
- await cmd.exec(message, await messageArguments(message, cmd));
117
- this.client.emit("commandRun", message, cmd);
118
+ await cmd.exec(message, (await messageArguments(message, cmd)));
119
+ this.client.emit('commandRun', message, cmd);
118
120
  }
119
121
  catch (error) {
120
- return this.client.emit("commandError", message, error, cmd);
122
+ return this.client.emit('commandError', message, error, cmd);
121
123
  }
122
124
  }
123
125
  });
@@ -125,7 +127,7 @@ export class MessageCommandEvents {
125
127
  });
126
128
  }
127
129
  messageDelete() {
128
- this.client.on("messageDelete", async (message) => {
130
+ this.client.on('messageDelete', async (message) => {
129
131
  if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
130
132
  if (this.client.handlerOptions.message?.handleTyping)
131
133
  message.channel.sendTyping();
@@ -145,7 +147,7 @@ export class SlashCommandEvents {
145
147
  this.client = client;
146
148
  }
147
149
  slashCreate() {
148
- this.client.on("interactionCreate", async (interaction) => {
150
+ this.client.on('interactionCreate', async (interaction) => {
149
151
  interaction.util = new InteractionCommandUtil(this.client, interaction);
150
152
  interaction.user.isOwner = this.client.util.isOwner(interaction.user.id);
151
153
  if (interaction.type === InteractionType.ApplicationCommand) {
@@ -159,16 +161,16 @@ export class SlashCommandEvents {
159
161
  if (commandValidation(interaction, command, this.client))
160
162
  return;
161
163
  if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
162
- await interaction.deferReply({ ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral, fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply, });
164
+ await interaction.deferReply({ ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral, fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply });
163
165
  if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
164
- await interaction.deferReply({ ephemeral: command.defer?.ephemeral, fetchReply: command.defer?.fetchReply, });
166
+ await interaction.deferReply({ ephemeral: command.defer?.ephemeral, fetchReply: command.defer?.fetchReply });
165
167
  if (command.conditions && (await command.conditions(interaction, { group: argumentsInfo.group(), subcommand: argumentsInfo.subcommand(), args: await argumentsInfo.arguments() })))
166
168
  return;
167
- await command.exec(interaction, { group: argumentsInfo.group(), subcommand: argumentsInfo.subcommand(), args: await argumentsInfo.arguments(), });
168
- this.client.emit("commandRun", interaction, command);
169
+ await command.exec(interaction, { group: argumentsInfo.group(), subcommand: argumentsInfo.subcommand(), args: await argumentsInfo.arguments() });
170
+ this.client.emit('commandRun', interaction, command);
169
171
  }
170
172
  catch (error) {
171
- this.client.emit("commandError", interaction, error, command);
173
+ this.client.emit('commandError', interaction, error, command);
172
174
  }
173
175
  }
174
176
  }
@@ -181,7 +183,7 @@ export class ContextCommandEvents {
181
183
  this.client = client;
182
184
  }
183
185
  contextCreate() {
184
- this.client.on("interactionCreate", async (interaction) => {
186
+ this.client.on('interactionCreate', async (interaction) => {
185
187
  interaction.util = new InteractionCommandUtil(this.client, interaction);
186
188
  interaction.user.isOwner = this.client.util.isOwner(interaction.user.id);
187
189
  if (interaction.type === InteractionType.ApplicationCommand) {
@@ -196,14 +198,14 @@ export class ContextCommandEvents {
196
198
  if (command.conditions && (await command.conditions(interaction)))
197
199
  return;
198
200
  if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
199
- await interaction.deferReply({ ephemeral: this.client.handlerOptions.context?.defer?.ephemeral, fetchReply: this.client.handlerOptions.context?.defer?.fetchReply, });
201
+ await interaction.deferReply({ ephemeral: this.client.handlerOptions.context?.defer?.ephemeral, fetchReply: this.client.handlerOptions.context?.defer?.fetchReply });
200
202
  if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
201
- await interaction.deferReply({ ephemeral: command.defer?.ephemeral, fetchReply: command.defer?.fetchReply, });
203
+ await interaction.deferReply({ ephemeral: command.defer?.ephemeral, fetchReply: command.defer?.fetchReply });
202
204
  await command.exec(interaction);
203
- this.client.emit("commandRun", interaction, command);
205
+ this.client.emit('commandRun', interaction, command);
204
206
  }
205
207
  catch (error) {
206
- this.client.emit("commandError", interaction, error, command);
208
+ this.client.emit('commandError', interaction, error, command);
207
209
  }
208
210
  }
209
211
  }
@@ -216,29 +218,29 @@ export class CommandsDeploy {
216
218
  this.client = client;
217
219
  }
218
220
  deploy() {
219
- this.client.once("ready", async (client) => {
221
+ this.client.once('ready', async (client) => {
220
222
  const slashCommands = [], contextCommands = [];
221
- this.client.commands.context.map(command => command.data ? contextCommands.push(command.data.toJSON()) : null);
222
- this.client.commands.slash.map(command => command.data ? slashCommands.push(command.data.toJSON()) : null);
223
+ this.client.commands.context.map((command) => (command.data ? contextCommands.push(command.data.toJSON()) : null));
224
+ this.client.commands.slash.map((command) => (command.data ? slashCommands.push(command.data.toJSON()) : null));
223
225
  try {
224
226
  const global = { slash: this.client.handlerOptions.slash?.global, context: this.client.handlerOptions.context?.global };
225
227
  const guild = { slash: this.client.handlerOptions.slash?.guildId, context: this.client.handlerOptions.context?.guildId };
226
228
  if (global.slash && global.context) {
227
229
  if (guild.slash !== guild.context)
228
230
  console.info(Style.log(`Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${(await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name}!`, { color: Style.TextColor.Red }));
229
- this.put("global", guild.slash, [...contextCommands, ...slashCommands]);
230
- this.put("guild", guild.slash, []);
231
+ this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
232
+ this.put('guild', guild.slash, []);
231
233
  }
232
234
  if (global.slash && !global.context) {
233
- this.put("global", guild.slash, slashCommands);
235
+ this.put('global', guild.slash, slashCommands);
234
236
  }
235
237
  if (!global.slash && global.context) {
236
- this.put("global", guild.context, contextCommands);
238
+ this.put('global', guild.context, contextCommands);
237
239
  }
238
240
  if (!global.slash && !global.context) {
239
- this.put("guild", guild.slash, [...contextCommands, ...slashCommands]);
241
+ this.put('guild', guild.slash, [...contextCommands, ...slashCommands]);
240
242
  }
241
- console.log(Style.log(`Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? "globally" : "locally"} and ${contextCommands.length} context commands ${global.context ? "globally" : "locally"}.`, { color: Style.TextColor.Purple }));
243
+ console.log(Style.log(`Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${global.context ? 'globally' : 'locally'}.`, { color: Style.TextColor.Purple }));
242
244
  }
243
245
  catch (error) {
244
246
  console.error(Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, { color: Style.BackgroundColor.Red }));
@@ -247,7 +249,7 @@ export class CommandsDeploy {
247
249
  }
248
250
  put(type, guild, body) {
249
251
  const rest = new REST({ version: GatewayVersion }).setToken(this.client.token);
250
- if (type === "guild")
252
+ if (type === 'guild')
251
253
  rest.put(Routes.applicationGuildCommands(this.client.user?.id, guild), { body });
252
254
  else
253
255
  rest.put(Routes.applicationCommands(this.client.user?.id), { body });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "type": "module",
5
5
  "description": "A bot framework for discord.js.",
6
6
  "main": "dist/main.js",
@@ -15,9 +15,11 @@
15
15
  "packageManager": "npm@8.5.5",
16
16
  "scripts": {
17
17
  "checks": "npm i && npm fund && npm audit fix --force && npm link && tsc -w",
18
- "patch": "git add . && git commit -m \"Version Patch\" && npm version patch && npm publish && git push",
19
- "minor": "git add . && git commit -m \"Version Upgrade\" && npm version minor && npm publish && git push",
20
- "major": "git add . && git commit -m \"Version Rewrite\" && npm version major && npm publish && git push"
18
+ "patch": "git add . && npm run commit && npm version patch && npm publish && git push",
19
+ "minor": "git add . && npm run commit && npm version minor && npm publish && git push",
20
+ "major": "git add . && npm run commit && npm version major && npm publish && git push",
21
+ "site": "git add docs && npm run commit && git push",
22
+ "commit": "node scripts/commit.js"
21
23
  },
22
24
  "repository": {
23
25
  "type": "git",
@@ -27,16 +29,12 @@
27
29
  "url": "https://github.com/TheDummi/xernerx/issues"
28
30
  },
29
31
  "dependencies": {
30
- "@sapphire/shapeshift": "^3.7.1",
31
- "@top-gg/sdk": "^3.1.3",
32
+ "@sapphire/shapeshift": "^3.8.1",
32
33
  "discord.js": "^14.7.0",
33
34
  "dumfunctions": "^2.0.0",
34
- "express": "^4.18.2",
35
- "topgg-autoposter": "^2.0.1",
36
- "xernerx-extension-builder": "^0.0.1"
35
+ "xernerx-extension-builder": "^0.0.2"
37
36
  },
38
37
  "devDependencies": {
39
- "@types/express": "^4.17.15",
40
38
  "typescript": "^4.9.4"
41
39
  }
42
40
  }
File without changes
@@ -0,0 +1,3 @@
1
+ import pkg from '../package.json' assert { type: 'json' };
2
+
3
+ export default pkg;
package/package.js DELETED
@@ -1,3 +0,0 @@
1
- import pkg from "./package.json" assert {type: 'json'};
2
-
3
- export default pkg;