A python Discord bot for running an internet speedtest on the machine running the bot using the Speedtest CLI. This bot is adapted from kkrypt0nn's bot template.
- Simple setup: point to Speedtest CLI, configure, make bot and run
s/test
to run speedtest and report results- Or use docker with the included Dockerfile (and docker-compose.yml)
- Control which users can run and on which channels (unauthorized users are presented with the results of the most recent speedtest)
- Pretty output using embeds
- Example output:
- Get Speedtest CLI.
- Run the following to accept the speedtest CLI license
speedtest --accept-license
- Install python 3
- Clone this repository using
git clone https://github.com/twilsonco/SpeedtestBot
- Install dependencies using
pip install -r requirements.txt
- Install Docker on your system.
- Clone this repository using
git clone https://github.com/twilsonco/SpeedtestBot
- Navigate to the cloned repository:
cd SpeedtestBot
-
Setup your new bot on Discord:
- Sign up for a Discord developer account
- Go to the developer portal, click New Application, pick a name and click Create
- Note the
CLIENT ID
- Note the
- Click on Bot under SETTINGS and then click Add Bot
- Fill out information for the bot and uncheck the
PUBLIC BOT
toggle- Note the bot
TOKEN
- Note the bot
-
Invite the bot to your server
- Go to
https://discordapp.com/api/oauth2/authorize?client_id=<client_id>&scope=bot&permissions=<permissions>
- replace
<client_id>
with theCLIENT ID
from above - replace
<permissions>
with the minimum permissions26624
(for send messages, manage messages, embed links) or administrator permissions8
to keep things simple
- replace
- Invite the bot to your server
- Go to
-
Configure the bot:
- Copy
config-sample.json
toconfig/config.json
- Edit
config/config.json
and set the following:bot_token
: Your bot secret tokenbot_owners
: List of owner user IDsuser_blacklist
and/oruser_whitelist
: List of user IDslisten_for_commands_channel_ids
: List of channel IDs where the bot should listen for commandsbot_prefix
: Set your desired prefix (default iss/
)
To get user and channel IDs, enable developer mode in your Discord client and right-click on a user/channel.
- Copy
You can run the SpeedtestBot using either Docker commands or Docker Compose.
Build the Docker image:
docker build -t speedtestbot .
Run the Docker container:
docker run -d --name speedtestbot -v $(pwd)/config:/config speedtestbot
- Create a
docker-compose.yml
file in your project root with the following content:
version: '3'
services:
speedtestbot:
build: /path/to/workspace
container_name: speedtestbot
volumes:
- ./config:/config
restart: unless-stopped
- Run the following command to start the bot:
docker-compose up -d
Run with python3 /path/to/SpeedtestBot/bot.py
and enjoy!
- I think that's it...
- Tim Wilson
- kkrypt0nn
This project is licensed under the Apache License 2.0 - see the LICENSE.md file for details