Skip to content
Snippets Groups Projects
Commit 97fce722 authored by Reviath's avatar Reviath
Browse files

Added channel delete event, update message delete and message update events.

parent 74c052ac
No related branches found
No related tags found
No related merge requests found
module.exports = {
channeldelete: (client, connection, Discord) => {
client.on('channelDelete', async (channel) => {
const channeldb = await new Promise((resolve, reject) => {
connection.query(`SELECT channel FROM log_channel WHERE guild ='${channel.guild.id}'`, function (err, result) {
if (err)
reject(err);
resolve(result);
});
});
let channelvariable;
if (channeldb.length < 1) {
return;
} else {
channelvariable = channeldb[0].channel;
};
const log_channel = channel.guild.channels.cache.get(channelvariable);
const embed = new Discord.MessageEmbed()
.setTitle(`Channel Deleted!`)
.addField(`Channel:`, `${channel.id} (\`${channel.name}\`)`)
.addField(`Channel Type:`,`${channel.type}`)
.setTimestamp()
.setColor("RANDOM");
log_channel.send(embed).catch(() => {
return;
});
});
}
};
\ No newline at end of file
......@@ -28,7 +28,9 @@ module.exports = {
.addField(`User:`, `${message.author} (${message.author.tag})`)
.setTimestamp()
.setColor("RANDOM");
channel.send(embed)
channel.send(embed).catch(() => {
return;
});
});
}
};
\ No newline at end of file
......@@ -33,7 +33,9 @@ module.exports = {
.addField('Redirect:', `Click [here!](https://discord.com/channels/${oldMessage.guild.id}/${oldMessage.channel.id}/${oldMessage.id})`)
.setTimestamp()
.setColor("RANDOM");
channel.send(embed)
channel.send(embed).catch(() => {
return;
});
});
}
};
\ No newline at end of file
......@@ -11,6 +11,7 @@ const fs = require('fs');
const mysql = require('mysql');
const messageupdate = require('./events/messageupdate');
const channelcreate = require('./events/channelcreate');
const channeldelete = require('./events/channeldelete');
const connection = mysql.createConnection({
host : dbconfig.host,
......@@ -35,6 +36,7 @@ memberremove.guildmemberremove(client, connection);
messagedelete.messagedelete(client, connection, Discord);
messageupdate.messageupdate(client, connection, Discord);
channelcreate.channelcreate(client, connection, Discord);
channeldelete.channeldelete(client, connection, Discord);
fs.readdir("./commands/", (err, files) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment