forked from rcxpony/sparkle
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#ifndef API_AUTHOR_HPP_
|
|
#define API_AUTHOR_HPP_
|
|
#include <utils/json.hpp>
|
|
#include <string>
|
|
#include <exception>
|
|
#include <iostream>
|
|
using std::string;
|
|
using std::cout;
|
|
using std::endl;
|
|
using json = nlohmann::json;
|
|
class Author {
|
|
private:
|
|
json data;
|
|
public:
|
|
Author(const json& data) : data(data) {}
|
|
string content() {
|
|
try {
|
|
return data["d"]["content"];
|
|
}
|
|
catch (std::exception& e) {
|
|
return e.what();
|
|
}
|
|
}
|
|
string channel_id() {
|
|
return data["d"]["channel_id"];
|
|
}
|
|
string id() {
|
|
return data["d"]["author"]["id"];
|
|
}
|
|
string global_name() {
|
|
return data["d"]["author"]["global_name"].dump();
|
|
}
|
|
string discriminator() {
|
|
return data["d"]["author"]["discriminator"];
|
|
}
|
|
bool isBot() {
|
|
try {
|
|
return data["d"]["author"]["bot"];
|
|
}
|
|
catch (std::exception& e) {
|
|
return false;
|
|
}
|
|
}
|
|
string guild_id() {
|
|
return data["d"]["guild_id"];
|
|
}
|
|
string msg_id() {
|
|
return data["d"]["id"];
|
|
}
|
|
bool isPinned() {
|
|
return data["d"]["pinned"];
|
|
}
|
|
string avatar() {
|
|
return data["d"]["author"]["avatar"];
|
|
}
|
|
};
|
|
#endif |