Skip to content

Commit

Permalink
🔧 Improved bot api
Browse files Browse the repository at this point in the history
  • Loading branch information
anditv21 committed Aug 14, 2023
1 parent 1936486 commit 3f68893
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/app/models/ApiModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,37 @@ protected function statsAPI()
protected function getuserbydiscord($dcid)
{
try {
$this->prepare("SELECT `username`, `displayname`, `banned` FROM `users` WHERE `dcid` = ?");
$this->prepare("SELECT `username`, `displayname`, `banned`, `admin`, `supp` FROM `users` WHERE `dcid` = ?");
$this->statement->execute([$dcid]);
$result = $this->statement->fetch(PDO::FETCH_ASSOC);

if (!$result) {
return false;
}
$response = [
"status" => "failed",
"error" => "No user with the provided discord id was found"
];
} else {
$username = $result['username'] ?? '';
$displayname = $result['displayname'] ?? '';
$banned = $result['banned'] ?? '';
$admin = $result['admin'] ?? '';
$supp = $result['supp'] ?? '';

return [
"username" => $result['username'],
"display_name" => $result['displayname'],
"banned" => $result['banned'],
"admin" => $result['admin'],
"supp" => $result['supp']
];
$response = [
"username" => $username,
"display_name" => $displayname,
"banned" => $banned,
"admin" => $admin,
"supp" => $supp
];
}
} catch (Exception $e) {
$response = [
"status" => "failed",
"exception" => $e,
"error" => $e->getMessage()
];
}
return $response;
}
}

0 comments on commit 3f68893

Please sign in to comment.