Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 2.11 KB

README.md

File metadata and controls

56 lines (37 loc) · 2.11 KB

discordBotWithStats

Python Discord bot that scrapes data from FiveThirtyEight's 2024 Election Forecast and updates the bot's nickname with election statistics.

Prerequisites

When creating a Discord bot through the Discord Developer Portal, make sure you enable both SERVER MEMBERS INTENT and MESSAGE CONTENT INTENT.

image

Required Libraries

You'll need to install:

  • beautifulsoup4
  • requests
  • discord.py

Bot Invitation

To invite the bot to a server:

  1. Select "bot" under scopes.
  2. Under Bot Permissions, enable:
    • View Channels
    • Send Messages
    • Read Message History
    • Change Nickname

Environment Variables

You can use an .env file to store environment variables securely (or store them within your IDE if supported). Never share your token with anyone. The .env file should include:

AUTHORIZED_USER_ID=<YOUR_USER_ID>
TOKEN=<DISCORD_BOT_TOKEN>

How to Use

To update the bots nickname with the latest election statistics, send a Direct Message (DM) to the bot in the following format:

update <server_id_that_the_bot_is_in>

Replace <server_id_that_the_bot_is_in> with the actual ID of the server where the bot is active.

How to Use

Notes

As of October 27, 2024, this program scrapes data successfully. However, future changes to the website's layout or structure may prevent successful scraping.

Website Screenshot

Website Screenshot

Python Program Screenshot

Python Program Screenshot


Special thanks to FiveThirtyEight for collecting and providing election data. This bot relies on manual calls to scrape data to avoid overloading the website. Please use it responsibly.