-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Labels
EnhancementIssues relating to features/fixes that can enhance the code.Issues relating to features/fixes that can enhance the code.
Description
I use this script in my website, and I want to check how long ago a user joined my server.
Looking at the Discord API, that information is accessible via the Guild Member object.
I attempted to add a function for get Guild Member based on the existing get_user function:
# A function to get user information within a guild | (identify scope)
function get_guild_member($guildid)
{
$url = $GLOBALS['base_url'] . "/api/guilds/" . $guildid . "/members/" . $_SESSION['user_id'];
$headers = array('Content-Type: application/x-www-form-urlencoded', 'Authorization: Bearer ' . $_SESSION['access_token']);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
curl_close($curl);
$results = json_decode($response, true);
$_SESSION['nick'] = $results['nick'];
$_SESSION['user_guild_avatar'] = $results['avatar'];
$_SESSION['roles'] = $results['roles'];
$_SESSION['joined_at'] = $results['joined_at'];
$_SESSION['deaf'] = $results['deaf'];
$_SESSION['mute'] = $results['mute'];
$_SESSION['permissions'] = $results['permissions'];
}I didn't test any of the other values, but the joined_at one I wanted was empty, so I did something wrong.
Do you have any idea what I may have done wrong here? It would be excellent if this could be in the official script.
Metadata
Metadata
Assignees
Labels
EnhancementIssues relating to features/fixes that can enhance the code.Issues relating to features/fixes that can enhance the code.