Bot that listens to code words

How do I make a bot that listens to a "secret code word" and performs an action when someone says it? This cannot be a slash command because slash commands show up when you type in "/".
4 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
d.js docs
d.js docs2mo ago
:event: (event) Client#messageCreate @14.16.3 Emitted whenever a message is created. :property: Message#content @14.16.3 The content of the message. This property requires the GatewayIntentBits.MessageContent privileged intent in a guild for messages that do not mention the client.
Steve
Steve2mo ago
On the "messagecreate" event, check if the message.content == your code word.
Eselfins
Eselfins2mo ago
You can make it like this
const secretWord = 'SecretWord';

if (message.author.bot) return;

if (message.content.includes(secretWord)) {
message.channel.send('Your text!');
}
const secretWord = 'SecretWord';

if (message.author.bot) return;

if (message.content.includes(secretWord)) {
message.channel.send('Your text!');
}
Want results from more Discord servers?
Add your server