🩹 fix user change message in counter channel

This commit is contained in:
Axel Olausson Holtenäs 2022-03-14 13:39:28 +01:00
parent a13652a276
commit 7c36c37f8f
No known key found for this signature in database
GPG key ID: E3AE7E194AE017ED

View file

@ -0,0 +1,27 @@
const { counters } = require('../helpers/database/models');
module.exports = {
name: 'messageUpdate',
async execute(oldMessage, newMessage) {
// If message author is bot
if (newMessage.author.bot) return;
// Get counter object
const counter = await counters.findOne({
guildId: newMessage.guild.id,
channelId: newMessage.channel.id,
});
// If counter for the message channel
if (counter) {
// If message content is not strictly the same as counter word
if (newMessage.content !== counter.word) {
// Delete the message
await newMessage.delete();
await newMessage.channel.send(
`${newMessage.author} said **${counter.word}**.`
);
}
}
},
};