I was doing a badword "detector" and don't works when It is to send the console.log

the code: const fs = require("fs"); // Función para detectar la palabra prohibida. function detectForbiddenWord(content) { const forbiddenWords = require("../../../forbidden-words.json"); for (const word of forbiddenWords) { if (content.includes(word)) { console.log(Forbidden word detected: ${word}); // Realiza aquí la acción correspondiente para la palabra prohibida // Por ejemplo, puedes aplicar una sanción al usuario o enviar un mensaje de advertencia return true; } } return false; } module.exports = { name: "interactionCreate", async execute(interaction, client) { if (!interaction.isCommand()) return; const { commandName } = interaction; const command = client.commands.get(commandName); if (!command) return; try { await command.execute(interaction); // Verificar si la interacción es un mensaje if (interaction.type === "MESSAGE") { const content = interaction.content; if (content && detectForbiddenWord(content.toLowerCase())) { console.log("Message with forbidden word detected"); } } } catch (error) { console.error(error); if (!interaction.replied) { await interaction.reply({ content: "Something went wrong while executing this command.", ephemeral: true, }); } } }, };
5 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
d.js docs
d.js docs2y ago
Codeblocks: ```js const Discord = require("discord.js"); // further code ``` becomes
const Discord = require("discord.js");
// further code
const Discord = require("discord.js");
// further code
Inline Code: `console.log('inline!');` becomes console.log('inline!');
sexy dark chocolate
What is content defined as? Doesn't look like it's in the message event forbiddenWords is an object
treble/luna
treble/luna2y ago
If i'm getting this right, you're trying to make a filter for messages. But you do not have a messageCreate event, messages are not interactions I dont even think message is a type and types also are enums in v14, not strings iirc
Ascensor Rural
Ascensor RuralOP2y ago
ok thanks I'll solve
Want results from more Discord servers?
Add your server