Skip to content

Feature request: Guild Member object #17

@benthetechguy

Description

@benthetechguy

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

No one assigned

    Labels

    EnhancementIssues relating to features/fixes that can enhance the code.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions