This repository holds two discord bots written in rust:
- Autokommentator
- Känguru Knecht
They are inspired by u/Kaenguru_Knecht and u/AutoKommentator (both bots of r/ich_iel).
This project is currently in its beta phase, so you need to compile it for yourself.
Then you can choose of a few solution:
- Install docker
- Get the source code for this repository:
git clone https://github.com/mafelp/discord_bots.git
- Build the docker image:
DOCKER_BUILDKIT=1 docker build . -t discord_bots
- Create the env file:
- Rename
.env.example
to.env
. - Edit
.env
and enter behind the equals sign your bot tokens for your two bots
- Rename
- Run the docker image:
docker run -it --rm \
--name xdbot \
--env-file .env \
xdbot
For both variants, you need to install docker
and docker-compose. You can then choose,
how to run and build your container. The recommended version, is to build and run
using the Dockerfile
, see recommended method. If you want to build for another,
platform for example the Raspberry Pi, use the "not recommended method".
There you build outside of docker for your or another platform using cross
and then just running the binary inside a container.
- Create the env file:
- Rename
.env.example
to.env
. - Edit
.env
and enter behind the equals sign your bot tokens for your two bots
- Rename
- Rename
docker-compose.yml.example
todocker-compose.yml
. - Edit
docker-compose.yml
to you likings. You do not have to edit it because it already works, but if you have to change something, you can do so here. - Run the following command to start the docker container
DOCKER_BUILDKIT=1 docker-compose up
If you want to have your container running in the background, run:
DOCKER_BUILDKIT=1 docker-compose up -d
To stop the container, simply run the following command:
docker-compose down
- Create the env file:
- Rename
.env.example
to.env
. - Edit
.env
and enter behind the equals sign your bot tokens for your two bots
- Rename
- Rename
native.docker-compose.yml.example
todocker-compose.yml
. - Build the binary:
- If you are cross compiling for another platform:
- Install the rust development tools
- Install cross using cargo:
cargo install cross
- Build the binary for the target platform with
~/.cargo/bin/cross build --release --target TARGET
on linux or%USERHOME%\.cargo\bin\cross build --release --target TARGET
on Windows. ReplaceTARGET
with the target you are compiling for. See targets below.- Raspberry Pi 4:
aarch64-unknown-linux-gnu
- Linux x86:
x86_64-unknown-linux-gnu
- Windows x86:
x86_64-pc-windows-gnu
- Raspberry Pi 4:
- If you are planning to run on the current platform:
- Install the rust development tools
- Run
cargo build --release
- If you are cross compiling for another platform:
- Edit
docker-compose.yml
:- Change
image: debian:buster-slim
to the platform your binary has been built for.- For a Raspberry Pi running Ubuntu Server 20.04 use:
ubuntu:20.04
- For debian use:
debian:buster-slim
- For Archlinux (based systems) use:
archlinux
- ...
- For a Raspberry Pi running Ubuntu Server 20.04 use:
- ONLY IF YOU WERE CROSS COMPILING IN STEP 3: In
volumes:
change./target/release/:/app/
to./target/TARGET/release/:/app/
whereTARGET
is the target you built for in step 3. Or if you are on another system, change this toPATH/TO/THE/BINARY:/app/xd_bot
.
- Change
- Run the following command to start the docker container
docker-compose up
If you want to have your container running in the background, run:
docker-compose up -d
To stop the container, simply run the following command:
docker-compose down
- Install the rust development tools
- Run
cargo build --release
- Run the following command to start the bots. Replace
YOUR KAENGURU BOT TOKEN
andYOUR XD BOT TOKEN
with the tokens used by your bots to authenticate to discord. See bot tokens for more information.
On Linux and MacOS:
DISCORD_TOKEN_KAENGURU="YOUR KAENGURU BOT TOKEN" \
DISCORD_TOKE_XD="YOUR XD BOT TOKEN" \
./target/xd_bot
On Windows (CMD):
set DISCORD_TOKEN_KAENGURU="YOUR KAENGURU BOT TOKEN"
set DISCORD_TOKE_XD="YOUR XD BOT TOKEN"
.\target\xd_bot
- Go to https://discord.com/developers/applications/.
- In the top right corner, click on
New Application
. - Give the bot a name and click on
Create
. - In the left side bar, click on
Bot
. - In the top right corner, click on
Add bot
. - Confirm your actions with
Yes, do it!
. - Now Copy your Discord Bot Token by either clicking on
copy
: or clicking onClick to Reveal Token
and then mark your Token and copy it.
- Copy and paste
The bot invitation token
from the console into your webbrowser and go to this website. The link should start withhttps://discord.com/oauth2/authorize?client_id=
. - Click on the Pop-Out-Menu
Select a Server
- From the list, selct the Server you want to invite the bot to. If the specific server does not appear there, make sure you have the required permissions to invite and manage bots to the server.
- After you selcted the server, click on
Authorize
.
- Solve the Captcha by clicking the square left to
I am human
and selecting the fitting images by clicking on them (not everyone has to solve these captchas! Don't be worried, if you don't have to solve them.)
- You should now see a green tick that says
Authorized
.
- Your bot should now appear on your server: