ServerBot User Manual v1.10.0


ServerBot - Discord Bot developed by Kamile320 that features:

Content:

  1. Structure of Directory
  2. First Run
  3. Autostartup
  4. Tokens
  5. UserID and bot Administrators
  6. Windows - FFmpeg installation
  7. Bot Modules/Extensions
  8. .ai command
  9. Database (SQLite3)
  10. Commands

List of Files and Directories:

  1. ServerBot.py - Main script file
  2. setup.bat - File that installs required python libraries (Windows)
  3. setup.sh - Operation menu: starting the bot, installing required libraries, etc. (requires installation of the "dialog" command)
  4. Logs.txt - File with the bot event log on the server
  5. manualPL.html - Bot Manual [PL]
  6. manualEN.html - Bot Manual [EN]
  7. Media - Directory with Music/Sound files
  8. ACL - User message log (after enabling ACL)
  9. .env - Special file for Bot Tokens
  10. .venv - Python Virtual Environment (After using setup.sh - option 4)
  11. tempDB.txt - Temporary file with database content (after using .showdb command)
  12. Files - Directory with required (and not) Bot files
    • favicon.ico - Manual icon
    • updates.txt - List of recent updates
    • Logs.txt - Copy of Bot Logs
    • autorun.sh - After using .mkservice
    • serverbot.db - SQLite3 Database
    • systemd_add.py - Systemd service creation script
    • Other Files (photos, videos, etc.)
    • setup - Config Files
      • setuplib.sh - Installer of pip3 Libraries
      • mkvenv.sh - Creates venv
      • requirements.txt - List of required python libraries

Pic. 1 - Running the script

First run:

The Bot requires:

You should run the script (python3 or setup.sh) through the IDE, terminal or other program.
If something goes wrong, the Bot should let you know what the problem is
and ask for approval of the correction or it will abandon the launch/installation.
After running the script, Bot should connect with Discord and be ready to work.
[!] You can install bot via .deb file - remember that bot will install in /usr/share/serverbot. Use serverbot command with sudo, if you want configure autostart.

The current Bot Commands can be seen using the .help command

Autostart using systemd:

When using the Bot, you may want it to start automatically with the operating system (Linux).
To easily enable this, there is the .mkservice command.
After typing the command, you must provide an additional value:

def -> creates default autorun.sh file in the Files directory. Works on systems based on Ubuntu 22.04 (doesn't use venv)

venv -> sometimes when installing modules using pip3 an externally managed pip error may appear .
In this case, you should create a Python Virtual Environment/Venv.
If you have not created it yet, it is recommended to create it in the main Bot directory (ServerBot).

Example: .mkservice venv -> executing command on Discord; script of the Bot runs in main directory.
NOTE! The bot (or rather setup.sh) is adapted to the name of a directory with a virtual environment called ".venv".
If you manually created venv with different directory name, the bot may not start!
It is recommended to use proper options from setup.sh -> It will easily install and configure everything needed.
For the autostart to work, you need to set the Bot files with read/write/execute permissions to 775 (r-x for everyone, rwx for owner and group) if those files don't already have them. I recommend moving the Bot files to the /ServerBot directory (so that it is not in other directories). Do not install bot in your home directory if you want to run it with system startup.

How to create venv:
  1. in the main bot directory, type: python3 -m venv .venv
  2. to activate venv: source .venv/bin/activate (as root)
  3. check version and location: which python
  4. once you are in venv, run setup.sh
  5. (optional) to exit venv, type: deactivate
  6. or simpler - just use option 4 in setup.sh to run automatic install and enter to venv

Full documentation of venv here.

Pic. 2 - setup.sh options

Tokens

The Bot uses API tokens of: Discord, Gemini and user IDs.
In order for the bot to run, you need to fill in the .env file with the appropriate data.

Scheme:
TOKEN="bot token"
AI_token="gamini token (to use .ai)"
admin_usr = ['your discord user ID']
dscserv_link = 'Link to your Discord Server'
addstable = 'stable_link of Discord Bot'
addtesting = 'testing_link of Discord Bot'
service_monitor = 'True/False' -> enables .service command
service_list = 'List of systemd services to see via Discord'
showmodulemessages = 'True/False' -> shows which Bot modules are enabled
ACLmodule = 'True/False' -> Enables AdvancedChannelListener module
aimodel = 'gemini-2.5-flash' -> selected gemini's language model
instructions = ['Instructions for language model']
extendedErrMess = 'True/False' -> turns on/off extended error messages

User ID and bot Administrators

Some commands uses Operating System data and functions,
so they require administrator privileges to run - you don't want to have system removed by unauthorized user, right?
To execute them, you must provide the ID of trusted and authorized users that can execute these commands in admin_usr. You should be the only one who has rights to execute them.
Some commands are intended for Discord Server Moderators - they allow you to interfere with the Discord Server. You can grant Mod privileges to Mod Users in the database using .db op {userID} command.
If you want to revoke Mod privileges - use .db deop {userID}.
They should be trusted moderators of your discord server. If none of the users have Mod privileges in database, only Bot Administrators will be able to use Mod commands.

Windows - FFmpeg installation

FFmpeg is responsible for playing music on Voice Channels. On Windows FFmpeg installation looks different than on Linux.
You have to manually install and add FFmpeg files to local user PATH:
  1. Download .zip of FFmpeg program from GitHub repository, preferably from the link provided in the script.
  2. Extract files to C:\ffmpeg directory (.exe files must be located in C:\ffmpeg\bin directory).
  3. Open Start Menu and search for 'Environment Variables' - select 'Edit the system environment variables'
  4. Select 'Path' variable in 'User variables' and click 'Edit'
  5. Click 'New' and add 'C:\ffmpeg\bin' (without quotes)
  6. Click OK to close all windows
  7. Restart your computer to apply changes
After these steps, FFmpeg should be installed and ready to use with the Bot.

Bot Extensions/modules

Bot has extensions/modules that extend functions, which can be enabled or disabled in the .env file.
Modules are also available as separate repositories (Discord Bots) on GitHub.

.ai command

The .ai command allows you to talk with artificial intelligence. Uses Google's Gemini API.
Get a gemini token (On the Google AI dev page) and put token in .env file in the 'AI_token' field.
In .env file you cen set language model (gemini-2.5-flash as default) in the 'aimodel' field, and instructions for a model in a 'instructions' field.
I recommend leaving default instruction that limits response to 1500 characters - longer response may not be send to discord channel and cause an error.

Database (SQLite3)

Bot uses SQLite3 database to store informations about users like:
Database file is located in 'Files/serverbot.db'. Bot automatically creates database and collects data after every message sent on channel.
It's required to working functions correctly that uses database, such as moderator commands.
In the future it's planned to add more functions that use database, not necessarily using user ID's.
The following commands allow managing the database from Discord:

Basic Commands:

======Chat======
hello
bye
hi
hello_there
=========Converter=========
binary {dec. number}
hexa {dec. number}
convert {type} {number}
========Fun========
random
banner
botbanner
blankthing
apple
ai
badge
======Admin======
ShutDown
copylog
bash
rebuild
mkshortcut
mkservice {mode}
service
pingip
module
db
showdb
=====BotInfo=====
manual {web/local}
credits
time
ping
release
next_update
========FileManager========
cd {directory}
dir {mode}
file {mode} {filename}
touch {file} {content}
====VoiceChannel====
join
leave
play {file dir}
ytplay {type} {link}
ytsearch
stop
pause
resume
waiting
=====ModOnly=====
testbot
testos
disks
delete
cleaner
webreq
kick
ban
unban
invitegen
echo