phpvms/app/Support/Discord.php
Nabeel S 96d33c11c8
Fix data not showing up for live map (#1223)
* Fix data not showing up for live map

* StyleCI fixes
2021-06-04 16:57:27 -04:00

36 lines
834 B
PHP

<?php
namespace App\Support;
use Illuminate\Support\Facades\Log;
class Discord
{
/**
* Get a user's private channel ID from Discord
*
* @param string $discord_id
*/
public static function getPrivateChannelId(string $discord_id)
{
/** @var HttpClient $httpClient */
$httpClient = app(HttpClient::class);
try {
$response = $httpClient->post(
'https://discord.com/api/users/@me/channels',
[
'recipient_id' => $discord_id,
]
);
dd($response);
return $response->id;
} catch (\Exception $ex) {
dd($ex);
Log::error('Could not get private channel id for '.$discord_id.';'.$ex->getMessage());
return '';
}
}
}