generated from Baipyrus/DiscordJS-Template
Compare commits
4 Commits
cbefb18dcd
...
034beca51c
Author | SHA1 | Date | |
---|---|---|---|
034beca51c | |||
6ec1892a80 | |||
194a3d89ab | |||
c13d0cb193 |
@ -5,11 +5,18 @@ import { Op } from 'sequelize';
|
||||
export const name = Events.MessageCreate;
|
||||
/** @param {Message} message */
|
||||
export async function execute(message) {
|
||||
// Ignore direct messages
|
||||
if (!message.inGuild()) return;
|
||||
// Ignore direct messages and own messages
|
||||
if (!message.inGuild() || message.author.id === process.env.CLIENT) return;
|
||||
|
||||
// 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
|
||||
/** @type {import('../../models/keywords.js').Keyword[]} */
|
||||
|
Loading…
Reference in New Issue
Block a user