mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 03:25:41 +01:00
Rework IgnoreChannel logic
This commit is contained in:
parent
8e6891efab
commit
e9828eb969
@ -35,6 +35,11 @@ function findArray (haystack, arr) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function IsIgnoredChannel (channelName) {
|
||||||
|
const IgnoredChannels = ['welcome', 'announcements', 'media'];
|
||||||
|
return IgnoredChannels.includes(channelName);
|
||||||
|
}
|
||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
// Initialize app channels.
|
// Initialize app channels.
|
||||||
state.logChannel = client.channels.get(process.env.DISCORD_LOG_CHANNEL);
|
state.logChannel = client.channels.get(process.env.DISCORD_LOG_CHANNEL);
|
||||||
@ -67,34 +72,38 @@ client.on('guildMemberAdd', (member) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageDelete', message => {
|
client.on('messageDelete', message => {
|
||||||
if (Boolean(message.content) && !message.content.startsWith('.')) {
|
if (IsIgnoredChannel(message.channel.name) == false) {
|
||||||
const deletionEmbed = new discord.RichEmbed()
|
if (message.content && message.content.startsWith('.') == false && message.author.bot == false) {
|
||||||
.setAuthor(message.author.tag, message.author.displayAvatarURL)
|
const deletionEmbed = new discord.RichEmbed()
|
||||||
.setDescription(`Message deleted in ${message.channel}`)
|
.setAuthor(message.author.tag, message.author.displayAvatarURL)
|
||||||
.addField('Content', message.cleanContent, false)
|
.setDescription(`Message deleted in ${message.channel}`)
|
||||||
.setTimestamp()
|
.addField('Content', message.cleanContent, false)
|
||||||
.setColor('RED');
|
.setTimestamp()
|
||||||
|
.setColor('RED');
|
||||||
|
|
||||||
state.msglogChannel.send(deletionEmbed);
|
state.msglogChannel.send(deletionEmbed);
|
||||||
logger.info(`${message.author.username} ${message.author} deleted message: ${message.cleanContent}.`);
|
logger.info(`${message.author.username} ${message.author} deleted message: ${message.cleanContent}.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageUpdate', (oldMessage, newMessage) => {
|
client.on('messageUpdate', (oldMessage, newMessage) => {
|
||||||
const oldM = oldMessage.cleanContent;
|
if (IsIgnoredChannel(oldMessage.channel.name) == false) {
|
||||||
const newM = newMessage.cleanContent;
|
const oldM = oldMessage.cleanContent;
|
||||||
|
const newM = newMessage.cleanContent;
|
||||||
|
|
||||||
if (Boolean(oldM) && Boolean(newM)) {
|
if (oldM && newM) {
|
||||||
const editedEmbed = new discord.RichEmbed()
|
const editedEmbed = new discord.RichEmbed()
|
||||||
.setAuthor(oldMessage.author.tag, oldMessage.author.displayAvatarURL)
|
.setAuthor(oldMessage.author.tag, oldMessage.author.displayAvatarURL)
|
||||||
.setDescription(`Message edited in ${oldMessage.channel} [Jump To Message](${newMessage.url})`)
|
.setDescription(`Message edited in ${oldMessage.channel} [Jump To Message](${newMessage.url})`)
|
||||||
.addField('Before', oldM, false)
|
.addField('Before', oldM, false)
|
||||||
.addField('After', newM, false)
|
.addField('After', newM, false)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setColor('GREEN');
|
.setColor('GREEN');
|
||||||
|
|
||||||
state.msglogChannel.send(editedEmbed);
|
state.msglogChannel.send(editedEmbed);
|
||||||
logger.info(`${oldMessage.author.username} ${oldMessage.author} edited message from: ${oldM} to: ${newM}.`);
|
logger.info(`${oldMessage.author.username} ${oldMessage.author} edited message from: ${oldM} to: ${newM}.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user