forked from RfadnjdExt/stardust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
96 lines (95 loc) · 4.11 KB
/
functions.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
function errorNotifer(client, interaction, e, lang) {
console.log(client, interaction, e, lang);
const { EmbedBuilder } = require("discord.js");
if (client.errorLog) {
if (client.shard) {
let embed = new EmbedBuilder()
.setColor(client.config.embedColor)
.setTimestamp()
.addFields([
{ name: "Command", value: `${interaction?.commandName}` },
{ name: "Error", value: `${e.stack}` },
{
name: "User",
value: `${interaction?.user?.tag} \`(${interaction?.user?.id})\``,
inline: true
},
{
name: "Guild",
value: `${interaction?.guild?.name} \`(${interaction?.guild?.id})\` - \`${interaction?.guild?.memberCount} members\``,
inline: true
},
{
name: "Time",
value: `<t:${Math.floor(Date.now() / 1000)}:R>`,
inline: true
},
{
name: "Command Usage Channel",
value: `${interaction?.channel?.name} \`(${interaction?.channel?.id})\``,
inline: true
},
{
name: "User Voice Channel",
value: `${interaction?.member?.voice?.channel?.name} \`(${interaction?.member?.voice?.channel?.id})\``,
inline: true
}
]);
client.shard.broadcastEval(
async (c, { channelId, embed }) => {
let channel = c.channels.cache.get(channelId);
channel?.send({ embeds: [embed] }).catch(e => {});
},
{ context: { channelId: client?.errorLog, embed: embed } }
);
} else {
let embed = new EmbedBuilder()
.setColor(client.config.embedColor)
.setTimestamp()
.addFields([
{ name: "Command", value: `${interaction?.commandName}` },
{ name: "Error", value: `${e.stack}` },
{
name: "User",
value: `${interaction?.user?.tag} \`(${interaction?.user?.id})\``,
inline: true
},
{
name: "Guild",
value: `${interaction?.guild?.name} \`(${interaction?.guild?.id})\``,
inline: true
},
{
name: "Time",
value: `<t:${Math.floor(Date.now() / 1000)}:R>`,
inline: true
},
{
name: "Command Usage Channel",
value: `${interaction?.channel?.name} \`(${interaction?.channel?.id})\``,
inline: true
},
{
name: "User Voice Channel",
value: `${interaction?.member?.voice?.channel?.name} \`(${interaction?.member?.voice?.channel?.id})\``,
inline: true
}
]);
client.channels.cache
.get(client?.errorLog)
?.send({ embeds: [embed] })
.catch(e => {});
}
} else {
console.log(`
Command: ${interaction?.commandName}
Error: ${e}
User: ${interaction?.user?.tag} (${interaction?.user?.id})
Guild: ${interaction?.guild?.name} (${interaction?.guild?.id})
Command Usage Channel: ${interaction?.channel?.name} (${interaction?.channel?.id})
User Voice Channel: ${interaction?.member?.voice?.channel?.name} (${interaction?.member?.voice?.channel?.id})
`);
}
return interaction.reply({ content: `${lang.error}\n\`${e}\``, ephemeral: true }).catch(e => {});
}
module.exports = errorNotifer;