-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
274 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "Emoji.h" | ||
|
||
DiscordCPP::Emoji::Emoji(const json& data, const std::string& token) | ||
: DiscordObject(token, data.at("id").get<std::string>()) { | ||
name = get_optional<std::string>(data, "name"); | ||
|
||
if (has_value(data, "roles")) { | ||
for (json role : data.at("roles")) { | ||
role_ids.push_back(role.get<std::string>()); | ||
} | ||
} | ||
if (has_value(data, "data")) { | ||
user = User(data.at("user"), get_token()); | ||
} | ||
|
||
require_colons = get_or_else<bool>(data, "require_colons", false); | ||
managed = get_or_else<bool>(data, "managed", false); | ||
animated = get_or_else<bool>(data, "animated", false); | ||
available = get_or_else<bool>(data, "available", true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "DiscordObject.h" | ||
#include "User.h" | ||
|
||
namespace DiscordCPP { | ||
class Emoji : public DiscordObject { | ||
private: | ||
/// emoji name | ||
std::optional<std::string> name; | ||
/// roles allowed to use this emoji | ||
std::vector<std::string> role_ids; | ||
/// user that created this emoji | ||
std::optional<User> user; | ||
/// wether this emoji must be wrapped in colons | ||
bool require_colons; | ||
/// wether this emoji is managed | ||
bool managed; | ||
/// wether this emoji is animated | ||
bool animated; | ||
/// whether this emoji can be used, may be false due to loss of Server Boosts | ||
bool available; | ||
|
||
public: | ||
DLL_EXPORT Emoji() = default; | ||
DLL_EXPORT Emoji(const json& data, const std::string& token); | ||
|
||
/// @return emoji name | ||
std::optional<std::string> get_name() { return name; } | ||
/// @return roles allowed to use this emoji | ||
std::vector<std::string> get_role_ids() { return role_ids; } | ||
/// @return user that created this emoji | ||
std::optional<User> get_user() { return user; } | ||
/// @return wether this emoji must be wrapped in colons | ||
bool requires_colons() { return require_colons; } | ||
/// @return wether this emoji is managed | ||
bool is_managed() { return managed; } | ||
/// @return wether this emoji is animated | ||
bool is_animated() { return animated; } | ||
/// @return whether this emoji can be used, may be false due to loss of Server Boosts | ||
bool is_available() { return available; } | ||
}; | ||
} // namespace DiscordCPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#pragma once | ||
#include <iostream> | ||
|
||
#include "DiscordObject.h" | ||
#include "Embed.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "Reaction.h" | ||
|
||
DiscordCPP::Reaction::Reaction(const json& data, const std::string& token) : BaseDiscordObject(token) { | ||
user_id = data.at("user_id").get<std::string>(); | ||
channel_id = data.at("channel_id").get<std::string>(); | ||
message_id = data.at("message_id").get<std::string>(); | ||
guild_id = get_optional<std::string>(data, "guild_id"); | ||
|
||
if (has_value(data, "member")) { | ||
member = Member(data.at("member"), token); | ||
} | ||
|
||
emoji = Emoji(data.at("emoji"), get_token()); | ||
message_author_id = get_optional<std::string>(data, "message_author_id"); | ||
burst = get_or_else<bool>(data, "burst", false); | ||
|
||
if (has_value(data, "burst_colors")) { | ||
for (json color : data.at("burst_colors")) { | ||
burst_colors.push_back(color.get<std::string>()); | ||
} | ||
} | ||
|
||
type = static_cast<Type>(data.at("type").get<int>()); | ||
} | ||
|
||
DiscordCPP::User DiscordCPP::Reaction::get_user() { | ||
if (!user.has_value()) { | ||
user = User(user_id, get_token()); | ||
} | ||
|
||
return user.value(); | ||
} | ||
|
||
DiscordCPP::TextChannel DiscordCPP::Reaction::get_channel() { | ||
if (!channel.has_value()) { | ||
channel = TextChannel(channel_id, get_token()); | ||
} | ||
|
||
return channel.value(); | ||
} | ||
|
||
DiscordCPP::Message DiscordCPP::Reaction::get_message() { | ||
if (!message.has_value()) { | ||
message = Message(message_id, get_token()); | ||
} | ||
|
||
return message.value(); | ||
} | ||
|
||
std::optional<DiscordCPP::Guild> DiscordCPP::Reaction::get_guild() { | ||
if (!guild_id.has_value() && guild_id.has_value()) { | ||
guild = Guild(nullptr, guild_id.value(), get_token()); | ||
} | ||
|
||
return guild; | ||
} | ||
|
||
std::optional<DiscordCPP::User> DiscordCPP::Reaction::get_message_author() { | ||
if (!message_author.has_value() && message_author_id.has_value()) { | ||
message_author = User(message_author_id.value(), get_token()); | ||
} | ||
|
||
return message_author; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "DiscordObject.h" | ||
#include "Emoji.h" | ||
#include "Guild.h" | ||
#include "Member.h" | ||
#include "Message.h" | ||
#include "TextChannel.h" | ||
#include "Threadpool.h" | ||
#include "User.h" | ||
|
||
namespace DiscordCPP { | ||
class Reaction : public BaseDiscordObject { | ||
public: | ||
enum Type { | ||
NORMAL = 0, | ||
BURST = 1 | ||
}; | ||
|
||
private: | ||
/// id of the user | ||
std::string user_id; | ||
/// the user who sent the reaction | ||
std::optional<User> user; | ||
/// id of the channel | ||
std::string channel_id; | ||
/// the channel of the message | ||
std::optional<TextChannel> channel; | ||
/// id of the message | ||
std::string message_id; | ||
/// the message of this reaction | ||
std::optional<Message> message; | ||
/// id of the guild | ||
std::optional<std::string> guild_id; | ||
/// the guild of the channel | ||
std::optional<Guild> guild; | ||
/// the guild member who reacted | ||
std::optional<Member> member; | ||
/// emoji used to react | ||
Emoji emoji; | ||
/// id of the message author | ||
std::optional<std::string> message_author_id; | ||
/// the message author | ||
std::optional<User> message_author; | ||
/// true if this is a super reaction | ||
bool burst; | ||
/// colors used for super reaction im #rrggbb format | ||
std::vector<std::string> burst_colors; | ||
/// the type of the reaction | ||
Type type; | ||
|
||
public: | ||
DLL_EXPORT Reaction(const json& data, const std::string& token); | ||
|
||
/// @return id of the user | ||
std::string get_user_id() { return user_id; } | ||
/// @return the user who sent the reaction | ||
User get_user(); | ||
/// @return id of the channel | ||
std::string get_channel_id() { return channel_id; } | ||
/// @return the channel of the message | ||
TextChannel get_channel(); | ||
/// @return id of the message | ||
std::string get_message_id() { return message_id; } | ||
/// @return the message of this reaction | ||
Message get_message(); | ||
/// @return id of the guild | ||
std::optional<std::string> get_guild_id() { return guild_id; } | ||
/// @return the guild of the channel | ||
std::optional<Guild> get_guild(); | ||
/// @return the guild member who reacted | ||
std::optional<Member> get_member() { return member; } | ||
/// @return emoji used to react | ||
Emoji get_emoji() { return emoji; } | ||
/// @return id of the message author | ||
std::optional<std::string> get_message_author_id() { return message_author_id; } | ||
/// @return the message author | ||
std::optional<User> get_message_author(); | ||
/// @return true if this is a super reaction | ||
bool is_burst() { return burst; } | ||
/// @return colors used for super reaction im #rrggbb format | ||
std::vector<std::string> get_burst_colors() { return burst_colors; } | ||
/// @return the type of the reaction | ||
Type get_type() { return type; } | ||
}; | ||
} // namespace DiscordCPP |
Oops, something went wrong.