Closed StrangerGithuber closed 3 years ago
Can you catch the exception and log out the response body
Hmm I am getting same. I put the code between try catch and I return the error message but I get the same message. Edit: Two months ago it worked but yesterday when I looked the project then this function didn't work.
Edit 2: I found this in the error logs:
[2020-01-27 00:34:03] local.ERROR: There was an error executing the leaveGuild command: Client error: `DELETE https://discordapp.com/api/v6/users/@me/guilds/652119293600989196` resulted in a `400 BAD REQUEST` response:
{"userId":14,"exception":"[object] (GuzzleHttp\\Command\\Exception\\CommandClientException(code: 0): There was an error executing the leaveGuild command: Client error: `DELETE https://discordapp.com/api/v6/users/@me/guilds/652119293600989196` resulted in a `400 BAD REQUEST` response:
at E:\\Projektek\\xyz\\vendor\\guzzlehttp\\command\\src\\Exception\\CommandException.php:57)
#18 E:\\Projektek\\xyz\\vendor\
estcord\
estcord\\src\\OverriddenGuzzleClient.php(86): GuzzleHttp\\Command\\ServiceClient->__call('leaveGuild', Array)
#19 E:\\Projektek\\xyt\\app\\Http\\Controllers\\ApiController.php(1399): RestCord\\OverriddenGuzzleClient->__call('leaveGuild', Array)
You have to dig through and get the guzzle server exception
Hmm which PHP version recommended? Documentation saying 7.0 and above but hmm now I have 7.4.1 which the newest xampp using.
I tried with guzzle's GuzzleHttp\Exception\ClientException but getting the same. Here is the full log file:
[2020-01-27 22:29:23] local.ERROR: There was an error executing the leaveGuild command: Client error:
DELETE https://discordapp.com/api/v6/users/@me/guilds/652118692481466388resulted in a
400 BAD REQUEST` response:
{"userId":14,"exception":"[object] (GuzzleHttp\Command\Exception\CommandClientException(code: 0): There was an error executing the leaveGuild command: Client error: DELETE https://discordapp.com/api/v6/users/@me/guilds/652118692481466388
resulted in a 400 BAD REQUEST
response:
at E:\Projektek\xyz\vendor\guzzlehttp\command\src\Exception\CommandException.php:57) [stacktrace]
estcord\ estcord\src\OverriddenGuzzleClient.php(86): GuzzleHttp\Command\ServiceClient->__call('leaveGuild', Array)
[previous exception] [object] (GuzzleHttp\Exception\ClientException(code: 400): Client error: DELETE https://discordapp.com/api/v6/users/@me/guilds/652118692481466388
resulted in a 400 BAD REQUEST
response:
at E:\Projektek\xyz\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113) [stacktrace]
estcord\ estcord\src\OverriddenGuzzleClient.php(86): GuzzleHttp\Command\ServiceClient->__call('leaveGuild', Array)
"} ` Hmm now I think back two months ago I had the php 7.2. Hmm maybe I need to expand something in the php settings? Hmm I don't know. I will try to setup stuffs in the php.ini file.
Edit: Increased these to following in php.ini and these didn't fix the problem: max_input_vars = 10000 memory_limit=1000M post_max_size=80M upload_max_filesize=100M
Edit 2: Hmm it seems same issue with the php 7.2 version. 🤔
Experiencing this issue on 7.3 as well, unable to find the resolution yet but will update if I find anything.
You can catch the actual error from discord with:
try {
$discordguild = new DiscordClient( [ 'token' => env( 'DISCORD_BOT_TOKEN' ) ] );
$discordguild->user->leaveGuild(['guild.id' => (int)$guildid]);
} (\GuzzleHttp\Exception\ClientException $e) {
var_dump($e->getResponse()->getBody()->getContents()); // May need to toString this as well
}
I'm having this same problem, when I get the error it only says: 400 Bad Request and code 0. But doing doing the same request with curl works fine
I just discovered that if I add the header 'Content-Type' => 'application/json', (which is present in the request made by Restcord) to my request using curl, it fails with the same error (400 Bad Request). Then, I removed the header from the request made by restcord and it worked. Don't know if that's all the bug or there is more, but it should help
Hello I can get the channels and members but I can't make the bot to leave the server when the owner click to the remove button. I get this message when I am trying to use:
There was an error executing the leaveGuild command: Client error:
DELETE https://discordapp.com/api/v6/users/@me/guilds/652119293600989196resulted in a
400 BAD REQUEST``The token is right used otherwise I couldn't get the guild channels and members so it can't be the problem. I am trying to use this way:
$discordguild = new DiscordClient( [ 'token' => env( 'DISCORD_BOT_TOKEN' ) ] ); $discordguild->user->leaveGuild(['guild.id' => (int)$guildid]);
What is the problem?