-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
applicationCommand.js
36 lines (27 loc) · 1.05 KB
/
applicationCommand.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module.exports = async (interaction, data) => {
const { name: cmd } = data;
try {
const response = await Promise.race([
PLX.commands[cmd].execute(interaction.message, interaction.message.args || []).catch(err => {
console.error(err, 'APP COMMAND ERROR');
return "ERROR"
}),
wait(2.5).then(x => "TIMEOUT")
]);
if (response === "TIMEOUT") {
await interaction.defer();
}
response.embeds = [response?.embed]
if (data.options?.find(x => x.name === 'private')?.value) response.flags = 64;
if (response?.length && typeof response !== 'string') {
let [res, file] = response;
return interaction.reply(res, file);
}
if (response === "TIMEOUT" || !response || (!response.embed && !response.content)) {
return interaction.editOriginal({ content: "\u200b" || _emoji("yep") });
}
interaction.reply(response);
} catch (err) {
console.error(err);
}
}