A Discord bot that responds with images of countries when they are mentioned in chat messages.
This bot listens for country names in messages and sends an image of the mentioned country if available.
The project is structured into several key components:
- Initializes the Discord client and configures event handlers.
- Loads configuration and country data from JSON files.
- Handles message events to detect country mentions and respond with images.
- Contains a list of country names that the bot can recognize and respond to.
- Stores configuration settings, including the bot token.
- Contains images of countries named in
countries.json
. - Images are named after the country they represent (e.g.,
MEXICO.jpg
).
Since discord bots should always be active, the code must be kept running constantly, to do this, the recommended option is to have the bot code running on a server Personally, I have the bot running on an Orange Pi 5 of 16GB RAM, but the bot requires almost no resources You can probably run it on a Raspberry Pi Zero, or a raspberry 2 or 3, they are cheap and should work.
You must have dotnet installed, locally if you want to edit, on the server to run it on there
Ready to deploy the bot? Follow these steps:
-
Clone this repo:
git clone https://github.com/Civermau/Country-Mentioned-Bot.git
-
Open the project in Visual Studio or your preferred C# IDE.
-
Edit the code to your liking
-
Ensure you have the necessary images in the
Images
directory. -
Update
config.json
with your Discord bot token. -
Build and run the solution. use
dotnet build
&dotnet run
- Clone this repo on the server, or upload your version to a server
git clone https://github.com/Civermau/Country-Mentioned-Bot.git
- run
dotnet publish -O path/of/bot
to generate the DLL, replace path to the desired location - move the file
config.json
(that should have now the token of YOUR bot) to the publish folder - move the file
countries.json
to the publish folder - move the dir
Images
to the publish folder - run
dotnet "country mentioned bot.dll"
or the name of the file you selected