A simple Discord bot that reacts with a configured emoji to messages containing images, videos, or stickers in a specific channel.
- Automatic Reaction: Automatically adds a specified emoji reaction to messages that contain attachments (images, videos) or embeds with images/thumbnails, or stickers.
- Configurable Emoji: Supports default Unicode emojis, custom server emojis, and animated custom server emojis.
- Dedicated Channel: Only reacts to messages in a pre-configured channel.
- Easy Setup: Configuration is handled via a
config.jsonfile, which is automatically generated if it doesn't exist.
- C++ Compiler: A C++20 compatible compiler (e.g., GCC, Clang, MSVC).
- CMake: Version 3.22 or higher.
- D++ Library: The Discord++ library.
-
Clone the Repository:
git clone <repository_url> cd cat-react
-
Create Build Directory and Build:
mkdir build cd build cmake .. cmake --build .
This will compile the bot executable. The executable will be named
cat-react(orcat-react.exeon Windows).
The bot uses a config.json file for its settings. If this file doesn't exist when you run the bot, a template config.json will be created for you.
{
"channel_id": 0,
"emoji_id": 0,
"emoji_type": "default",
"emoji_unicode": "🐱",
"token": "NONE"
}token(string, required): Your Discord bot token. You can get this from the Discord Developer Portal.channel_id(integer, required): The ID of the channel where the bot should react to messages. To get a channel ID, enable Developer Mode in Discord settings, then right-click on the channel and select "Copy ID".emoji_type(string, required): Specifies the type of emoji to use for reactions."default": Use a standard Unicode emoji."custom": Use a custom emoji from your server (non-animated)."custom_animated": Use a custom animated emoji from your server.
emoji_unicode(string, required fordefaultemoji_type): The Unicode representation of the emoji to use (e.g., "🐱", "👍"). You can find these on websites like Emojipedia.emoji_id(integer, required forcustomorcustom_animatedemoji_type): The ID of your custom emoji. To get a custom emoji's ID, type\:emoji_name:in Discord chat, then add a backslash before it (\:emoji_name:). This will display the emoji in the format<:emoji_name:emoji_id>or<a:emoji_name:emoji_id>. Copy theemoji_id.
After building the bot and configuring config.json, simply run the executable from your build directory:
./cat-react # On Linux/macOS
.\cat-react.exe # On WindowsThe bot will log its status to the console.
- Bot Permissions: Ensure your bot has the necessary permissions in your Discord server, specifically:
Read Message HistoryAdd Reactions
- Message Content Intent: This bot uses
dpp::i_message_contentintent, which is a privileged intent. Make sure it's enabled in your bot's settings on the Discord Developer Portal if you are running into issues. - Error Handling: The bot provides basic error handling for configuration file issues. If
config.jsonis missing, it will create a template. - Custom Emoji Availability: For custom emojis, the bot must be in a server where the custom emoji is available. If using an animated custom emoji, ensure you set
emoji_typeto"custom_animated".