xernerx 3.4.2 → 3.5.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 (71) hide show
  1. package/README.md +10 -10
  2. package/dist/build/ContextCommandBuilder.js +93 -88
  3. package/dist/build/EventBuilder.js +34 -35
  4. package/dist/build/InhibitorBuilder.js +27 -28
  5. package/dist/build/MessageCommandBuilder.js +90 -80
  6. package/dist/build/SlashCommandBuilder.js +125 -118
  7. package/dist/client/XernerxClient.js +101 -81
  8. package/dist/handlers/CommandHandler.js +42 -42
  9. package/dist/handlers/EventHandler.js +16 -16
  10. package/dist/handlers/Handler.js +250 -250
  11. package/dist/handlers/InhibitorHandler.js +21 -21
  12. package/dist/main.cjs +2012 -0
  13. package/dist/main.js +42 -42
  14. package/dist/models/CommandArguments.js +121 -123
  15. package/dist/models/Events.js +294 -304
  16. package/dist/models/Extensions.js +23 -23
  17. package/dist/tools/XernerxError.js +8 -8
  18. package/dist/tools/package.js +37 -41
  19. package/dist/types/enums.js +35 -35
  20. package/dist/types/interfaces.js +1 -1
  21. package/dist/types/options.js +1 -1
  22. package/dist/types/types.js +1 -1
  23. package/dist/utils/ClientUtil.js +222 -218
  24. package/dist/utils/CommandUtil.js +248 -260
  25. package/dist/validators/CommandValidations.js +183 -185
  26. package/dist/validators/InhibitorValidations.js +42 -42
  27. package/dist/validators/Shapes.js +1 -0
  28. package/package.json +54 -39
  29. package/types/build/ContextCommandBuilder.d.ts +68 -0
  30. package/{dist → types}/build/EventBuilder.d.ts +21 -17
  31. package/{dist → types}/build/InhibitorBuilder.d.ts +19 -20
  32. package/types/build/MessageCommandBuilder.d.ts +59 -0
  33. package/types/build/SlashCommandBuilder.d.ts +64 -0
  34. package/{dist → types}/client/XernerxClient.d.ts +28 -28
  35. package/{dist → types}/handlers/CommandHandler.d.ts +27 -26
  36. package/{dist → types}/handlers/EventHandler.d.ts +13 -12
  37. package/{dist → types}/handlers/Handler.d.ts +57 -57
  38. package/{dist → types}/handlers/InhibitorHandler.d.ts +18 -17
  39. package/{dist → types}/main.d.ts +44 -30
  40. package/{dist → types}/models/CommandArguments.d.ts +17 -17
  41. package/{dist → types}/models/Events.d.ts +24 -24
  42. package/{dist → types}/models/Extensions.d.ts +7 -7
  43. package/{dist → types}/tools/XernerxError.d.ts +5 -5
  44. package/{dist → types}/tools/package.d.ts +38 -38
  45. package/types/types/enums.d.ts +44 -0
  46. package/{dist → types}/types/interfaces.d.ts +25 -25
  47. package/{dist → types}/types/options.d.ts +241 -206
  48. package/{dist → types}/types/types.d.ts +61 -32
  49. package/{dist → types}/utils/ClientUtil.d.ts +25 -25
  50. package/{dist → types}/utils/CommandUtil.d.ts +58 -56
  51. package/{dist → types}/validators/CommandValidations.d.ts +12 -7
  52. package/{dist → types}/validators/InhibitorValidations.d.ts +11 -11
  53. package/types/validators/Shapes.d.ts +1 -0
  54. package/dist/build/ContextCommandBuilder.d.ts +0 -42
  55. package/dist/build/MessageCommandBuilder.d.ts +0 -42
  56. package/dist/build/SlashCommandBuilder.d.ts +0 -40
  57. package/dist/build/XContextCommandBuilder.d.ts +0 -40
  58. package/dist/build/XContextCommandBuilder.js +0 -84
  59. package/dist/build/XEventBuilder.d.ts +0 -17
  60. package/dist/build/XEventBuilder.js +0 -35
  61. package/dist/build/XInhibitorBuilder.d.ts +0 -20
  62. package/dist/build/XInhibitorBuilder.js +0 -28
  63. package/dist/build/XMessageCommandBuilder.d.ts +0 -42
  64. package/dist/build/XMessageCommandBuilder.js +0 -80
  65. package/dist/build/XSlashCommandBuilder.d.ts +0 -36
  66. package/dist/build/XSlashCommandBuilder.js +0 -114
  67. package/dist/models/CommandValidations.d.ts +0 -4
  68. package/dist/models/CommandValidations.js +0 -183
  69. package/dist/models/InhibitorValidations.d.ts +0 -12
  70. package/dist/models/InhibitorValidations.js +0 -42
  71. package/dist/types/enums.d.ts +0 -35
@@ -1,185 +1,183 @@
1
- import { Message } from 'discord.js';
2
- import { CommandType } from '../types/enums.js';
3
- function getUser(from) {
4
- if (from instanceof Message)
5
- return from.author;
6
- else
7
- return from.user;
8
- }
9
- export default function commandValidation(action, command, client, res = false) {
10
- let user = getUser(action);
11
- if ((command.ignoreOwner || client.settings.ignoreOwner) && client.util.isOwner(user.id))
12
- return res;
13
- else if (inCooldown(user, client, command, action))
14
- return true;
15
- else if (command.owner && !client.util.isOwner(user.id)) {
16
- res = true;
17
- emit(client, action, command, 'Not an owner', client.settings.ownerId);
18
- }
19
- else if (command.channelType?.length > 0 || command.channelType) {
20
- if (!Array.isArray(command.channelType))
21
- command.channelType = [command.channelType];
22
- if (!command?.channelType?.includes(action.channel?.type)) {
23
- res = true;
24
- emit(client, action, command, 'Not the correct channel', command.channelType);
25
- }
26
- }
27
- else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
28
- res = true;
29
- emit(client, action, command, 'Not a whitelisted channel', command.channels);
30
- }
31
- else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
32
- res = true;
33
- emit(client, action, command, 'Not a whitelisted guild', command.guilds);
34
- }
35
- else if (command.channelType && command.channelType !== action.channel?.type) {
36
- res = true;
37
- emit(client, action, command, 'Not the correct type of channel', command.channelType);
38
- }
39
- else if (action?.guild && (command.userPermissions || client.settings.userPermissions)) {
40
- const permissions = command.userPermissions ||
41
- client?.settings?.userPermissions?.push(...handlerPermissions(client, command.commandType, 'user')), missing = [];
42
- if (Array.isArray(permissions))
43
- permissions.map((permission) => {
44
- if (!(action.member?.permissions).has(permission)) {
45
- missing.push(permission);
46
- }
47
- });
48
- if (missing.length > 0) {
49
- res = true;
50
- emit(client, action, command, 'Missing User Permissions', missing);
51
- }
52
- }
53
- else if (action?.guild && (command.clientPermissions || client.settings.clientPermissions)) {
54
- const permissions = command.clientPermissions ||
55
- client?.settings?.clientPermissions?.push(...handlerPermissions(client, command.commandType, 'client')), missing = [];
56
- if (Array.isArray(permissions))
57
- permissions.map((permission) => {
58
- if (!(action.member?.permissions).has(permission)) {
59
- missing.push(permission);
60
- }
61
- });
62
- if (missing.length > 0) {
63
- res = true;
64
- emit(client, action, command, 'Missing Client Permissions', missing);
65
- }
66
- }
67
- return res;
68
- }
69
- function emit(client, action, command, reason, extra) {
70
- return client.emit('commandBlock', action, command, reason, extra);
71
- }
72
- function inCooldown(user, client, command, action) {
73
- let res = false, downs = {};
74
- const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
75
- if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
76
- if (messageCommands.has(user.id)) {
77
- const usr = messageCommands.get(user.id);
78
- usr.timeRemaining = usr.endsAt - Date.now();
79
- downs.message = usr;
80
- res = true;
81
- }
82
- if (!messageCommands.has(user.id)) {
83
- messageCommands.set(user.id, toCooldown(action, command, client.handlerOptions.message.cooldown, user.id));
84
- setInterval(() => {
85
- messageCommands.delete(user.id);
86
- }, client.handlerOptions.message.cooldown);
87
- }
88
- }
89
- if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
90
- if (slashCommands.has(user.id)) {
91
- const usr = slashCommands.get(user.id);
92
- usr.timeRemaining = usr.endsAt - Date.now();
93
- downs.slash = usr;
94
- res = true;
95
- }
96
- if (!slashCommands.has(user.id)) {
97
- slashCommands.set(user.id, toCooldown(action, command, client.handlerOptions.slash.cooldown, user.id));
98
- setInterval(() => {
99
- slashCommands.delete(user.id);
100
- }, client.handlerOptions.slash.cooldown);
101
- }
102
- }
103
- if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
104
- if (contextCommands.has(user.id)) {
105
- const usr = contextCommands.get(user.id);
106
- usr.timeRemaining = usr.endsAt - Date.now();
107
- downs.context = usr;
108
- res = true;
109
- }
110
- if (!contextCommands.has(user.id)) {
111
- contextCommands.set(user.id, toCooldown(action, command, client.handlerOptions.context.cooldown, user.id));
112
- setInterval(() => {
113
- contextCommands.delete(user.id);
114
- }, client.handlerOptions.context.cooldown);
115
- }
116
- }
117
- if (client.settings?.cooldown?.default) {
118
- if (cooldowns.has(user.id)) {
119
- const usr = cooldowns.get(user.id);
120
- usr.timeRemaining = usr.endsAt - Date.now();
121
- downs.default = usr;
122
- res = true;
123
- }
124
- if (!cooldowns.has(user.id)) {
125
- cooldowns.set(user.id, toCooldown(action, command, client.settings.cooldown.default, user.id));
126
- setInterval(() => {
127
- cooldowns.delete(user.id);
128
- }, client.settings.cooldown.default);
129
- }
130
- }
131
- if (command.cooldown) {
132
- const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
133
- if (commands.has(name)) {
134
- const usr = commands.get(name);
135
- usr.timeRemaining = usr.endsAt - Date.now();
136
- downs.command = usr;
137
- res = true;
138
- }
139
- if (!commands.has(name)) {
140
- commands.set(name, toCooldown(action, command, command.cooldown, name));
141
- setInterval(() => {
142
- commands.delete(name);
143
- }, command.cooldown);
144
- }
145
- }
146
- if (Object.keys(downs).length > 0)
147
- client.emit('commandCooldown', action, command, downs);
148
- return res;
149
- }
150
- function toCooldown(action, command, cooldown, name) {
151
- let user = getUser(action);
152
- return {
153
- name,
154
- id: user.id,
155
- tag: user.tag,
156
- commandType: command.commandType,
157
- commandName: command?.data?.name || command?.name,
158
- guildId: action?.guild?.id,
159
- channelId: action?.channel?.id,
160
- startsAt: Number(Date.now()),
161
- endsAt: Number(Date.now()) + cooldown,
162
- };
163
- }
164
- function handlerPermissions(client, commandType, type) {
165
- let permissions = [];
166
- if (commandType === CommandType.MessageCommand) {
167
- if (type === 'user')
168
- permissions = client.handlerOptions.message?.userPermissions || [];
169
- else if (type === 'client')
170
- permissions = client.handlerOptions.message?.clientPermissions || [];
171
- }
172
- else if (commandType === CommandType.SlashCommand) {
173
- if (type === 'user')
174
- permissions = client.handlerOptions.slash?.userPermissions || [];
175
- else if (type === 'client')
176
- permissions = client.handlerOptions.slash?.clientPermissions || [];
177
- }
178
- else if (commandType === CommandType.ContextCommand) {
179
- if (type === 'user')
180
- permissions = client.handlerOptions.context?.userPermissions || [];
181
- else if (type === 'client')
182
- permissions = client.handlerOptions.context?.clientPermissions || [];
183
- }
184
- return permissions;
185
- }
1
+ import { Message } from 'discord.js';
2
+ import { CommandType } from '../types/enums.js';
3
+ function getUser(from) {
4
+ if (from instanceof Message)
5
+ return from.author;
6
+ else
7
+ return from.user;
8
+ }
9
+ export default function commandValidation(action, command, client, res = false) {
10
+ let user = getUser(action);
11
+ if ((command.ignoreOwner || client.settings.ignore?.owner) && client.util.isOwner(user.id))
12
+ return res;
13
+ else if (inCooldown(user, client, command, action))
14
+ return true;
15
+ else if (command.owner && !client.util.isOwner(user.id)) {
16
+ res = true;
17
+ emit(client, action, command, 'Not an owner', client.settings.ownerId);
18
+ }
19
+ else if (command.channelType?.length > 0 || command.channelType) {
20
+ if (!Array.isArray(command.channelType))
21
+ command.channelType = [command.channelType];
22
+ if (!command?.channelType?.includes(action.channel?.type)) {
23
+ res = true;
24
+ emit(client, action, command, 'Not the correct channel', command.channelType);
25
+ }
26
+ }
27
+ else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
28
+ res = true;
29
+ emit(client, action, command, 'Not a whitelisted channel', command.channels);
30
+ }
31
+ else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
32
+ res = true;
33
+ emit(client, action, command, 'Not a whitelisted guild', command.guilds);
34
+ }
35
+ else if (command.channelType && command.channelType !== action.channel?.type) {
36
+ res = true;
37
+ emit(client, action, command, 'Not the correct type of channel', command.channelType);
38
+ }
39
+ else if (action?.guild && (command.permissions?.user || client.settings.permissions?.user)) {
40
+ const permissions = command.permissions?.user || client?.settings?.permissions?.user?.push(...handlerPermissions(client, command.commandType, 'user')), missing = [];
41
+ if (Array.isArray(permissions))
42
+ permissions.map((permission) => {
43
+ if (!(action.member?.permissions).has(permission)) {
44
+ missing.push(permission);
45
+ }
46
+ });
47
+ if (missing.length > 0) {
48
+ res = true;
49
+ emit(client, action, command, 'Missing User Permissions', missing);
50
+ }
51
+ }
52
+ else if (action?.guild && (command.permissions?.client || client.settings.permissions?.client)) {
53
+ const permissions = command.permissions?.client || client?.settings?.permissions?.client?.push(...handlerPermissions(client, command.commandType, 'client')), missing = [];
54
+ if (Array.isArray(permissions))
55
+ permissions.map((permission) => {
56
+ if (!(action.member?.permissions).has(permission)) {
57
+ missing.push(permission);
58
+ }
59
+ });
60
+ if (missing.length > 0) {
61
+ res = true;
62
+ emit(client, action, command, 'Missing Client Permissions', missing);
63
+ }
64
+ }
65
+ return res;
66
+ }
67
+ function emit(client, action, command, reason, extra) {
68
+ return client.emit('commandBlock', action, command, reason, extra);
69
+ }
70
+ function inCooldown(user, client, command, action) {
71
+ let res = false, downs = {};
72
+ const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
73
+ if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
74
+ if (messageCommands.has(user.id)) {
75
+ const usr = messageCommands.get(user.id);
76
+ usr.timeRemaining = usr.endsAt - Date.now();
77
+ downs.message = usr;
78
+ res = true;
79
+ }
80
+ if (!messageCommands.has(user.id)) {
81
+ messageCommands.set(user.id, toCooldown(action, command, client.handlerOptions.message.cooldown, user.id));
82
+ setInterval(() => {
83
+ messageCommands.delete(user.id);
84
+ }, client.handlerOptions.message.cooldown);
85
+ }
86
+ }
87
+ if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
88
+ if (slashCommands.has(user.id)) {
89
+ const usr = slashCommands.get(user.id);
90
+ usr.timeRemaining = usr.endsAt - Date.now();
91
+ downs.slash = usr;
92
+ res = true;
93
+ }
94
+ if (!slashCommands.has(user.id)) {
95
+ slashCommands.set(user.id, toCooldown(action, command, client.handlerOptions.slash.cooldown, user.id));
96
+ setInterval(() => {
97
+ slashCommands.delete(user.id);
98
+ }, client.handlerOptions.slash.cooldown);
99
+ }
100
+ }
101
+ if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
102
+ if (contextCommands.has(user.id)) {
103
+ const usr = contextCommands.get(user.id);
104
+ usr.timeRemaining = usr.endsAt - Date.now();
105
+ downs.context = usr;
106
+ res = true;
107
+ }
108
+ if (!contextCommands.has(user.id)) {
109
+ contextCommands.set(user.id, toCooldown(action, command, client.handlerOptions.context.cooldown, user.id));
110
+ setInterval(() => {
111
+ contextCommands.delete(user.id);
112
+ }, client.handlerOptions.context.cooldown);
113
+ }
114
+ }
115
+ if (client.settings?.cooldown?.default) {
116
+ if (cooldowns.has(user.id)) {
117
+ const usr = cooldowns.get(user.id);
118
+ usr.timeRemaining = usr.endsAt - Date.now();
119
+ downs.default = usr;
120
+ res = true;
121
+ }
122
+ if (!cooldowns.has(user.id)) {
123
+ cooldowns.set(user.id, toCooldown(action, command, client.settings.cooldown.default, user.id));
124
+ setInterval(() => {
125
+ cooldowns.delete(user.id);
126
+ }, client.settings.cooldown.default);
127
+ }
128
+ }
129
+ if (command.cooldown) {
130
+ const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
131
+ if (commands.has(name)) {
132
+ const usr = commands.get(name);
133
+ usr.timeRemaining = usr.endsAt - Date.now();
134
+ downs.command = usr;
135
+ res = true;
136
+ }
137
+ if (!commands.has(name)) {
138
+ commands.set(name, toCooldown(action, command, command.cooldown, name));
139
+ setInterval(() => {
140
+ commands.delete(name);
141
+ }, command.cooldown);
142
+ }
143
+ }
144
+ if (Object.keys(downs).length > 0)
145
+ client.emit('commandCooldown', action, command, downs);
146
+ return res;
147
+ }
148
+ function toCooldown(action, command, cooldown, name) {
149
+ let user = getUser(action);
150
+ return {
151
+ name,
152
+ id: user.id,
153
+ tag: user.tag,
154
+ commandType: command.commandType,
155
+ commandName: command?.data?.name || command?.name,
156
+ guildId: action?.guild?.id,
157
+ channelId: action?.channel?.id,
158
+ startsAt: Number(Date.now()),
159
+ endsAt: Number(Date.now()) + cooldown,
160
+ };
161
+ }
162
+ function handlerPermissions(client, commandType, type) {
163
+ let permissions = [];
164
+ if (commandType === CommandType.MessageCommand) {
165
+ if (type === 'user')
166
+ permissions = client.handlerOptions.message?.userPermissions || [];
167
+ else if (type === 'client')
168
+ permissions = client.handlerOptions.message?.clientPermissions || [];
169
+ }
170
+ else if (commandType === CommandType.SlashCommand) {
171
+ if (type === 'user')
172
+ permissions = client.handlerOptions.slash?.userPermissions || [];
173
+ else if (type === 'client')
174
+ permissions = client.handlerOptions.slash?.clientPermissions || [];
175
+ }
176
+ else if (commandType === CommandType.ContextCommand) {
177
+ if (type === 'user')
178
+ permissions = client.handlerOptions.context?.userPermissions || [];
179
+ else if (type === 'client')
180
+ permissions = client.handlerOptions.context?.clientPermissions || [];
181
+ }
182
+ return permissions;
183
+ }
@@ -1,42 +1,42 @@
1
- import { InhibitorType } from '../types/enums.js';
2
- export class InhibitorValidation {
3
- client;
4
- action;
5
- command;
6
- inhibited;
7
- constructor(client, action, command) {
8
- this.client = client;
9
- this.action = action;
10
- this.command = command;
11
- this.inhibited = {};
12
- }
13
- async inhibit() {
14
- for (const inhibitor of this.client.inhibitors) {
15
- const inhibit = inhibitor[1];
16
- if (inhibit)
17
- this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
18
- }
19
- for (const inhibit of Object.values(this.inhibited)) {
20
- if (inhibit)
21
- return this.inhibited;
22
- }
23
- }
24
- args(action, type) {
25
- if (type === InhibitorType.Channel)
26
- return action.channel;
27
- if (type === InhibitorType.User)
28
- return action.author || action.user;
29
- if (type === InhibitorType.Guild)
30
- return action.guild;
31
- if (type === InhibitorType.Member)
32
- return action.member;
33
- // if (type === InhibitorType.Command)
34
- // return this.client.util.getAllCommands().filter(this.command.name);
35
- // if (type === InhibitorType.MessageCommand)
36
- // return this.client.util.getAllMessageCommands().find(this.command.name);
37
- // if (type === InhibitorType.SlashCommand)
38
- // return this.client.util.getAllSlashCommands().find(this.command.name);
39
- // if (type === InhibitorType.ContextCommand)
40
- // return this.client.util.getAllContextCommands().find(this.command.name);
41
- }
42
- }
1
+ import { InhibitorType } from '../types/enums.js';
2
+ export class InhibitorValidation {
3
+ client;
4
+ action;
5
+ command;
6
+ inhibited;
7
+ constructor(client, action, command) {
8
+ this.client = client;
9
+ this.action = action;
10
+ this.command = command;
11
+ this.inhibited = {};
12
+ }
13
+ async inhibit() {
14
+ for (const inhibitor of this.client.inhibitors) {
15
+ const inhibit = inhibitor[1];
16
+ if (inhibit)
17
+ this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
18
+ }
19
+ for (const inhibit of Object.values(this.inhibited)) {
20
+ if (inhibit)
21
+ return this.inhibited;
22
+ }
23
+ }
24
+ args(action, type) {
25
+ if (type === InhibitorType.Channel)
26
+ return action.channel;
27
+ if (type === InhibitorType.User)
28
+ return action.author || action.user;
29
+ if (type === InhibitorType.Guild)
30
+ return action.guild;
31
+ if (type === InhibitorType.Member)
32
+ return action.member;
33
+ // if (type === InhibitorType.Command)
34
+ // return this.client.util.getAllCommands().filter(this.command.name);
35
+ // if (type === InhibitorType.MessageCommand)
36
+ // return this.client.util.getAllMessageCommands().find(this.command.name);
37
+ // if (type === InhibitorType.SlashCommand)
38
+ // return this.client.util.getAllSlashCommands().find(this.command.name);
39
+ // if (type === InhibitorType.ContextCommand)
40
+ // return this.client.util.getAllContextCommands().find(this.command.name);
41
+ }
42
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,41 +1,56 @@
1
1
  {
2
- "name": "xernerx",
3
- "version": "3.4.2",
4
- "type": "module",
5
- "description": "A bot framework for discord.js.",
6
- "main": "dist/main.js",
7
- "keywords": [
8
- "discord.js",
9
- "discord",
10
- "framework"
11
- ],
12
- "author": "Dummi",
13
- "license": "MIT",
14
- "homepage": "https://xernerx.github.io/xernerx/home.html",
15
- "packageManager": "npm@8.5.5",
16
- "scripts": {
17
- "start": "npm i && npm fund && npm audit fix --force && npm link && tsc -w",
18
- "patch": "npm run build && tsc && git add . && npm run commit && npm version patch && npm publish && git push",
19
- "minor": "npm run build && tsc && git add . && npm run commit && npm version minor && npm publish && git push",
20
- "major": "npm run build && tsc && 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",
23
- "build": "node ../.scripts/rewritePackage.js"
24
- },
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/xernerx/xernerx.git"
28
- },
29
- "bugs": {
30
- "url": "https://github.com/xernerx/xernerx/issues"
31
- },
32
- "dependencies": {
33
- "@sapphire/shapeshift": "^3.8.1",
34
- "discord.js": "^14.7.0",
35
- "dumfunctions": "^2.0.0",
36
- "xernerx-extension-builder": "^0.0.2"
37
- },
38
- "devDependencies": {
39
- "typescript": "^4.9.4"
40
- }
2
+ "name": "xernerx",
3
+ "version": "3.5.0",
4
+ "type": "module",
5
+ "description": "A bot framework for discord.js.",
6
+ "main": "dist/main.js",
7
+ "keywords": [
8
+ "discord.js",
9
+ "discord",
10
+ "framework",
11
+ "mjs",
12
+ "esm",
13
+ "cjs",
14
+ "ts"
15
+ ],
16
+ "author": "Dummi",
17
+ "license": "MIT",
18
+ "homepage": "https://xernerx.github.io/xernerx/home.html",
19
+ "packageManager": "npm@8.5.5",
20
+ "exports": {
21
+ "import": "./dist/main.js",
22
+ "require": "./dist/main.cjs",
23
+ "types": "./types",
24
+ "node": null,
25
+ "default": null
26
+ },
27
+ "scripts": {
28
+ "start": "npm i && npm fund && npm audit fix --force && npm link && tsc -w",
29
+ "patch": "npm run write && git add . && npm run commit && npm version patch && npm publish && git push",
30
+ "minor": "npm run write && git add . && npm run commit && npm version minor && npm publish && git push",
31
+ "major": "npm run write && git add . && npm run commit && npm version major && npm publish && git push",
32
+ "site": "git add docs && npm run commit && git push",
33
+ "commit": "node ../.scripts/commit.js",
34
+ "write": "npm run build && node ../.scripts/rewritePackage.js ",
35
+ "build": "tsc && npx tsup src/main.ts && npx prettier --write src types"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/xernerx/xernerx.git"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/xernerx/xernerx/issues"
43
+ },
44
+ "dependencies": {
45
+ "@sapphire/shapeshift": "^3.8.1",
46
+ "discord.js": "^14.7.0",
47
+ "dumfunctions": "^2.0.0",
48
+ "xernerx-extension-builder": "^0.0.2",
49
+ "zod": "^3.20.6"
50
+ },
51
+ "devDependencies": {
52
+ "prettier": "^2.8.4",
53
+ "tsup": "^6.6.0",
54
+ "typescript": "^4.9.5"
55
+ }
41
56
  }
@@ -0,0 +1,68 @@
1
+ import { ContextMenuCommandBuilder, Interaction } from 'discord.js';
2
+ import { ContextCommandOptions } from '../types/options.js';
3
+ import XernerxClient from '../client/XernerxClient.js';
4
+ /**
5
+ * @description The command builder for context commands.
6
+ * @param {String} id - The unique ID of the command.
7
+ * @param {ContextCommandOptions} options - The command options.
8
+ */
9
+ export default class ContextCommandBuilder {
10
+ id: string;
11
+ data: ContextMenuCommandBuilder;
12
+ name: string;
13
+ type: import('@discordjs/builders').ContextMenuCommandType;
14
+ description: string | undefined;
15
+ info: string | undefined;
16
+ category: string | undefined;
17
+ channelType: number | number[] | undefined;
18
+ cooldown: number | undefined;
19
+ ignore:
20
+ | {
21
+ owner?: boolean | undefined;
22
+ users?: string[] | undefined;
23
+ channels?: string[] | undefined;
24
+ guilds?: string[] | undefined;
25
+ }
26
+ | undefined;
27
+ strict:
28
+ | {
29
+ owner?: boolean | undefined;
30
+ users?: string[] | undefined;
31
+ channels?: string[] | undefined;
32
+ guilds?: string[] | undefined;
33
+ }
34
+ | undefined;
35
+ permissions:
36
+ | {
37
+ client?: string[] | undefined;
38
+ users?: string[] | undefined;
39
+ dm?: boolean | undefined;
40
+ }
41
+ | undefined;
42
+ defer:
43
+ | {
44
+ /**
45
+ * @param {Interaction} interaction - The Discord interaction event data.
46
+ * @description Make your custom command here.
47
+ * TODO - update description
48
+ */
49
+ reply?: boolean | undefined;
50
+ ephemeral?: boolean | undefined;
51
+ fetch?: boolean | undefined;
52
+ }
53
+ | undefined;
54
+ client: typeof XernerxClient;
55
+ constructor(id: string, options: ContextCommandOptions);
56
+ /**
57
+ * @param {Interaction} interaction - The Discord interaction event data.
58
+ * @description make any preconditions here.
59
+ * TODO - update description
60
+ */
61
+ conditions(interaction: Interaction, args: any): Promise<void>;
62
+ /**
63
+ * @param {Interaction} interaction - The Discord interaction event data.
64
+ * @description Make your custom command here.
65
+ * TODO - update description
66
+ */
67
+ exec(interaction: Interaction, args: any): Promise<void>;
68
+ }