-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
embed.js
172 lines (172 loc) Β· 4.32 KB
/
embed.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
const env = require('./env.js');
const merge = require('lodash.merge');
var setembed = function(opts){
var embed = {
// Discord Embed Template Coda
title: '',
description: '',
color: 0x19ebfe,
url: '',
timestamp: `${new Date().toISOString()}`,
footer: {
text: 'discord.gg/coda',
icon_url: `${global.client.guilds.cache.get(env.discord.guild).iconURL({ dynamic: true })}`,
},
};
return merge (embed, opts);
};
var sendError = function(message){
try {
var embed = setembed({
title: 'Error',
description: `${message}`,
color: 0xe74c3c,
});
global.client.channels.cache.get(env.discord.logs_channel).send({ embeds: [embed] });
}
catch (err) {
console.log(err);
}
};
var log = function(message){
var embed = setembed({
title: 'Log',
description: `${message}`,
color: 0x19ebfe,
});
global.client.channels.cache.get(env.discord.logs_channel).send({ embeds: [embed] });
};
var alert = function(message){
var embed = setembed({
title: 'π¨ Alert π¨',
description: `${message}`,
color: 0xe74c3c,
});
global.client.channels.cache.get(env.discord.logs_channel).send({ content: 'π¨ Critical Alert π¨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', embeds: [embed] });
};
var banAlert = async function(userbanning, userbanned, reason){
try {
var embed = setembed({
title: 'π¨ Ban Alert π¨',
description: `${userbanning} has banned ${userbanned} from the server.`,
thumbnail: {
url: `${userbanned.displayAvatarURL({ dynamic: true })}`,
},
fields: [
{
name: 'Reason',
value: `${reason}`,
},
{
name: 'User ID',
value: `${userbanned.id}`,
},
{
name: 'User Tag',
value: `${userbanned.tag}`,
},
{
name: 'Joined Discord',
value: `${userbanned.createdAt}`,
},
{
name: 'Mod ID',
value: `${userbanning.id}`,
},
{
name: 'Mod Tag',
value: `${userbanning.tag}`,
},
],
color: 0xe74c3c,
});
global.client.channels.cache.get(env.discord.logs_channel).send({ content: `Attention <@&${env.discord.mod_role}>, ${userbanning} has banned ${userbanned}`, embeds: [embed] });
}
catch (err) {
console.log(err);
sendError(err);
}
};
var kickAlert = async function(userkicking, userkicked, reason){
try {
var embed = setembed({
title: 'π¨ Kick Alert π¨',
description: `${userkicking} has kicked ${userkicked} from the server.`,
thumbnail: {
url: `${userkicked.displayAvatarURL({ dynamic: true })}`,
},
fields: [
{
name: 'Reason',
value: `${reason}`,
},
{
name: 'User ID',
value: `${userkicked.id}`,
},
{
name: 'User Tag',
value: `${userkicked.tag}`,
},
{
name: 'Joined Discord',
value: `<t:${parseInt(userkicked.createdTimestamp / 1000, 10)}:F>`,
},
{
name: 'Mod ID',
value: `${userkicking.id}`,
},
{
name: 'Mod Tag',
value: `${userkicking.tag}`,
},
],
color: 0xe74c3c,
});
global.client.channels.cache.get(env.discord.logs_channel).send({ content: `Attention <@&${env.discord.mod_role}>, ${userkicking} has kicked ${userkicked}`, embeds: [embed] });
}
catch (err) {
console.log(err);
sendError(err);
}
};
var mentionAlert = async function(message, strikenum){
try {
var embed = setembed({
title: 'π¨ Mass Mention Alert π¨',
description: `${message.author} has mass mentioned in ${message.channel}, strike ${strikenum}`,
thumbnail: {
url: `${message.member.displayAvatarURL({ dynamic: true })}`,
},
fields: [
{
name: 'Message Content',
value: `${message.content}`,
},
{
name: 'User ID',
value: `${message.author.id}`,
},
{
name: 'User Tag',
value: `${message.author.tag}`,
},
{
name: 'Joined Discord',
value: `<t:${parseInt(message.author.createdTimestamp / 1000, 10)}:F>`,
},
{
name: 'Joined Server',
value: `<t:${parseInt(message.member.joinedTimestamp / 1000, 10)}:F>`,
},
],
color: 0xe74c3c,
});
global.client.channels.cache.get(env.discord.logs_channel).send({ content: `Attention <@&${env.discord.mod_role}>, ${message.member} attempted to mass mention`, embeds: [embed] });
}
catch (err) {
console.log(err);
sendError(err);
}
};
module.exports = { setembed, sendError, log, alert, banAlert, kickAlert, mentionAlert };