DiscordChannel2Text-Exporter is a Python tool that allows you to export messages from a specified Discord channel into a file. This tool can retrieve a set number of messages from a channel, or optionally all messages, and process them using custom modules.
- Export messages from a Discord channel to a markdown file.
- Define the number of messages to fetch or fetch all messages in the channel.
- Use custom processing modules for message formatting and output.
- Supports fetching messages before or after a specific message ID.
- Handles rate limiting with customizable request timeouts between message fetches.
- Python 3.6+
- A valid Discord Token with access to the required channel
-
Clone this repository:
git clone https://github.com/Makar-Ts/DiscordChannel2Text-Exporter.git cd DiscordChannel2Text-Exporter
-
Configure your Discord token by editing the
config.ini
file located in thelocal
directory (it will appear after the first startup automatically).[DISCORD_LOGIN] TOKEN=your_discord_token_here
To run the script, use the following command:
python main.py <channel_id> <output_dir> <process_type> [options]
channel_id
- The ID of the Discord channel to export messages from.output_dir
- The directory where the file will be saved.process_type
- The type of processing to apply to the messages (must match a module in theprocess
folder).
-ml
,--messages_limit
- Limit the number of messages to fetch (default: 50).-b
,--before
- Fetch messages before this message ID.-a
,--after
- Fetch messages after this message ID.-t
,--timeout
- Set a delay between API requests in milliseconds (default: 0).--all
- Fetch all messages from the channel (not recommended for large channels).-pr_args
,--processer_args
- The processer's arguments.
python main.py 1234567890 ./exports/output.md text.markdown --messages_limit 100 --before 9876543210
This will fetch 100 messages from channel 1234567890
, that were posted before message 9876543210
, and process them using the markdown
processor.
python main.py 1234567890 ./exports/output json.multi --all --timeout 1000 -pr_args="-sbd"
This will fetch all messages from channel 1234567890
with 1s timeout between requests, and process them using the json.multi
processor, with files separated by date.
The process_type
refers to a Python module in the process
directory. Each processor module should implement:
process_messages
- function that handles the fetched messages according to your needs.help
- function that returns info about this processor.set_args
- function that configures processor arguments.check_args
- function that checks arguments
You can create custom processors by adding Python scripts to the process
folder.
This project is licensed under the MIT License. See the LICENSE file for more details.