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.
#include <dpp/dpp.h>
int main() {
if (event.
msg.
content.find(
"bad word") != std::string::npos) {
event.reply("That is not allowed here. Please, mind your language!", true);
}
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:80
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ i_message_content
Intent for receipt of message content.
Definition: intents.h:112
@ i_default_intents
Default D++ intents (all non-privileged intents).
Definition: intents.h:132
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:63
Create message.
Definition: dispatcher.h:1635
message msg
message that was created (sent).
Definition: dispatcher.h:1642
std::string content
Contents of the message.
Definition: message.h:2079
If all went well, you should have something like this!