Fix data not showing up for live map (#1223)
* Fix data not showing up for live map * StyleCI fixes
This commit is contained in:
35
app/Support/Discord.php
Normal file
35
app/Support/Discord.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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 '';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user