Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 7daef9f

Browse files
committed
Fixed some docs and json accessors to reduce chance of ambiguous calls
1 parent e988752 commit 7daef9f

File tree

13 files changed

+32
-28
lines changed

13 files changed

+32
-28
lines changed

include/aegis/gateway/objects/attachment.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ inline void from_json(const nlohmann::json& j, attachment& m)
4242
if (j.count("id"))
4343
m.id = j["id"];
4444
if (j.count("filename"))
45-
m.filename = j["filename"];
45+
m.filename = j["filename"].get<std::string>();
4646
if (j.count("size"))
4747
m.size = j["size"];
4848
if (j.count("url"))
49-
m.url = j["url"];
49+
m.url = j["url"].get<std::string>();
5050
if (j.count("proxy_url"))
51-
m.proxy_url = j["proxy_url"];
51+
m.proxy_url = j["proxy_url"].get<std::string>();
5252
if (j.count("height") && !j["height"].is_null())
5353
m.height = j["height"];
5454
if (j.count("width") && !j["width"].is_null())

include/aegis/gateway/objects/channel.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ inline void from_json(const nlohmann::json& j, channel& m)
8888
for (const auto & i : j["permission_overwrites"])
8989
m.permission_overwrites.push_back(i);
9090
if (j.count("name") && !j["name"].is_null())
91-
m.name = j["name"];
91+
m.name = j["name"].get<std::string>();
9292
if (j.count("topic") && !j["topic"].is_null())
93-
m.topic = j["topic"];
93+
m.topic = j["topic"].get<std::string>();
9494
if (j.count("nsfw") && !j["nsfw"].is_null())
9595
m.nsfw = j["nsfw"];
9696
if (j.count("last_message_id") && !j["last_message_id"].is_null())
@@ -100,7 +100,7 @@ inline void from_json(const nlohmann::json& j, channel& m)
100100
if (j.count("userlimit") && !j["userlimit"].is_null())
101101
m.userlimit = j["userlimit"];
102102
if (j.count("icon") && !j["icon"].is_null())
103-
m.icon = j["icon"];
103+
m.icon = j["icon"].get<std::string>();
104104
if (j.count("owner_id") && !j["owner_id"].is_null())
105105
m.owner_id = j["owner_id"];
106106
if (j.count("application_id") && !j["application_id"].is_null())

include/aegis/gateway/objects/footer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ struct footer
3636
inline void from_json(const nlohmann::json& j, footer& m)
3737
{
3838
if (j.count("text") && !j["text"].is_null())
39-
m.text = j["text"];
39+
m.text = j["text"].get<std::string>();
4040
if (j.count("icon_url") && !j["icon_url"].is_null())
41-
m.icon_url = j["icon_url"];
41+
m.icon_url = j["icon_url"].get<std::string>();
4242
if (j.count("proxy_icon_url") && !j["proxy_icon_url"].is_null())
43-
m.proxy_icon_url = j["proxy_icon_url"];
43+
m.proxy_icon_url = j["proxy_icon_url"].get<std::string>();
4444
}
4545

4646
inline void to_json(nlohmann::json& j, const footer& m)

include/aegis/gateway/objects/guild.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ inline void from_json(const nlohmann::json& j, guild& m)
9393
if (j.count("id") && !j["id"].is_null())
9494
m.id = m.guild_id = j["id"];
9595
if (j.count("name") && !j["name"].is_null())
96-
m.name = j["name"];
96+
m.name = j["name"].get<std::string>();
9797
if (j.count("icon") && !j["icon"].is_null())
98-
m.icon = j["icon"];
98+
m.icon = j["icon"].get<std::string>();
9999
if (j.count("splash") && !j["splash"].is_null())
100-
m.splash = j["splash"];
100+
m.splash = j["splash"].get<std::string>();
101101
if (j.count("owner_id") && !j["owner_id"].is_null())
102102
m.owner_id = j["owner_id"];
103103
if (j.count("region") && !j["region"].is_null())
104-
m.region = j["region"];
104+
m.region = j["region"].get<std::string>();
105105
if (j.count("afk_channel_id") && !j["afk_channel_id"].is_null())
106106
m.afk_channel_id = j["afk_channel_id"];
107107
if (j.count("afk_timeout") && !j["afk_timeout"].is_null())
@@ -117,7 +117,7 @@ inline void from_json(const nlohmann::json& j, guild& m)
117117
if (j.count("mfa_level") && !j["mfa_level"].is_null())
118118
m.mfa_level = j["mfa_level"];
119119
if (j.count("joined_at") && !j["joined_at"].is_null())
120-
m.joined_at = j["joined_at"];
120+
m.joined_at = j["joined_at"].get<std::string>();
121121
if (j.count("large") && !j["large"].is_null())
122122
m.large = j["large"];
123123
if (j.count("unavailable") && !j["unavailable"].is_null())

include/aegis/gateway/objects/guild_member.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ inline void from_json(const nlohmann::json& j, guild_member& m)
4141
{
4242
m._user = j["user"];
4343
if (j.count("nick") && !j["nick"].is_null())
44-
m.nick = j["nick"];
44+
m.nick = j["nick"].get<std::string>();
4545
if (j.count("guild_id") && !j["guild_id"].is_null())
4646
m.guild_id = j["guild_id"];
4747
if (j.count("roles") && !j["roles"].is_null())
4848
for (const auto & _role : j["roles"])
4949
m.roles.push_back(_role);
5050
if (j.count("joined_at"))
51-
m.joined_at = j["joined_at"];
51+
m.joined_at = j["joined_at"].get<std::string>();
5252
if (j.count("deaf"))
5353
m.deaf = j["deaf"];
5454
if (j.count("mute"))

include/aegis/gateway/objects/image.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ struct image
3535
inline void from_json(const nlohmann::json& j, image& m)
3636
{
3737
if (j.count("url") && !j["url"].is_null())
38-
m.url = j["url"];
38+
m.url = j["url"].get<std::string>();
3939
if (j.count("proxy_url") && !j["proxy_url"].is_null())
40-
m.proxy_url = j["proxy_url"];
40+
m.proxy_url = j["proxy_url"].get<std::string>();
4141
if (j.count("height") && !j["height"].is_null())
4242
m.height = j["height"];
4343
if (j.count("width") && !j["width"].is_null())

include/aegis/gateway/objects/member.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ inline void from_json(const nlohmann::json& j, member& m)
6262
for (const auto & _role : j["roles"])
6363
m.roles.push_back(_role);
6464
if (j.count("nick") && !j["nick"].is_null())
65-
m.nick = j["nick"];
65+
m.nick = j["nick"].get<std::string>();
6666
if (j.count("joined_at") && !j["joined_at"].is_null())
67-
m.joined_at = j["joined_at"];
67+
m.joined_at = j["joined_at"].get<std::string>();
6868
if (j.count("mute") && !j["mute"].is_null())
6969
m.mute = j["mute"];
7070
if (j.count("deaf") && !j["deaf"].is_null())

include/aegis/gateway/objects/provider.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ struct provider
3333
inline void from_json(const nlohmann::json& j, provider& m)
3434
{
3535
if (j.count("name") && !j["name"].is_null())
36-
m.name = j["name"];
36+
m.name = j["name"].get<std::string>();
3737
if (j.count("url") && !j["url"].is_null())
38-
m.url = j["url"];
38+
m.url = j["url"].get<std::string>();
3939
}
4040
/// \endcond
4141

include/aegis/gateway/objects/role.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct role
4949

5050
uint32_t color = 0;
5151
snowflake id;
52-
snowflake role_id;
52+
snowflake role_id; //<deprecated use role::id instead
5353
std::string name;
5454
aegis::permission _permission;
5555
uint16_t position = 0;
@@ -66,7 +66,7 @@ inline void from_json(const nlohmann::json& j, role& m)
6666
if (j.count("id") && !j["id"].is_null())
6767
m.id = m.role_id = j["id"];
6868
if (j.count("name") && !j["name"].is_null())
69-
m.name = j["name"];
69+
m.name = j["name"].get<std::string>();
7070
if (j.count("permissions") && !j["permissions"].is_null())
7171
m._permission = j["permissions"];
7272
if (j.count("position") && !j["position"].is_null())

include/aegis/gateway/objects/thumbnail.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ struct thumbnail
3737
inline void from_json(const nlohmann::json& j, thumbnail& m)
3838
{
3939
if (j.count("url"))
40-
m.url = j["url"];
40+
m.url = j["url"].get<std::string>();
4141
if (j.count("proxy_url"))
42-
m.proxy_url = j["proxy_url"];
42+
m.proxy_url = j["proxy_url"].get<std::string>();
4343
if (j.count("height") && !j["height"].is_null())
4444
m.height = j["height"];
4545
if (j.count("width") && !j["width"].is_null())

0 commit comments

Comments
 (0)