- The first run takes a bit of time as it has to export the entire server.
- Then subsequent runs are not as much time consuming as it exports after the last message exported per channel.
- First of all get the latest version of Discord Chat Exporter CLI from here
- Extract it in DCE_CLI folder.
- Open config.py and edit the config accordingly.
- Open backup_server.bat file and edit the
MAIN_PATH
variable. Make sure it is the same as theMAIN_PATH
variable in config.py. And make sure it ends with a backslash\
- Run the backup_server.bat and it will start backupping your server.
PRO Tip 1 : Send the backup_server.bat file to desktop as shortcut and run it whenever you want to export
PRO Tip 2 : Set backup_server.bat in windows task scheduler and it will run whenever you want automatically. (Tutorial)
PRO Tip 3: You can conver these JSON Files to HTML via DCE-JSONtoHTML
- Using the bot token with highest privileges is recommended
- Please while running the script for large servers, do not use any other highly RAM dependent programs, as the script loads the entire json file while stitching. [This will be fixed by using
ijson
library which loads only a part of json file, but for my usecase json module works just fine.]
Lets say i run the script for the first time today. The script will call the official discord api and do the following
-
Get all Channels and the id of the last message sent in them.
- 1.1 Compare these ids with the last message id already exported files in Exported Files Directory [Empty if exporting for the first time]
- 1.2 Then if the last message id doesnt match, it adds that channel id to be exported. (The messages after sent that last message will be exported)
-
Get all the threads in all the channels (Both archived and public).
- Repeat the above process as of the channels again.
-
Then it makes another batch script which will be called for exporting via Discord Chat Exporter CLI. (Happens automatically)
-
Lastly it stitches the json files made.
- More info on stitching:
- The files exported by the script after the last sent message (step 1.2) are made into a separate file, so the script stitches those separate file with the original file.