ServerBot User Manual v1.6.3


ServerBot - Discord Bot developed by Kamile320 enabling:

Content:

  1. Structure of Directory
  2. First Run
  3. Autostartup
  4. Tokens
  5. Windows - FFmpeg installation
  6. 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. manual.html - Bot Manual
  6. Media - Directory with Default Music/Sounds
  7. .env - Special file for Bot Tokens
  8. .venv - Python Virtual Environment (After using setup.sh - option 4)
  9. 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 .mksysctlstart
    • Other Files (photos, videos, etc.)
    • setup - Config Files
      • setuplib.sh - Installer of pip3 Libraries
      • mkvenv.sh - Creates venv

Pic. 1 - Running the script

First run:

The Bot requires:

You should run the script 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.

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

Autostart via systemctl:

When using the Bot, you may want it to start automatically with the operating system (Linux).
To easily enable this, there is the .mksysctlstart command.
After entering 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: .mksysctl 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 option 4 from setup.sh -> It will easily install and configure everything as needed.
For the autostart to work, you need to set the Bot files with read/write/execute permissions to 777 (for everyone). I recommend moving the Bot files to the /ServerBot directory (so that it is not in other directories)

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 tokens: Discord API, OpenAI and user IDs.
In order for the bot to run, you need to fill in the .env file with the appropriate data.

Scheme:
TOKEN="your bot token"
OpenAI="your token (API key)"
admin_usr = ['your discord user ID']
mod_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_list = 'List of systemctl services to see via Discord'

User ID

Some commands uses Operating System data and functions,
so it requires administrator privileges to run - you don't want to have removed system 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.
You also need to fill mod_usr with your trusted Discord Server Moderators - allows you to execute commands that interfere with the Discord Server

Windows - FFmpeg installation

FFmpeg is responsible for playing music on Voice Channels. On Windows FFmpeg installation looks different than on Linux.
Just run setup.bat script - after installation of all needed python libraries you'll see a message about FFmpeg configuration. Download .zip of FFmpeg program from GitHub repository, from the link provided in the script. After download, extract files to C:\ffmpeg directory (.exe files must be in C:\ffmpeg\bin directory). If you want to extract ffmpeg to other location - edit setup.bat! After that, press enter (in running setup.bat) to add FFmpeg to PATH. If you see "SUCCESS" message, reboot Windows.

Basic Commands:

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