Compare commits

..

4 Commits

Author SHA1 Message Date
034beca51c filter duplicate words 2024-04-10 07:57:52 +02:00
6ec1892a80 scan each word with and without symbols 2024-04-10 07:57:25 +02:00
194a3d89ab convert message to lowercase first 2024-04-10 07:56:04 +02:00
c13d0cb193 ignore bot-owned messages 2024-04-10 07:52:23 +02:00

View File

@ -5,11 +5,18 @@ import { Op } from 'sequelize';
export const name = Events.MessageCreate; export const name = Events.MessageCreate;
/** @param {Message} message */ /** @param {Message} message */
export async function execute(message) { export async function execute(message) {
// Ignore direct messages // Ignore direct messages and own messages
if (!message.inGuild()) return; if (!message.inGuild() || message.author.id === process.env.CLIENT) return;
// Split message content into words // Split message content into words
const words = message.content.split(/\s+/); const words = message.content
.toLowerCase()
.split(/\s+/)
.flatMap((word) => {
const without = word.replace(/[^\w\s]/g, '');
return without !== word ? [word, without] : word;
})
.filter((w, i, a) => a.indexOf(w) === i);
// Get guild keywords // Get guild keywords
/** @type {import('../../models/keywords.js').Keyword[]} */ /** @type {import('../../models/keywords.js').Keyword[]} */