Simple Discord bot to monitor a website's uptime and latency. *Used for monitoring hatch.lol's API.
- Install Python if you don't already have it - download
- Install dependencies with
pip install discord.py requests - Download the latest version of WatchBot from the releases tab
- Configure your bot. Open
config.jsonand edit the URL you want to monitor, the wait time (15 seconds by default), the command prefix (if desired), your bot's token (see Creating Your Bot), and the role ID of the role you want to be able to run the commands. I recommend keeping setting it to your administrator or owner role so users don't disable the monitoring. - Run
bot.py: usepy bot.pyin your terminal on Windows orpython3 bot.pyon Linux. - Begin monitoring: type
!beginin the channel you'd like the bot to send updates to. If you changed the prefix in the configuration file, use that instead of ! - To stop monitoring for any reason, you can use
!stop.
If you don't have a Discord bot application set up, this section helps you do it.
- Log in to the Discord Developer Portal
- Click the button in the top right that says New Application
- Name the bot and agree to the terms. Then click create.
- Click on the Bot tab on the left, scroll down to Token and then click Reset Token.
- Copy the token and store it somewhere safe and private.
- Scroll down to Privileged Gateway Intents and enable Server Members Intent and Message Content Intent.
- On the left sidebar, click on the OAuth2 tab, scroll down to OAuth2 URL Generator and choose Bot, then in the new menu that appears below choose Administrator (you may want to select individual permissions instead).
Caution
Enabling the Administrator permission gives your bot access to everything in whichever server you add it to, which will be destructive if you do not store your token securely. (KEEP YOUR TOKEN PRIVATE!) Also, if you do not own the server you are adding the bot to, you may need to select individual permissions instead, such as Send Messages, Manage Messages, Embed Links, Attach Files, Add Reactions, View Channels, and Manage Server if you want it to be able to work in private channels.
- Select Guild Install from the dropdown after you've selected the bot permissions, and copy the generated URL. Then paste it into a new tab and add the bot to your server.
- Select the Installation tab on the left side and uncheck the User Install box. Then, use the dropdown below to set Install Link to None
- Select the Bot tab again, and toggle Public Bot off. Your bot then should be ready to go! Steps 9 and 10 go through setting your bot as private so people can't add it to their own server. You can now start the bot setup detailed above.