Sometimes, you may want to listen out for a message, rather than a command. This could be used for many cases like a spam filter, a bot that would respond to movie quotes with gifs, or a chat bot! However, in this page, we'll be using this to create a moderation filter (detect bad words).
- Warning
- As of August 30th, 2022, Discord made Message Content a privileged intent. Whilst this means you can still use prefixed messages as commands, Discord does not encourage this and heavily suggests you use slash commands. If you wish to create commands, use slash commands, not messages.
if (event.
msg.
content.find(
"bad word") != std::string::npos) {
event.reply("That is not allowed here. Please, mind your language!", true);
}
});
return 0;
}
If all went well, you should have something like this!