<?php
class Discord {
private $members = array();
private $invitelink = NULL;
function __construct() {
$jsoncontents = file_get_contents('https://discord.com/api/guilds/173993845166571520/widget.json', true);
$JSON = json_decode($jsoncontents, true);
$this->members = $JSON['members'];
if (isset($JSON['instant_invite']))
$this->invitelink = $JSON['instant_invite'];
}
private function getMembers() {
return $this->members;
}
public function getUserCount() {
return sizeof(self::getMembers());
}
public function getUsersInVoice() {
$count = 0;
for ($i = 0; $i < count(self::getMembers()); $i++) {
if (isset(self::getMembers()[$i]['channel_id']))
$count++;
}
return $count;
}
public function getInviteLink() {
return $this->invitelink;
}
}