Overhaul a lot, fix the JS implementation

This commit is contained in:
2016-08-10 17:07:41 +01:00
parent f47d8adc36
commit e4cc023055
19 changed files with 1236 additions and 632 deletions

View File

@ -57,7 +57,7 @@ namespace DiscordObjects {
type = "text";
}
inline Channel::Channel(json data) {
inline Channel::Channel(json data) : Channel() {
load_from_json(data);
}

View File

@ -73,7 +73,7 @@ namespace DiscordObjects {
bool unavailable;
std::vector<Channel *> channels;
std::map<std::string, GuildMember> members;
std::vector<GuildMember *> members;
std::vector<Role *> roles;
//std::vector<std::unique_ptr<DiscordObjects::User>> users;
};
@ -83,13 +83,11 @@ namespace DiscordObjects {
afk_timeout = verification_level = -1;
}
inline Guild::Guild(json data) {
inline Guild::Guild(json data) : Guild() {
load_from_json(data);
}
inline void Guild::load_from_json(json data) {
Guild();
id = data.value("id", "null");
name = data.value("name", "null");
icon = data.value("icon", "null");

View File

@ -30,13 +30,12 @@ namespace DiscordObjects {
inline GuildMember::GuildMember() {
user = nullptr;
nick = "null";
joined_at = "null";
nick = joined_at = "null";
deaf = false;
mute = false;
}
inline GuildMember::GuildMember(json data, User *user) {
inline GuildMember::GuildMember(json data, User *user) : GuildMember() {
this->user = user;
load_from_json(data);
}
@ -54,6 +53,8 @@ namespace DiscordObjects {
+ "\n**bot:** " + std::to_string(user->bot)
+ "\n**mfa_enabled:** " + std::to_string(user->mfa_enabled)
+ "\n**avatar:** " + user->avatar
+ "\n**status:** " + user->status
+ "\n**game name:** " + user->game
+ "\n**nick:** " + nick
+ "\n**joined_at:** " + joined_at
+ "\n**deaf:** " + std::to_string(deaf)

View File

@ -42,7 +42,7 @@ namespace DiscordObjects {
mentionable = false;
}
inline Role::Role(json data) {
inline Role::Role(json data) : Role() {
load_from_json(data);
}

View File

@ -39,15 +39,20 @@ namespace DiscordObjects {
bool bot;
bool mfa_enabled;
// presence
std::string game;
std::string status;
std::vector<std::string> guilds;
};
inline User::User() {
id = username = discriminator = avatar = "null";
id = username = discriminator = avatar = game = "null";
status = "offline";
bot = mfa_enabled = false;
}
inline User::User(json data) {
inline User::User(json data) : User() {
load_from_json(data);
}