A lightweight Windows tray application that monitors your computer's lock status and reports it to a Discord channel. Get notifications when your PC locks/unlocks and optionally lock it remotely via Discord command.
- 🔒 Real-time lock/unlock notifications sent to Discord
- 💬 Discord commands to check status (
!status
) and lock PC (!lock
) - ⚙️ Easy configuration via
config.txt
file (no recompiling needed!) - ✨ Custom system tray icon
- 🚀 Option to run automatically at Windows startup
- 🟢 Startup/shutdown status notifications in Discord
- 🔄 Minimal resource usage
For Running the Release Executable:
- Windows 10 or 11
- A Discord Bot Token and Channel ID (see Discord Setup below)
For Compiling from Source (Optional):
- .NET 8.0 SDK or later (Developed with 8.0, compatible with newer versions)
- Windows 10 or 11
- Create a new Discord application at the Discord Developer Portal.
- Go to the "Bot" tab and click "Add Bot".
- Enable the
MESSAGE CONTENT INTENT
under the "Privileged Gateway Intents" section on the Bot tab. This is required for the bot to read commands like!status
. - Copy the bot Token (you'll need this for
config.txt
). Click "Reset Token" if you don't see it. Keep this token secure! - Go to the "OAuth2" tab -> "URL Generator". Select the
bot
scope. - In the "Bot Permissions" section that appears, select
Send Messages
andRead Message History
. - Copy the generated URL and paste it into your browser. Invite the bot to your desired server.
- Get the Channel ID for the specific channel where you want the bot to post messages: Enable Developer Mode in Discord User Settings (Advanced section), then right-click the channel name and select "Copy Channel ID". You'll need this numeric ID for
config.txt
.
- Go to the Releases page of this repository.
- Download the
.zip
file from the latest release assets. - Extract the contents of the
.zip
file into a dedicated folder on your computer. - Find the
config.txt
file included within the extracted files. - Open
config.txt
with a text editor (like Notepad). - Replace
YOUR_DISCORD_BOT_TOKEN_HERE
with your actual Discord Bot Token obtained in Step 1.4. - Replace
YOUR_DISCORD_CHANNEL_ID_HERE
with the numeric Channel ID obtained in Step 1.8. - Save and close the
config.txt
file. - Run the
lockbot.exe
(or similar name) file. It should now connect successfully and appear in your system tray.
# Clone the repository
git clone https://github.com/twolven/DiscordLockBot
cd DiscordLockBot
# Build the application using the build script or dotnet command
# Option 1: Run the build script
./build.bat
# Option 2: Use dotnet CLI directly
dotnet publish -c Release
# Navigate to the publish directory (e.g., bin\Release\net8.0-windows\publish\)
# Find the config.txt template file (you might need to copy it from the project source
# into the publish directory manually if the build doesn't include it).
# Edit config.txt with your Token and Channel ID as described in steps 5-8
# of the "Using the Release Executable" section above.
# Run the executable after configuring config.txt.
- Once configured (via
config.txt
), run thelockbot.exe
. - The application minimizes to the system tray (look for the lock/? icon).
- Right-click the tray icon for options:
- Show Status: View current connection state, lock status, and configuration info.
- Run at Startup: Toggle whether the application starts automatically when you log into Windows.
- Exit: Close the application (sends a shutdown message to Discord if connected).
(Send these in the channel specified in config.txt
)
!status
- Check the current lock status of the monitored computer.!lock
- Attempt to lock the monitored computer remotely.!help
- Show available commands.
(Sent to the configured Discord channel)
- 🔒 Computer locked notification
- 🔓 Computer unlocked notification
- 🟢 Application start notification
- 🔴 Application shutdown notification (when exited gracefully)
- Double-check
config.txt
: Ensure theTOKEN
andCHANNEL_ID
are correct and there are no extra spaces. Make sure you saved the file after editing. Did you remove the placeholder text entirely? - Check Discord Bot Permissions: Verify the bot was invited with
Send Messages
andRead Message History
permissions in the correct channel. - Check Privileged Intents: Ensure the
MESSAGE CONTENT INTENT
is enabled for your bot in the Discord Developer Portal. - Channel ID: Make sure the
CHANNEL_ID
inconfig.txt
is for the specific channel you want the bot to use and where you are typing commands. - Internet Connection: Ensure the computer running the application has internet access.
- Check
config.txt
first, as invalid values can cause startup issues. Ensure you replaced the placeholder text correctly. - If compiling from source, ensure the correct .NET SDK is installed and the build completed without errors.
- Try running the
.exe
from a command prompt (cmd
or PowerShell) - it might print error messages to the console before exiting.
If the application doesn't start automatically with Windows after enabling the option:
- Ensure the application runs correctly when started manually after
config.txt
is properly filled out. - Try toggling the "Run at Startup" option off and on again via the tray menu. Wait a few seconds between toggles.
- Check Windows Task Manager -> Startup tab to see if "LockStatusMonitor" (or similar) is listed and enabled.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT