Finished 3 events with audit log

This commit is contained in:
ahoZiorce
2018-07-02 22:23:15 +02:00
parent 916bc5e77c
commit 605bbd8419

View File

@@ -13,6 +13,21 @@ exports.loadModule = function loadModule () {
try {
let a = await dbEI.getEvent(channel.guild.id, 'channelCreate');
if (a.event.d === true) {
let auditlog = await bot.getGuildAuditLogs(channel.guild.id, 1);
let entry = auditlog.entries[0];
console.log(entry);
let hb = "";
if (a.event.msg.includes("$hastebin")) {
let hastebinMessage = 'Gateway Event Info :\n';
hastebinMessage += 'New Channel ' + channel.name + ' data as JSON\n\n';
hastebinMessage += JSON.stringify(channel) + '\n\n';
hastebinMessage += '---\n\n';
hastebinMessage += 'Audit Log Time !\n\n';
hastebinMessage += 'User :\n';
hastebinMessage += JSON.stringify(entry.user) + '\n\n';
hastebinMessage += entry.user.username + '#' + entry.user.discriminator + ' with id ' + entry.user.id;
hb = await hastebin(configM.config.hastebinServer, hastebinMessage);
}
let type = "";
if (channel.type === 0) {
type = "text";
@@ -22,11 +37,7 @@ exports.loadModule = function loadModule () {
}
let mention = channel.mention;
if (channel.type === 2) mention.shift();
let hb = "";
if (a.event.msg.includes("$hastebin")) {
hb = await hastebin(configM.config.hastebinServer, 'Channel ' + channel.name + ' data as JSON\n\n' + JSON.stringify(channel));
}
let finalMessage = a.event.msg.replace('$type', type).replace('$mention', mention).replace('$id', channel.id).replace('$timestamp', channel.createdAt).replace('$hastebin', hb).replace('$name', channel.name);
let finalMessage = a.event.msg.replace('$type', type).replace('$mention', mention).replace('$id', channel.id).replace('$timestamp', channel.createdAt).replace('$hastebin', hb).replace('$name', channel.name).replace('$user', entry.user.username + '#' + entry.user.discriminator).replace('$userId', entry.user.id);
bot.createMessage(a.event.c === 'f' ? a.fallbackChannelId : a.event.c, finalMessage);
}
}
@@ -42,6 +53,21 @@ exports.loadModule = function loadModule () {
try {
let a = await dbEI.getEvent(channel.guild.id, 'channelDelete');
if (a.event.d === true) {
let auditlog = await bot.getGuildAuditLogs(channel.guild.id, 1);
let entry = auditlog.entries[0];
console.log(entry);
let hb = "";
if (a.event.msg.includes("$hastebin")) {
let hastebinMessage = 'Gateway Event Info :\n';
hastebinMessage += 'Channel Removed' + channel.name + ' data as JSON\n\n';
hastebinMessage += JSON.stringify(channel) + '\n\n';
hastebinMessage += '---\n\n';
hastebinMessage += 'Audit Log Time !\n\n';
hastebinMessage += 'User :\n';
hastebinMessage += JSON.stringify(entry.user) + '\n\n';
hastebinMessage += entry.user.username + '#' + entry.user.discriminator + ' with id ' + entry.user.id;
hb = await hastebin(configM.config.hastebinServer, hastebinMessage);
}
let type = "";
if (channel.type === 0) {
type = "text";
@@ -51,11 +77,7 @@ exports.loadModule = function loadModule () {
}
let mention = channel.mention;
if (channel.type === 2) mention.shift();
let hb = "";
if (a.event.msg.includes("$hastebin")) {
hb = await hastebin(configM.config.hastebinServer, 'Channel ' + channel.name + ' data as JSON\n\n' + JSON.stringify(channel));
}
let finalMessage = a.event.msg.replace('$type', type).replace('$mention', mention).replace('$id', channel.id).replace('$timestamp', channel.createdAt).replace('$hastebin', hb).replace('$name', channel.name);
let finalMessage = a.event.msg.replace('$type', type).replace('$mention', mention).replace('$id', channel.id).replace('$timestamp', channel.createdAt).replace('$hastebin', hb).replace('$name', channel.name).replace('$user', entry.user.username + '#' + entry.user.discriminator).replace('$userId', entry.user.id);
bot.createMessage(a.event.c === 'f' ? a.fallbackChannelId : a.event.c, finalMessage);
}
}
@@ -100,6 +122,28 @@ exports.loadModule = function loadModule () {
try {
let a = await dbEI.getEvent(channel.guild.id, 'channelUpdate');
if (a.event.d === true) {
let auditlog = await bot.getGuildAuditLogs(channel.guild.id, 1);
let entry = auditlog.entries[0];
console.log(entry);
let hb = "";
if (a.event.msg.includes("$hastebin")) {
let hastebinMessage = 'Gateway Event Info :\n';
hastebinMessage += 'New Channel ' + channel.name + ' data as JSON\n\n';
hastebinMessage += JSON.stringify(channel) + '\n\n';
hastebinMessage += 'Old Channel ' + oldChannel.name + ' data as JSON\n\n';
hastebinMessage += JSON.stringify(oldChannel) + '\n\n';
hastebinMessage += '---\n\n';
hastebinMessage += 'Audit Log Time !\n\n';
hastebinMessage += 'What changed :\n';
hastebinMessage += 'Before :\n';
hastebinMessage += JSON.stringify(entry.before) + '\n';
hastebinMessage += 'After :\n';
hastebinMessage += JSON.stringify(entry.after) + '\n';
hastebinMessage += 'User :\n';
hastebinMessage += JSON.stringify(entry.user) + '\n\n';
hastebinMessage += entry.user.username + '#' + entry.user.discriminator + ' with id ' + entry.user.id;
hb = await hastebin(configM.config.hastebinServer, hastebinMessage);
}
let type = "";
if (channel.type === 0) {
type = "text";
@@ -107,22 +151,11 @@ exports.loadModule = function loadModule () {
else {
type = "voice";
}
let typeOld = "";
if (oldChannel.type === 0) {
type = "text";
}
else {
type = "voice";
}
let mention = channel.mention;
if (channel.type === 2) mention.shift();
let mentionOld = oldChannel.mention;
if (channel.type === 2) mentionOld.shift();
let hb = "";
if (a.event.msg.includes("$hastebin")) {
hb = await hastebin(configM.config.hastebinServer, 'New Channel ' + channel.name + ' data as JSON\n\n' + JSON.stringify(channel) + '\n\n------------------\n\nOld Channel ' + oldChannel.name + ' data as JSON\n\n' + JSON.stringify(oldChannel));
}
let finalMessage = a.event.msg.replace('$type', type).replace('$mention', mention).replace('$id', channel.id).replace('$timestamp', channel.createdAt).replace('$hastebin', hb).replace('$name', channel.name).replace('$oldMention', mentionOld).replace('$oldTimestamp', oldChannel.createdAt).replace("$oldName", oldChannel.name);
let finalMessage = a.event.msg.replace('$type', type).replace('$mention', mention).replace('$id', channel.id).replace('$timestamp', channel.createdAt).replace('$hastebin', hb).replace('$name', channel.name).replace('$oldMention', mentionOld).replace('$oldTimestamp', oldChannel.createdAt).replace('$oldName', oldChannel.name).replace('$user', entry.user.username + '#' + entry.user.discriminator).replace('$userId', entry.user.id);
bot.createMessage(a.event.c === 'f' ? a.fallbackChannelId : a.event.c, finalMessage);
}
}