Installing Modmail on Windows
Prerequisites
- Minimum 2 GB of RAM*
- At least 2 GB available disk space.
- Supported Windows version:
- Windows 10
- Windows 11
Note that while it is possible to run Modmail with even less memory, Windows 10 itself recommend at least 2GB (4GB for Windows 11). This guide assumes the lowest threshold to comfortably run Modmail without possibly running into any resource bottleneck.
Dependencies
We will be using the following dependencies:
- Chocolatey
- Python 3.11
- Poetry
To install these dependencies, we will be using Powershell.
Search “powershell” in the Windows start menu, right-click on it and then click “Run as administrator”.
Then run each of the following commands:
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco upgrade git --params "/GitOnlyOnPath /WindowsTerminal" -y
choco upgrade python311 -y
Update pip
and install pipx
with:
py -3.11 -m ensurepip --upgrade
py -3.11 pip install pipx
Re-launch your powershell and install Poetry with:
pipx install poetry
Installation
In any folder location of your choice, Shift+Right Click
and click on Open PowerShell window here
.
In your PowerShell window, run these commands to clone the official Modmail repository locally and cd
into the folder:
git clone https://github.com/raidensakura/modmail
cd modmail
Install the Python dependencies for Modmail with:
poetry install --no-root
Create a new file in the modmail folder named .env
and paste in your environmental variables needed to run Modmail.
![Hello](/_next/image?url=%2Fwindows-env.png&w=828&q=75)
Lastly, in your PowerShell window simply enter the command below to run your Modmail bot:
poetry run python bot.py
If no error shows up, it means that your Modmail is now running correctly.
Set up auto-restart
Creating a batch file
Create a new text document anywhere you want to. This file will be used to launch the bot, so you may want to put it somewhere convenient, like Documents or Desktop.
Open that document in Notepad, and paste the following text in it:
@ECHO OFF
:MODMAIL
poetry run python bot.py
IF %ERRORLEVEL% == 1 GOTO RESTART_MODMAIL
IF %ERRORLEVEL% == 26 GOTO RESTART_MODMAIL
EXIT /B %ERRORLEVEL%
:RESTART_MODMAIL
ECHO Restarting Modmail...
GOTO MODMAIL
Click "File", "Save as". Change the dropdown "Save as type" to "All Files (.)". Set the filename to start_modmail.bat
, and click save.
There should now be a new file in the location you created the text document in. You can delete that text document as it is no longer needed.
You can now use the start_modmail.bat
batch file to launch Modmail by double clicking it.
This script will automatically restart Modmail when when the bot shuts down abnormally.
Launch the bot on startup
Create a shortcut of your start_modmail.bat
file.
Open the "Run" dialogue box using Windows Key + R.
Enter shell:startup
if you want the bot to launch only when the current user logs in, or shell:common
startup if you want the bot to launch when any user logs in.
Drag the shortcut into the folder that is opened. The bot will now launch on startup.