You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.7 KiB
2.7 KiB
Scheduling exports on Windows
We'll be using DiscordChatExporter CLI, PowerShell, and Task Scheduler.
- Open a text editor such as Notepad and paste:
# Info: https://github.com/Tyrrrz/DiscordChatExporter/wiki
$TOKEN = "tokenhere"
$CHANNEL = "channelhere"
$EXEPATH = "exefolderhere"
$FILENAME = "filenamehere"
$EXPORTDIRECTORY = "dirhere"
$EXPORTFORMAT = "formathere"
# Available export formats: PlainText, HtmlDark, HtmlLight, Json, Csv
cd $EXEPATH
.\DiscordChatExporter.Cli.exe export -t $TOKEN -c $CHANNEL -f $EXPORTFORMAT -o "$FILENAME.tmp"
$Date = Get-Date -Format "yyyy-MM-dd-HH-mm"
If($EXPORTFORMAT -match "PlainText"){mv "$FILENAME.tmp" -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.txt"}
ElseIf($EXPORTFORMAT -match "HtmlDark"){mv "$FILENAME.tmp" -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.html"}
ElseIf($EXPORTFORMAT -match "HtmlLight"){mv "$FILENAME.tmp" -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.html"}
ElseIf($EXPORTFORMAT -match "Json"){mv "$FILENAME.tmp" -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.json"}
ElseIf($EXPORTFORMAT -match "Csv"){mv "$FILENAME.tmp" -Destination "$EXPORTDIRECTORY\$FILENAME-$Date.csv"}
exit
- Replace:
tokenhere
with your Tokenchannelhere
with a Channel IDexefolderhere
with the .exe directory's path (e.g. C:\Users\User\Desktop\DiscordChatExporter)filenamehere
with a filename without spacesdirhere
with the export directory (e.g. C:\Users\User\Documents\Exports)formathere
with one of the available export formats
Make sure not to delete the quotes (")
- Save the file as
filename.ps1
not.txt
Export at Startup
- Press Windows + R, type
shell:startup
and press ENTER - Paste
filename.ps1
or a shortcut into this folder
Scheduling with Task Scheduler
Please notice your computer must be turned on so the exportation can occur.
- Press Windows + R, type
taskschd.msc
and press ENTER - Select
Task Scheduler Library
, create a Basic Task, and follow the instructions on-screen
- At 'Start a Program', write
powershell -file -ExecutionPolicy ByPass -WindowStyle Hidden "C:\path\to\filename.ps1"
in the Program/script text box
- Click 'Yes'
- Click 'Finish'
Special thanks to @Yudi