mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-29 03:13:55 +01:00
22 lines
540 B
PowerShell
22 lines
540 B
PowerShell
|
function Upload-Discord {
|
||
|
|
||
|
[CmdletBinding()]
|
||
|
param (
|
||
|
[parameter(Position=0,Mandatory=$False)]
|
||
|
[string]$file,
|
||
|
[parameter(Position=1,Mandatory=$False)]
|
||
|
[string]$text
|
||
|
)
|
||
|
|
||
|
$hookurl = 'YOUR-DISCORD-WEBHOOK'
|
||
|
|
||
|
$Body = @{
|
||
|
'username' = $env:username
|
||
|
'content' = $text
|
||
|
}
|
||
|
|
||
|
if (-not ([string]::IsNullOrEmpty($text))){
|
||
|
Invoke-RestMethod -ContentType 'Application/Json' -Uri $hookurl -Method Post -Body ($Body | ConvertTo-Json)};
|
||
|
|
||
|
if (-not ([string]::IsNullOrEmpty($file))){curl.exe -F "file1=@$file" $hookurl}
|
||
|
}
|