A Python script that uses discord.py
to collect all messages from a specified channel in a Discord server.
- Python 3.x
discord.py
library- A Discord account and a server where you have administrative or read message permissions
-
Install Python: If you don't have Python installed, download and install it from python.org.
-
Install
discord.py
: Open your command prompt and run:pip install discord.py
-
Clone this repository or download the script.
- Create a Discord Bot:
- Go to Discord Developer Portal
- Click "New Application" and give it a name.
- Navigate to the "Bot" tab and click "Add Bot".
- Under the "TOKEN" section, click "Copy" to copy your bot token.
- Activate "Message Content Intent":
- Still in the same "Bot" session
- Scroll down in the "Privileged Gateway Intents" area
- Activate "Message Content Intent"
- Invite the Bot to Your Server:
- Go to the "OAuth2" tab in your bot's application page.
- Under "URL Generator", select "bot" in the scopes section.
- Choose the necessary permissions (at minimum, "Read Messages").
- Copy the generated URL and use it to invite the bot to your server.
-
Open your command prompt and navigate to the directory where the script is located.
-
Run the script:
python discord_scraper.py
-
The script will prompt you to enter the name of the Discord server and the bot token.
- For the server name, enter the name of the Discord server you want to collect messages from.
- For the bot token, paste the token you copied earlier.
-
Check the Output
- The script will save all messages from each text channel to a separate text file, named after the channel (e.g.,
general_messages.txt
,random_messages.txt
, etc.). - Messages that could not be accessed will be reported in the console.
- The script will save all messages from each text channel to a separate text file, named after the channel (e.g.,