01 Why host?Po co hostować?
When you run python bot.py on your computer, the bot is only online while that window is open. Close it — or shut down — and the bot goes offline. Hosting means running it on a machine that stays on 24/7.
Gdy uruchamiasz python bot.py na swoim komputerze, bot jest online tylko wtedy, gdy to okno jest otwarte. Zamknij je — lub wyłącz komputer — a bot zniknie. Hosting oznacza uruchomienie go na maszynie, która działa 24/7.
02 Where to hostGdzie hostować
Common options, from simplest to most flexible:
Popularne opcje, od najprostszej do najbardziej elastycznej:
- A bot-hosting platform — upload your code, set your token, click run.
- A small VPS (virtual server) — full control via the command line.
- A spare device like a Raspberry Pi left running at home.
- Platforma do hostowania botów — wgraj kod, ustaw token, kliknij uruchom.
- Mały VPS (serwer wirtualny) — pełna kontrola przez wiersz poleceń.
- Zapasowe urządzenie, np. Raspberry Pi działające w domu.
Whatever you pick, the bot is just python bot.py running continuously. A process manager (or the host's "always restart" option) brings it back if it crashes.
Cokolwiek wybierzesz, bot to po prostu python bot.py działający w sposób ciągły. Menedżer procesów (lub opcja hosta „zawsze restartuj”) przywróci go po awarii.
03 Token as a secretToken jako sekret
On a host, set your token as an environment variable — never in the code you upload. Most platforms have a "Secrets" or "Variables" panel for this.
Na hoście ustaw token jako zmienną środowiskową — nigdy w kodzie, który wgrywasz. Większość platform ma do tego panel „Secrets” lub „Variables”.
export DISCORD_TOKEN="your-token-here"
python bot.py
If a token ever leaks (e.g. pushed to a public repo), regenerate it immediately in the Developer Portal. The old one is compromised forever.
Jeśli token kiedykolwiek wycieknie (np. trafi do publicznego repozytorium), wygeneruj go od nowa w Portalu Deweloperskim. Stary jest skompromitowany na zawsze.
04 Pin your packagesZapisz pakiety
So the host installs the same libraries you used, write them to a requirements.txt. The host reads this file and installs everything before starting your bot.
Aby host zainstalował te same biblioteki, których użyłeś, zapisz je do requirements.txt. Host odczyta ten plik i zainstaluje wszystko przed uruchomieniem bota.
python -m pip freeze > requirements.txt
05 Test yourselfSprawdź się
requirements.txt do?Do czego służy requirements.txt?