Selenium Discord Website Check Bot

Test this app for free
123
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import requests
import discord
from discord.ext import commands
import os

# Obtain the Discord bot token from environment variables
bot_token = os.environ['DISCORD_BOT_TOKEN']

intents = discord.Intents.all()  # enable all intents
bot = commands.Bot(command_prefix="!", intents=intents)

@bot.command()
async def website_stats(ctx, website_link: str):
    # Check if the URL is correct
    if not website_link.startswith("http://") and not website_link.startswith("https://"):
        await ctx.send("The URL is not correct. Please enter a valid URL.")
        return

    options = Options()
    options.add_argument("--no-sandbox")
Get full code

Created: | Last Updated:

The Website Stats App is a Discord bot that provides detailed statistics about a given website. It visits the website, determines its load time, status, and security level, and sends this information back to a Discord command. The app also handles errors for incorrect URLs, notifies the user if the website processing is taking some time, and alerts the user if the website is down or not reachable. The app requires the DISCORD_BOT_TOKEN environment variable to be set in the Env Secrets tab. The app supports the !website_stats command on Discord.

Introduction to the Selenium Discord Website Check Bot Template

Welcome to the step-by-step guide on how to use the Selenium Discord Website Check Bot template. This template allows you to create a Discord bot that can provide detailed statistics about a given website, such as its load time, status, and security level. The bot will respond to commands within Discord, making it a handy tool for anyone looking to monitor website performance directly from their server.

To get started with this template, simply click on "Start with this Template" on the Lazy platform. This will set up the template in your Lazy Builder interface, ready for customization and deployment.

Setting Environment Secrets

Before you can use the bot, you need to set up an environment secret for the Discord bot token. This token is essential for the bot to authenticate and interact with the Discord API.

  • Go to the Environment Secrets tab within the Lazy Builder.
  • Create a new secret with the key `DISCORD_BOT_TOKEN`.
  • Paste your Discord bot token as the value for this secret.

Ensure that you have created a bot on the Discord Developer Portal and obtained the token from there. If you need help creating a bot and getting the token, please refer to the Discord Developer Documentation.

External Integrations

There are no external integrations required for this template other than setting up the Discord bot and obtaining the bot token as mentioned above.

Using the Test Button

Once you have set up the environment secret, you can deploy the bot by clicking the Test button. This will launch the Lazy CLI, and if the code requires any user input, you will be prompted to provide it at this stage.

After the deployment is complete, the bot will be running and ready to listen for commands on your Discord server. You can invite the bot to your server using the OAuth2 URL provided by the Discord Developer Portal where you created your bot.

Interacting with the Bot

To use the bot, simply type the `!website_stats` command followed by a valid website URL in your Discord server. For example:

`!website_stats https://www.example.com`

The bot will process your request and provide you with the website's load time, status code, and security level. If the website is not reachable or if there is an error, the bot will inform you accordingly.

Remember, the bot will only respond to commands within the Discord server it has been invited to and where it has the necessary permissions to read and send messages.

That's all you need to get started with the Selenium Discord Website Check Bot template on Lazy. By following these steps, you can quickly deploy a functional Discord bot that helps you monitor website statistics directly from your server.

Technologies

Enhance Selenium Automation with Lazy AI: API Testing, Scraping and More Enhance Selenium Automation with Lazy AI: API Testing, Scraping and More
Discord Automation & Bots Discord Automation & Bots

Similar templates

We found some blogs you might like...