diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-11-28 22:48:30 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-11-28 22:48:30 -0500 |
commit | e1703aea3fd597b23bde90e6c505278c517be611 (patch) | |
tree | 37d98fc90c9cd0844388bfb79beda2204f44af92 /src/discord/channel.hpp | |
parent | fd53a76bf6f53a095a639765923a30f2206b2cd6 (diff) | |
parent | e02107feea8214a045e6faa969f00dcbc0d2b072 (diff) | |
download | abaddon-portaudio-e1703aea3fd597b23bde90e6c505278c517be611.tar.gz abaddon-portaudio-e1703aea3fd597b23bde90e6c505278c517be611.zip |
merge master
Diffstat (limited to 'src/discord/channel.hpp')
-rw-r--r-- | src/discord/channel.hpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/discord/channel.hpp b/src/discord/channel.hpp new file mode 100644 index 0000000..942d555 --- /dev/null +++ b/src/discord/channel.hpp @@ -0,0 +1,92 @@ +#pragma once +#include "snowflake.hpp" +#include "json.hpp" +#include "user.hpp" +#include "permissions.hpp" +#include <string> +#include <vector> + +enum class ChannelType : int { + GUILD_TEXT = 0, + DM = 1, + GUILD_VOICE = 2, + GROUP_DM = 3, + GUILD_CATEGORY = 4, + GUILD_NEWS = 5, + GUILD_STORE = 6, + /* 7 and 8 were used for LFG */ + /* 9 was used for threads */ + GUILD_NEWS_THREAD = 10, + GUILD_PUBLIC_THREAD = 11, + GUILD_PRIVATE_THREAD = 12, + GUILD_STAGE_VOICE = 13, +}; + +enum class StagePrivacy { + PUBLIC = 1, + GUILD_ONLY = 2, +}; + +constexpr const char *GetStagePrivacyDisplayString(StagePrivacy e) { + switch (e) { + case StagePrivacy::PUBLIC: + return "Public"; + case StagePrivacy::GUILD_ONLY: + return "Guild Only"; + default: + return "Unknown"; + } +} + +// should be moved somewhere? + +struct ThreadMetadataData { + bool IsArchived; + int AutoArchiveDuration; + std::string ArchiveTimestamp; + std::optional<bool> IsLocked; + + friend void from_json(const nlohmann::json &j, ThreadMetadataData &m); +}; + +struct ThreadMemberObject { + std::optional<Snowflake> ThreadID; + std::optional<Snowflake> UserID; + std::string JoinTimestamp; + int Flags; + + friend void from_json(const nlohmann::json &j, ThreadMemberObject &m); +}; + +struct ChannelData { + Snowflake ID; + ChannelType Type; + std::optional<Snowflake> GuildID; + std::optional<int> Position; + std::optional<std::vector<PermissionOverwrite>> PermissionOverwrites; // shouldnt be accessed + std::optional<std::string> Name; // null for dm's + std::optional<std::string> Topic; // null + std::optional<bool> IsNSFW; + std::optional<Snowflake> LastMessageID; // null + std::optional<int> Bitrate; + std::optional<int> UserLimit; + std::optional<int> RateLimitPerUser; + std::optional<std::vector<UserData>> Recipients; // only access id + std::optional<std::vector<Snowflake>> RecipientIDs; + std::optional<std::string> Icon; // null + std::optional<Snowflake> OwnerID; + std::optional<Snowflake> ApplicationID; + std::optional<Snowflake> ParentID; // null + std::optional<std::string> LastPinTimestamp; // null + std::optional<ThreadMetadataData> ThreadMetadata; + std::optional<ThreadMemberObject> ThreadMember; + + friend void from_json(const nlohmann::json &j, ChannelData &m); + void update_from_json(const nlohmann::json &j); + + bool NSFW() const; + bool IsThread() const noexcept; + bool IsJoinedThread() const; + std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const; + std::vector<UserData> GetDMRecipients() const; +}; |