From b8f051642548739ae9482295429c78bef37390f8 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Sat, 22 May 2021 07:54:55 -0600 Subject: [PATCH] channel logs --- commands/moderation/logs.js | 5 ++--- events/channelCreate.js | 14 ++++++++++++++ events/channelDelete.js | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 events/channelCreate.js create mode 100644 events/channelDelete.js diff --git a/commands/moderation/logs.js b/commands/moderation/logs.js index 864944b..7b9c5f0 100644 --- a/commands/moderation/logs.js +++ b/commands/moderation/logs.js @@ -7,9 +7,8 @@ const LogData = require('../../models/log'); const ObjLogTypes = { mdelete: ['md', 'mdelete', 'messagedelete', 'deletemessage', 'deletemsg', 'msgdelete'], medit: ['me', 'medit', 'messageedit', 'editmessage', 'msgedit', 'editmsg'], - chnew: ['chn', 'chc', 'newch', 'newchannel', 'chcreate', 'channelcreate'], + ch: ['channel', 'ch'], //chedit: ['channeledit'], - chdelete: ['chd', 'channeldelete', 'deletechannel', 'deletech', 'chdelete'], vc: ['voice', 'vc'], //servervcmute: [], //servervcdeafen: [], @@ -70,7 +69,7 @@ module.exports = { } if (['l', 'list'].includes(args[0].toLowerCase())) { - return message.channel.send("Valid log types:\n\n-`msgdelete` - Shows the content of a message that was deleted, in any channel.\n-`msgedit` - Shows both the old and new versions of a message when it is edited.\n-`vc` - Logs when members join and leave VCs."); + return message.channel.send("Valid log types:\n\n-`msgdelete` - Shows the content of a message that was deleted, in any channel.\n-`msgedit` - Shows both the old and new versions of a message when it is edited.\n-`vc` - Logs when members join and leave VCs.\n-`ch` - Logs channel creations and deletions."); } if (['v', 'view'].includes(args[0].toLowerCase())) { diff --git a/events/channelCreate.js b/events/channelCreate.js new file mode 100644 index 0000000..07aa2a4 --- /dev/null +++ b/events/channelCreate.js @@ -0,0 +1,14 @@ +const Discord = require('discord.js'); + +module.exports = (client, channel) => { + let ts = client.guildconfig.logs.has(channel.guild.id) && client.guildconfig.logs.get(channel.guild.id).has('ch') ? client.guildconfig.logs.get(channel.guild.id).get('ch') : null; + if (ts) {if (channel.guild.channels.cache.has(ts) && channel.guild.channels.cache.get(ts).permissionsFor(client.user.id).has("SEND_MESSAGES")) { + channel.guild.channels.cache.get(ts).send(new Discord.MessageEmbed() + .setTitle("New Channel") + .setDescription(`<#${channel.id}> || **#${channel.name}**${channel.parent && channel.parent.name ? `\nCategory: **${channel.parent.name}**` : ''}`) + .setColor('936b30') + .setFooter("Natsuki", client.user.avatarURL()) + .setTimestamp() + ); + }} +}; \ No newline at end of file diff --git a/events/channelDelete.js b/events/channelDelete.js new file mode 100644 index 0000000..19ccab8 --- /dev/null +++ b/events/channelDelete.js @@ -0,0 +1,14 @@ +const Discord = require('discord.js'); + +module.exports = (client, channel) => { + let ts = client.guildconfig.logs.has(channel.guild.id) && client.guildconfig.logs.get(channel.guild.id).has('ch') ? client.guildconfig.logs.get(channel.guild.id).get('ch') : null; + if (ts) {if (channel.guild.channels.cache.has(ts) && channel.guild.channels.cache.get(ts).permissionsFor(client.user.id).has("SEND_MESSAGES")) { + channel.guild.channels.cache.get(ts).send(new Discord.MessageEmbed() + .setTitle("Channel Deleted") + .setDescription(`Name: **#${channel.name}**${channel.parent && channel.parent.name ? `\nCategory: **${channel.parent.name}**` : ''}`) + .setColor('936b30') + .setFooter("Natsuki", client.user.avatarURL()) + .setTimestamp() + ); + }} +}; \ No newline at end of file