xernerx 4.0.5 → 4.2.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.
- package/dist/build/SlashCommandBuilder.d.ts +1 -0
- package/dist/build/SlashCommandBuilder.js +1 -0
- package/dist/client/XernerxClient.d.ts +5 -4
- package/dist/client/XernerxClient.js +2 -10
- package/dist/functions/deploy.js +20 -16
- package/dist/handlers/CommandHandler.js +39 -16
- package/dist/handlers/EventHandler.js +1 -1
- package/dist/handlers/ExtensionHandler.js +1 -1
- package/dist/handlers/InhibitorHandler.js +1 -1
- package/dist/main.d.ts +3 -2
- package/dist/main.js +3 -2
- package/dist/tools/XernerxLog.d.ts +1 -0
- package/dist/tools/XernerxLog.js +26 -8
- package/dist/types/extenders.d.ts +11 -6
- package/dist/types/interfaces.d.ts +23 -19
- package/dist/utils/ClientUtil.d.ts +2 -1
- package/dist/utils/ClientUtil.js +10 -1
- package/dist/utils/MessageUtil.d.ts +4 -1
- package/dist/utils/MessageUtil.js +4 -2
- package/package.json +1 -1
- package/dist/build copy/ContextCommandBuilder.d.ts +0 -37
- package/dist/build copy/ContextCommandBuilder.js +0 -88
- package/dist/build copy/EventBuilder.d.ts +0 -21
- package/dist/build copy/EventBuilder.js +0 -34
- package/dist/build copy/InhibitorBuilder.d.ts +0 -19
- package/dist/build copy/InhibitorBuilder.js +0 -27
- package/dist/build copy/MessageCommandBuilder.d.ts +0 -39
- package/dist/build copy/MessageCommandBuilder.js +0 -90
- package/dist/build copy/SlashCommandBuilder.d.ts +0 -41
- package/dist/build copy/SlashCommandBuilder.js +0 -122
- package/dist/client/DBLClient.d.ts +0 -8
- package/dist/client/DBLClient.js +0 -15
- package/dist/client/Top.ggClient.d.ts +0 -1
- package/dist/client/Top.ggClient.js +0 -1
- package/dist/events/messageCreate.d.ts +0 -1
- package/dist/events/messageCreate.js +0 -1
- package/dist/functions/AsyncFunctions.d.ts +0 -1
- package/dist/functions/AsyncFunctions.js +0 -1
- package/dist/functions/getPermissionBitField.d.ts +0 -2
- package/dist/functions/getPermissionBitField.js +0 -17
- package/dist/functions/hasVoted.d.ts +0 -1
- package/dist/functions/hasVoted.js +0 -1
- package/dist/functions/voted.d.ts +0 -1
- package/dist/functions/voted.js +0 -1
- package/dist/models/CommandArguments.d.ts +0 -17
- package/dist/models/CommandArguments.js +0 -101
- package/dist/models/Events.d.ts +0 -24
- package/dist/models/Events.js +0 -297
- package/dist/models/Extensions.d.ts +0 -7
- package/dist/models/Extensions.js +0 -23
- package/dist/models/XernerxUser.d.ts +0 -2
- package/dist/models/XernerxUser.js +0 -9
- package/dist/tools/classes.d.ts +0 -6
- package/dist/tools/classes.js +0 -10
- package/dist/tools/loggers.d.ts +0 -4
- package/dist/tools/loggers.js +0 -4
- package/dist/tools/package.d.ts +0 -42
- package/dist/tools/package.js +0 -41
- package/dist/types/enums.d.ts +0 -44
- package/dist/types/enums.js +0 -35
- package/dist/types/options.d.ts +0 -254
- package/dist/types/options.js +0 -1
- package/dist/utils/CommandUtil.d.ts +0 -58
- package/dist/utils/CommandUtil.js +0 -232
- package/dist/utils/InteractionArguments.d.ts +0 -1
- package/dist/utils/InteractionArguments.js +0 -1
- package/dist/validators/CommandValidations.d.ts +0 -12
- package/dist/validators/CommandValidations.js +0 -166
- package/dist/validators/commands.d.ts +0 -4
- package/dist/validators/commands.js +0 -25
- /package/dist/validators/{InhibitorValidations.d.ts → inhibitorValidations.d.ts} +0 -0
- /package/dist/validators/{InhibitorValidations.js → inhibitorValidations.js} +0 -0
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
export class InteractionArguments {
|
|
2
|
-
interaction;
|
|
3
|
-
constructor(interaction) {
|
|
4
|
-
this.interaction = interaction;
|
|
5
|
-
}
|
|
6
|
-
group() {
|
|
7
|
-
return this.interaction?.options?._group;
|
|
8
|
-
}
|
|
9
|
-
subcommand() {
|
|
10
|
-
return this.interaction?.options?._subcommand;
|
|
11
|
-
}
|
|
12
|
-
arguments() {
|
|
13
|
-
const options = {};
|
|
14
|
-
if (this.interaction?.options?._hoistedOptions) {
|
|
15
|
-
for (const option of this.interaction.options._hoistedOptions) {
|
|
16
|
-
options[option.name] = option.channel || option.user || option.role || option.value;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return options;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export async function messageArguments(message, command) {
|
|
23
|
-
let args = { flags: {} },
|
|
24
|
-
separator = command.separator || ' ',
|
|
25
|
-
i = 0;
|
|
26
|
-
if (!command.args) return;
|
|
27
|
-
command.args
|
|
28
|
-
.filter((c) => c.type == 'flag')
|
|
29
|
-
.map((flag) => {
|
|
30
|
-
args = args;
|
|
31
|
-
for (const flg of message.content.matchAll(flag.match)) {
|
|
32
|
-
if (flag.match == flg) {
|
|
33
|
-
message.content = message.content.replace(flag.match, '');
|
|
34
|
-
args.flags[flag.name] = true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (!args.flags[flag.name]) args.flags[flag.name] = false;
|
|
38
|
-
});
|
|
39
|
-
for (const argument of command.args) {
|
|
40
|
-
args = args;
|
|
41
|
-
let content = message.content
|
|
42
|
-
.split(/ +/)
|
|
43
|
-
.slice(1)
|
|
44
|
-
.join(separator)
|
|
45
|
-
.replace(new RegExp(`${separator}${separator}+`, 'g'), separator)
|
|
46
|
-
.split(separator)
|
|
47
|
-
.slice(i);
|
|
48
|
-
if (content.join(separator) != '' && argument.type !== 'flag') {
|
|
49
|
-
if (argument?.content?.includes(content[0])) {
|
|
50
|
-
args[argument.name] = content[0];
|
|
51
|
-
} else if (argument.type == 'string') {
|
|
52
|
-
args[argument.name] = content[0];
|
|
53
|
-
} else if (argument.type == 'number') {
|
|
54
|
-
args[argument.name] = parseInt(content[0]);
|
|
55
|
-
} else if (argument.type == 'boolean') {
|
|
56
|
-
if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false') content[0] = null;
|
|
57
|
-
args[argument.name] = content[0];
|
|
58
|
-
} else if (argument.type == 'user') {
|
|
59
|
-
let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0])) || null;
|
|
60
|
-
try {
|
|
61
|
-
user = (await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, ''))) || null;
|
|
62
|
-
} catch (e) {
|
|
63
|
-
user = null;
|
|
64
|
-
}
|
|
65
|
-
args[argument.name] = user;
|
|
66
|
-
} else if (argument.type == 'role') {
|
|
67
|
-
let role = message.guild?.roles.cache.find((r) => r?.name?.toLowerCase()?.includes(content[0])) || null;
|
|
68
|
-
try {
|
|
69
|
-
role = (await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, ''))) || null;
|
|
70
|
-
} catch (e) {
|
|
71
|
-
role = null;
|
|
72
|
-
}
|
|
73
|
-
args[argument.name] = role;
|
|
74
|
-
} else if (argument.type == 'member') {
|
|
75
|
-
let member = message.guild?.members.cache.find((m) => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0])) || null;
|
|
76
|
-
try {
|
|
77
|
-
member = (await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, ''))) || null;
|
|
78
|
-
} catch (e) {
|
|
79
|
-
member = null;
|
|
80
|
-
}
|
|
81
|
-
args[argument.name] = member;
|
|
82
|
-
} else if (argument.type == 'channel') {
|
|
83
|
-
let channel = message.guild?.channels.cache.find((c) => c?.name?.toLowerCase()?.includes(content[0]));
|
|
84
|
-
try {
|
|
85
|
-
channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ''));
|
|
86
|
-
} catch (e) {
|
|
87
|
-
channel = null;
|
|
88
|
-
}
|
|
89
|
-
args[argument.name] = channel;
|
|
90
|
-
} else if (argument.type == 'rest') {
|
|
91
|
-
args[argument.name] = content.join(separator);
|
|
92
|
-
break;
|
|
93
|
-
} else if (argument.prompt) {
|
|
94
|
-
if (argument.prompt.reply) return message.util?.reply(argument.prompt.reply);
|
|
95
|
-
else if (argument.prompt.send) return message.channel.send(argument.prompt.send);
|
|
96
|
-
} else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
|
|
97
|
-
i++;
|
|
98
|
-
} else args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
|
|
99
|
-
}
|
|
100
|
-
return args;
|
|
101
|
-
}
|
package/dist/models/Events.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
2
|
-
export declare class MessageCommandEvents {
|
|
3
|
-
client: XernerxClient;
|
|
4
|
-
constructor(client: XernerxClient);
|
|
5
|
-
messageCreate(): void;
|
|
6
|
-
messageUpdate(): void;
|
|
7
|
-
messageDelete(): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class SlashCommandEvents {
|
|
10
|
-
client: XernerxClient;
|
|
11
|
-
constructor(client: XernerxClient);
|
|
12
|
-
slashCreate(): void;
|
|
13
|
-
}
|
|
14
|
-
export declare class ContextCommandEvents {
|
|
15
|
-
client: XernerxClient;
|
|
16
|
-
constructor(client: XernerxClient);
|
|
17
|
-
contextCreate(): void;
|
|
18
|
-
}
|
|
19
|
-
export declare class CommandsDeploy {
|
|
20
|
-
private client;
|
|
21
|
-
constructor(client: XernerxClient);
|
|
22
|
-
deploy(): void;
|
|
23
|
-
private put;
|
|
24
|
-
}
|
package/dist/models/Events.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
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 '../validators/CommandValidations.js';
|
|
5
|
-
import { Style } from 'dumfunctions';
|
|
6
|
-
import { InhibitorValidation } from '../validators/InhibitorValidations.js';
|
|
7
|
-
import User from './XernerxUser.js';
|
|
8
|
-
export class MessageCommandEvents {
|
|
9
|
-
client;
|
|
10
|
-
constructor(client) {
|
|
11
|
-
this.client = client;
|
|
12
|
-
}
|
|
13
|
-
messageCreate() {
|
|
14
|
-
this.client.on('messageCreate', async (message) => {
|
|
15
|
-
if (!message.author.bot) {
|
|
16
|
-
let command = undefined,
|
|
17
|
-
px = undefined;
|
|
18
|
-
message.author = await User(message);
|
|
19
|
-
message.util = new MessageCommandUtil(this.client, message);
|
|
20
|
-
const commands = this.client.commands.message;
|
|
21
|
-
commands
|
|
22
|
-
.filter((c) => !c.regex)
|
|
23
|
-
.map(async (cmd) => {
|
|
24
|
-
if (cmd.prefix) {
|
|
25
|
-
cmd.prefix.map((prefix) => {
|
|
26
|
-
if (message.content.startsWith(prefix)) {
|
|
27
|
-
command = message.content.replace(prefix, '').split(/ +/).shift();
|
|
28
|
-
px = prefix;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
if (this.client.handlerOptions.message?.prefix) {
|
|
33
|
-
const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
|
|
34
|
-
prefix.map((prefix) => {
|
|
35
|
-
if (message.content.startsWith(prefix)) {
|
|
36
|
-
command = message.content.replace(prefix, '').split(/ +/).shift();
|
|
37
|
-
px = prefix;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (this.client.handlerOptions.message?.allowMention) {
|
|
42
|
-
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';
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
|
|
48
|
-
if (
|
|
49
|
-
(cmd.name.toLowerCase() == command?.toLowerCase() || cmd.aliases?.map((c) => c.toLowerCase())?.includes(command?.toLowerCase())) &&
|
|
50
|
-
(cmd.prefix.includes(px) || prefix?.includes(px) || px === 'MentionPrefix')
|
|
51
|
-
) {
|
|
52
|
-
try {
|
|
53
|
-
if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
|
|
54
|
-
const inhibitor = new InhibitorValidation(this.client, message, command);
|
|
55
|
-
if (commandValidation(message, cmd, this.client)) return;
|
|
56
|
-
if (await inhibitor.inhibit()) return;
|
|
57
|
-
if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
|
|
58
|
-
await cmd.exec(message, await messageArguments(message, cmd));
|
|
59
|
-
this.client.emit('commandRun', message, cmd);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
return this.client.emit('commandError', message, error, cmd);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
messageUpdate() {
|
|
69
|
-
this.client.on('messageUpdate', async (old, message) => {
|
|
70
|
-
message = message;
|
|
71
|
-
if (!message.author?.bot) {
|
|
72
|
-
let command = undefined,
|
|
73
|
-
px = undefined;
|
|
74
|
-
message.author = await User(message);
|
|
75
|
-
message.util = new MessageCommandUtil(this.client, message);
|
|
76
|
-
const commands = this.client.commands.message;
|
|
77
|
-
commands
|
|
78
|
-
.filter((c) => !c.regex)
|
|
79
|
-
.map(async (cmd) => {
|
|
80
|
-
if (cmd.prefix) {
|
|
81
|
-
cmd.prefix.map((prefix) => {
|
|
82
|
-
if (message?.content?.startsWith(prefix)) {
|
|
83
|
-
command = message.content.replace(prefix, '').split(/ +/).shift();
|
|
84
|
-
px = prefix;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (this.client.handlerOptions.message?.prefix) {
|
|
89
|
-
const prefix = Array.isArray(this.client.handlerOptions.message.prefix) ? this.client.handlerOptions.message.prefix : [this.client.handlerOptions.message.prefix];
|
|
90
|
-
prefix.map((prefix) => {
|
|
91
|
-
if (message?.content?.startsWith(prefix)) {
|
|
92
|
-
command = message.content.replace(prefix, '').split(/ +/).shift();
|
|
93
|
-
px = prefix;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
if (this.client.handlerOptions.message?.allowMention) {
|
|
98
|
-
if (message.mentions.users.has(this.client.user?.id || '') || message.mentions.repliedUser?.id === this.client.user?.id) {
|
|
99
|
-
command = message?.content?.replace(`<@${this.client.user?.id}>`, '').trim().split(/ +/).shift();
|
|
100
|
-
px = 'MentionPrefix';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const prefix = Array.isArray(this.client.handlerOptions.message?.prefix) ? this.client.handlerOptions.message?.prefix : [this.client.handlerOptions.message?.prefix];
|
|
104
|
-
if (
|
|
105
|
-
(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
|
-
) {
|
|
108
|
-
try {
|
|
109
|
-
if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
|
|
110
|
-
message = message;
|
|
111
|
-
const inhibitor = new InhibitorValidation(this.client, message, command);
|
|
112
|
-
if (commandValidation(message, cmd, this.client)) return;
|
|
113
|
-
if (await inhibitor.inhibit()) return;
|
|
114
|
-
if (cmd.conditions && (await cmd.conditions(message, await messageArguments(message, cmd)))) return;
|
|
115
|
-
await cmd.exec(message, await messageArguments(message, cmd));
|
|
116
|
-
this.client.emit('commandRun', message, cmd);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
return this.client.emit('commandError', message, error, cmd);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
messageDelete() {
|
|
126
|
-
this.client.on('messageDelete', async (message) => {
|
|
127
|
-
if (this.client.cache.messages.has(message.id) && this.client.handlerOptions.message?.handleDeletes) {
|
|
128
|
-
try {
|
|
129
|
-
if (this.client.handlerOptions.message?.handleTyping) message.channel.sendTyping();
|
|
130
|
-
message.author = await User(message);
|
|
131
|
-
const msg = this.client.cache.messages.get(message.id);
|
|
132
|
-
const response = await message.channel.messages.fetch(msg?.response);
|
|
133
|
-
await response.delete();
|
|
134
|
-
} catch (error) {
|
|
135
|
-
this.client.emit('commandError', message, error, null);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export class SlashCommandEvents {
|
|
142
|
-
client;
|
|
143
|
-
constructor(client) {
|
|
144
|
-
this.client = client;
|
|
145
|
-
}
|
|
146
|
-
slashCreate() {
|
|
147
|
-
this.client.on('interactionCreate', async (interaction) => {
|
|
148
|
-
interaction.util = new InteractionCommandUtil(this.client, interaction);
|
|
149
|
-
interaction.author = await User(interaction);
|
|
150
|
-
if (interaction.type === InteractionType.ApplicationCommand) {
|
|
151
|
-
if (this.client.commands.slash.has(interaction.commandName)) {
|
|
152
|
-
let command = this.client.commands.slash.get(interaction.commandName);
|
|
153
|
-
const argumentsInfo = new InteractionArguments(interaction);
|
|
154
|
-
try {
|
|
155
|
-
const inhibitor = new InhibitorValidation(this.client, interaction, command);
|
|
156
|
-
if (await inhibitor.inhibit()) return;
|
|
157
|
-
if (commandValidation(interaction, command, this.client)) return;
|
|
158
|
-
if (command.defer?.reply !== false && this.client.handlerOptions.slash?.defer?.reply)
|
|
159
|
-
await interaction.deferReply({
|
|
160
|
-
ephemeral: this.client.handlerOptions.slash?.defer?.ephemeral,
|
|
161
|
-
fetchReply: this.client.handlerOptions.slash?.defer?.fetchReply,
|
|
162
|
-
});
|
|
163
|
-
if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
|
|
164
|
-
await interaction.deferReply({
|
|
165
|
-
ephemeral: command.defer?.ephemeral,
|
|
166
|
-
fetchReply: command.defer?.fetchReply,
|
|
167
|
-
});
|
|
168
|
-
if (
|
|
169
|
-
command.conditions &&
|
|
170
|
-
(await command.conditions(interaction, {
|
|
171
|
-
group: argumentsInfo.group(),
|
|
172
|
-
subcommand: argumentsInfo.subcommand(),
|
|
173
|
-
args: await argumentsInfo.arguments(),
|
|
174
|
-
}))
|
|
175
|
-
)
|
|
176
|
-
return;
|
|
177
|
-
await command.exec(interaction, {
|
|
178
|
-
group: argumentsInfo.group(),
|
|
179
|
-
subcommand: argumentsInfo.subcommand(),
|
|
180
|
-
args: await argumentsInfo.arguments(),
|
|
181
|
-
});
|
|
182
|
-
this.client.emit('commandRun', interaction, command);
|
|
183
|
-
} catch (error) {
|
|
184
|
-
this.client.emit('commandError', interaction, error, command);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
export class ContextCommandEvents {
|
|
192
|
-
client;
|
|
193
|
-
constructor(client) {
|
|
194
|
-
this.client = client;
|
|
195
|
-
}
|
|
196
|
-
contextCreate() {
|
|
197
|
-
this.client.on('interactionCreate', async (interaction) => {
|
|
198
|
-
interaction.util = new InteractionCommandUtil(this.client, interaction);
|
|
199
|
-
interaction.author = await User(interaction);
|
|
200
|
-
if (interaction.type === InteractionType.ApplicationCommand) {
|
|
201
|
-
if (this.client.commands.context.has(interaction.commandName)) {
|
|
202
|
-
let command = this.client.commands.context.get(interaction.commandName);
|
|
203
|
-
try {
|
|
204
|
-
const inhibitor = new InhibitorValidation(this.client, interaction, command);
|
|
205
|
-
if (commandValidation(interaction, command, this.client)) return;
|
|
206
|
-
if (await inhibitor.inhibit()) return;
|
|
207
|
-
if (command.conditions && (await command.conditions(interaction))) return;
|
|
208
|
-
if (command.defer?.reply !== false && this.client.handlerOptions.context?.defer?.reply)
|
|
209
|
-
await interaction.deferReply({
|
|
210
|
-
ephemeral: this.client.handlerOptions.context?.defer?.ephemeral,
|
|
211
|
-
fetchReply: this.client.handlerOptions.context?.defer?.fetchReply,
|
|
212
|
-
});
|
|
213
|
-
if (!(interaction.deferred || interaction.replied) && command.defer?.reply)
|
|
214
|
-
await interaction.deferReply({
|
|
215
|
-
ephemeral: command.defer?.ephemeral,
|
|
216
|
-
fetchReply: command.defer?.fetchReply,
|
|
217
|
-
});
|
|
218
|
-
let args = {};
|
|
219
|
-
if (command.type === 3) args = await interaction.channel.messages.fetch(interaction.targetId);
|
|
220
|
-
if (command.type === 2) args = await this.client.users.fetch(interaction.targetId);
|
|
221
|
-
await command.exec(interaction, args);
|
|
222
|
-
this.client.emit('commandRun', interaction, command);
|
|
223
|
-
} catch (error) {
|
|
224
|
-
this.client.emit('commandError', interaction, error, command);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
export class CommandsDeploy {
|
|
232
|
-
client;
|
|
233
|
-
constructor(client) {
|
|
234
|
-
this.client = client;
|
|
235
|
-
}
|
|
236
|
-
deploy() {
|
|
237
|
-
this.client.once('ready', async (client) => {
|
|
238
|
-
const slashCommands = [],
|
|
239
|
-
contextCommands = [];
|
|
240
|
-
this.client.commands.context.map((command) => (command.data ? contextCommands.push(command.data.toJSON()) : null));
|
|
241
|
-
this.client.commands.slash.map((command) => (command.data ? slashCommands.push(command.data.toJSON()) : null));
|
|
242
|
-
try {
|
|
243
|
-
const global = {
|
|
244
|
-
slash: this.client.handlerOptions.slash?.global,
|
|
245
|
-
context: this.client.handlerOptions.context?.global,
|
|
246
|
-
};
|
|
247
|
-
const guild = {
|
|
248
|
-
slash: this.client.handlerOptions.slash?.guildId,
|
|
249
|
-
context: this.client.handlerOptions.context?.guildId,
|
|
250
|
-
};
|
|
251
|
-
if (!guild.slash && !guild.context) return;
|
|
252
|
-
if (global.slash && global.context) {
|
|
253
|
-
if (guild.slash !== guild.context)
|
|
254
|
-
console.info(
|
|
255
|
-
Style.log(
|
|
256
|
-
`Xernerx | Warning: slash and context commands are both set to global, but don't have a matching guildId, using ${
|
|
257
|
-
(await this.client.guilds.fetch(this.client.handlerOptions.slash?.guildId)).name
|
|
258
|
-
}!`,
|
|
259
|
-
{ color: Style.TextColor.Red }
|
|
260
|
-
)
|
|
261
|
-
);
|
|
262
|
-
this.put('global', guild.slash, [...contextCommands, ...slashCommands]);
|
|
263
|
-
this.put('guild', guild.slash, []);
|
|
264
|
-
}
|
|
265
|
-
if (global.slash && global.context === false) {
|
|
266
|
-
this.put('global', guild.slash, slashCommands);
|
|
267
|
-
}
|
|
268
|
-
if (global.slash === false && global.context) {
|
|
269
|
-
this.put('global', guild.context, contextCommands);
|
|
270
|
-
}
|
|
271
|
-
if (global.slash === false && global.context === false) {
|
|
272
|
-
this.put('guild', guild.slash, [...contextCommands, ...slashCommands]);
|
|
273
|
-
}
|
|
274
|
-
if (this.client.handlerOptions.context?.logging || this.client.handlerOptions.slash?.logging)
|
|
275
|
-
console.info(
|
|
276
|
-
Style.log(
|
|
277
|
-
`Xernerx | Deployed ${slashCommands.length} slash commands ${global.slash ? 'globally' : 'locally'} and ${contextCommands.length} context commands ${
|
|
278
|
-
global.context ? 'globally' : 'locally'
|
|
279
|
-
}.`,
|
|
280
|
-
{ color: Style.TextColor.Purple }
|
|
281
|
-
)
|
|
282
|
-
);
|
|
283
|
-
} catch (error) {
|
|
284
|
-
console.error(
|
|
285
|
-
Style.log(`Xernerx | Couldn't deploy interaction commands because <${error}>.`, {
|
|
286
|
-
color: Style.BackgroundColor.Red,
|
|
287
|
-
})
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
put(type, guild, body) {
|
|
293
|
-
const rest = new REST({ version: GatewayVersion }).setToken(this.client.token);
|
|
294
|
-
if (type === 'guild') rest.put(Routes.applicationGuildCommands(this.client.user?.id, guild), { body });
|
|
295
|
-
else rest.put(Routes.applicationCommands(this.client.user?.id), { body });
|
|
296
|
-
}
|
|
297
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import XernerxExtensionBuilder from 'xernerx-extension-builder';
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
export default class Extensions {
|
|
4
|
-
client: XernerxClient;
|
|
5
|
-
constructor(client: XernerxClient);
|
|
6
|
-
load(extensions: Array<XernerxExtensionBuilder>, logging?: boolean): Promise<void>;
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Style } from 'dumfunctions';
|
|
2
|
-
export default class Extensions {
|
|
3
|
-
client;
|
|
4
|
-
constructor(client) {
|
|
5
|
-
this.client = client;
|
|
6
|
-
}
|
|
7
|
-
async load(extensions, logging = false) {
|
|
8
|
-
const exts = [];
|
|
9
|
-
extensions.map((extension) => {
|
|
10
|
-
try {
|
|
11
|
-
this.client.extensions[extension.name] = extension;
|
|
12
|
-
exts.push(extension.name);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error(
|
|
15
|
-
Style.log(`Xernerx | An error occurred trying to load ${extension.name}, error: <${error}>`, {
|
|
16
|
-
color: Style.BackgroundColor.Red,
|
|
17
|
-
})
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
if (logging) console.info(Style.log(`Xernerx | Loaded ${exts.length} extensions: ${exts.join(', ')}`, { color: Style.TextColor.Cyan }));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { hasVoted } from 'dbl-sdk';
|
|
2
|
-
export default async function XernerxUser(interaction) {
|
|
3
|
-
const user = interaction.user || interaction.author;
|
|
4
|
-
user.owner = interaction.client.util.isOwner(user.id);
|
|
5
|
-
user.voter = interaction.client.handlerOptions?.webhook?.topgg?.token
|
|
6
|
-
? await hasVoted(user.id, interaction.client.user.id, interaction.client.handlerOptions.webhook.topgg.token, 'top.gg')
|
|
7
|
-
: false;
|
|
8
|
-
return user;
|
|
9
|
-
}
|
package/dist/tools/classes.d.ts
DELETED
package/dist/tools/classes.js
DELETED
package/dist/tools/loggers.d.ts
DELETED
package/dist/tools/loggers.js
DELETED
package/dist/tools/package.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
name: string;
|
|
3
|
-
version: string;
|
|
4
|
-
description: string;
|
|
5
|
-
main: string;
|
|
6
|
-
type: string;
|
|
7
|
-
keywords: string[];
|
|
8
|
-
author: string;
|
|
9
|
-
license: string;
|
|
10
|
-
homepage: string;
|
|
11
|
-
packageManager: string;
|
|
12
|
-
scripts: {
|
|
13
|
-
start: string;
|
|
14
|
-
patch: string;
|
|
15
|
-
minor: string;
|
|
16
|
-
major: string;
|
|
17
|
-
site: string;
|
|
18
|
-
commit: string;
|
|
19
|
-
write: string;
|
|
20
|
-
format: string;
|
|
21
|
-
build: string;
|
|
22
|
-
};
|
|
23
|
-
repository: {
|
|
24
|
-
type: string;
|
|
25
|
-
url: string;
|
|
26
|
-
};
|
|
27
|
-
bugs: {
|
|
28
|
-
url: string;
|
|
29
|
-
};
|
|
30
|
-
dependencies: {
|
|
31
|
-
'dbl-sdk': string;
|
|
32
|
-
'discord.js': string;
|
|
33
|
-
dumfunctions: string;
|
|
34
|
-
'xernerx-extension-builder': string;
|
|
35
|
-
zod: string;
|
|
36
|
-
};
|
|
37
|
-
devDependencies: {
|
|
38
|
-
prettier: string;
|
|
39
|
-
typescript: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export default _default;
|
package/dist/tools/package.js
DELETED
|
@@ -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
|
-
};
|
package/dist/types/enums.d.ts
DELETED
|
@@ -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';
|
package/dist/types/enums.js
DELETED
|
@@ -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 = {})));
|