A Discord bot with some random commands.
Clone the repo using Git and enter it using the commands below:
git clone https://github.com/GeeTransit/joshgone
cd joshgoneInstall Python (minimum is 3.9) and create the virtual environment by running:
# On Windows
python -m venv .venv
# On Linux
python3 -m venv .venvTo enter the virtual environment, run the following. To leave the virtual environment, type deactivate and press enter.
# On Windows
call .venv\Scripts\activate.bat
# On Linux
source .venv/bin/activateInstall all dependencies by entering the virtual environment and running:
# On Windows
pip install -r requirements.txt
# On Linux
pip3 install -r requirements.txtIf installing the dependencies failed, this is likely because the requirements.txt file was generated on Windows. You can try manually pip installing the dependencies listed in hatch.toml under [envs.default].
JoshGone takes all configuration using environment variables. Here's a table with the environment variables needed.
| Name | Purpose |
|---|---|
| JOSHGONE_TOKEN | Discord bot user's token. Should be around 59 characters long and look random. |
| JOSHGONE_DB | SQLite database location. Set it to joshgone.db. |
| JOSHGONE_REPL | Optional. Can be 0 (default) or 1. If it is 1, there will be a REPL after the bot starts. |
You can get your Discord bot user's token by going to your dashboard, clicking on your application, clicking Bot in the left sidebar, and pressing the Copy button under Token in the Build-A-Bot section.
If you don't have an application, click New Application on the top right and choose a name (you can change it later).
If you don't have a bot user, press Add Bot in the Build-a-Bot section and click Yes, do it!
To set an environment variable, run:
# On Windows
set NAME=value
# On Linux
export NAME=valueCreate or update the database to the newest format by entering the virtual environment and running:
yoyo applyFor playing music to work, you need to have FFmpeg on your PATH environment variable. Verify by running:
ffmpeg -versionEnter the virtual environment and run:
# On Windows
python joshgone.py
# On Linux
python3 joshgone.pyNote: This is very experimental.
For playing music from Online Sequencer to work, you need to install from requirements-os.txt instead of requirements.txt. For more info on how it gets the sequence notes, check out online_sequencer_get_note_infos.py.
Next, run the following command in the virtual environment. This will download the instrument settings and the audio file for each instrument into a directory named oscollection.
# On Windows
python online_sequencer_download.py oscollection
# On Linux
python3 online_sequencer_download.py oscollectionIf you want to use a different directory name, replace oscollection with the different name in the command, and set the JOSHGONE_OS_DIRECTORY environment variable to the different name.
Install Hatch globally (I recommend using pipx).
JoshGone uses Hatch mainly to manage virtual environments. The requirements.txt file is generated from the default environment by a Hatch plugin, and likewise with the requirements-os.txt from the os environment.
To enter a Hatch-managed virtual environment, run the following. To leave the virtual environment, type exit and press enter.
hatch --env default shellThe environment defaults to default, so you can omit --env default if you wish.
To run a command inside an environment, there is a faster way using the run subcommand:
hatch --env default run ...To add a dependency, go to hatch.toml and add to the dependencies list. The next time you enter the environment, the corresponding requirements file will be updated.