-
Notifications
You must be signed in to change notification settings - Fork 3
/
log.js
150 lines (131 loc) · 3.48 KB
/
log.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
// Logging javascript file
// Python can't log changes, but coffee can.
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on("messageDelete", (messageDelete) => {
if (messageDelete.author.bot){return;}
if(messageDelete.attachments)
{
var a = messageDelete.attachments;
a.forEach(function (b)
{
messageDelete.content = messageDelete.content + " -- " + b.url;
})
}
try{
// send to local message channel
var channel = messageDelete.guild.channels.find(channel => channel.name === "message_logs");
channel.send({embed: {
color: 16726088,
description: "A message sent by " + messageDelete.author.username + " was removed! \n\nContent: \n" + messageDelete.content + "\n\nChannel: <#" + messageDelete.channel.id + ">" ,
}});
}
catch(e){
console.log(e)
}
});
client.on('messageUpdate', (oldMessage, newMessage) => {
if (newMessage.author.bot){return;}
if(newMessage.attachments)
{
var a = newMessage.attachments;
a.forEach(function (b)
{
newMessage.content = newMessage.content + " -- " + b.url;
})
}
try{
var channel = newMessage.guild.channels.find(channel => channel.name === "message_logs");
channel.send({embed: {
color: 3447003,
description: "A message sent by " + newMessage.author.username + " was edited! \n\nOld message: \n" + oldMessage.content + "\nNew message: \n" + newMessage.content + "\n\nChannel: <#" + newMessage.channel.id + ">",
}});
}
catch(e)
{
console.log(e)
}
});
client.on('channelCreate', channel => {
try{
var c = channel.guild.channels.find(c => c.name === "channel_logging");
c.send({embed: {
color: 3447003,
description: "A new channel (" + channel.name + ") was created!",
}});
}
catch(e)
{
console.log(e)
}
});
client.on('channelDelete', channel => {
try{
var c = channel.guild.channels.find(c => c.name === "channel_logging");
c.send({embed: {
color: 16726088,
description: "Channel (" + channel.name + ") was deleted!",
}});
}
catch(e){
console.log(e)
}
});
client.on('guildMemberAdd', member => {
try{
var channel = member.guild.channels.find(channel => channel.name === "user_logs");
channel.send({embed: {
color: 3447003,
description: "A new member (" + member.user.username + ") has joined!",
}});
}
catch(e){
console.log(e)
}
});
client.on('guildMemberRemove', member => {
try{
var channel = member.guild.channels.find(channel => channel.name === "user_logs");
channel.send({embed: {
color: 16726088,
description: "Member <@" + member.id + "> ( " + member.user.username + " )" + " has left!",
}});
}
catch(e){
console.log(e)
}
});
client.on('guildBanAdd', (guild, member) => {
try{
var channel = guild.channels.find(channel => channel.name === "case_logs");
channel.send({embed: {
color: 16726088,
description: "Member <@" + member.id + "> ( " + member.user.username + " )" + " has been banned!",
}});
}
catch(e)
{
console.log(e)
}
});
client.on('guildBanRemove', (guild, member) => {
try{
var channel = guild.channels.find(channel => channel.name === "user_logs");
channel.send({embed: {
color: 16726088,
description: "Member <@" + member.id + "> ban revoked",
}});
var channel = guild.channels.find(channel => channel.name === "case_logs");
channel.send({embed: {
color: 16726088,
description: "Member <@" + member.id + "> ban revoked",
}});
}
catch(e){
console.log(e)
}
});
client.login('MyToken');