Skip to content

Do not upload files, only text #6

@Tarkiin

Description

@Tarkiin

A few days ago I was using it and it worked perfectly
Now it does not upload files, can you verify that it works and what causes the error?
Some errors:
Error 1

curl.exe : curl: (26) Failed to open/read local data from file/application
En C:\Users\admin\Desktop\upload-discord.ps1: 20 Carácter: 44

  • ... [string]::IsNullOrEmpty($file))){curl.exe -F "file1=@$file" $hookurl}
  •                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (curl: (26) Fail...ile/application:String) [], RemoteException
    • FullyQualifiedErrorId : NativeCommandError

Error 2

curl.exe : % Total % Received % Xferd Average Speed Time Time Time Current
In C:\Users\admin\Desktop\ Upload files to discord.ps1: 21 Character: 44

  • ... [string]::IsNullOrEmpty($file))){curl.exe -F "file1=@$file" $hookurl}
  •    + CategoryInfo : NotSpecified: ( % Total % ... Time Current:String) [], RemoteException
       + FullyQualifiedErrorId : NativeCommandError
    
                                    Dload Upload Total Spent Left Speed
     0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
     0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
    

curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function cannot check revocation for the certificate.


function Upload-Discord {

[CmdletBinding()]
param (
    [parameter(Position=0,Mandatory=$False)]
    [string]$file,
    [parameter(Position=1,Mandatory=$False)]
    [string]$text 
)

$hookurl = "https://discord.com/api/webhooks/XXXXXXXXXXXXXX"
$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}
}


Upload-Discord -file "C:\Users\admin\Desktop\Bar.gif" -text "Text"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions