From a51a54bc5979a2491f152abc47ad54e6b63f27c8 Mon Sep 17 00:00:00 2001 From: Dylam De La Torre Date: Tue, 23 Nov 2021 05:21:56 +0100 Subject: Restructure source and resource files (#46) importantly, res is now res/res and css is now res/css --- src/discord/channel.hpp | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/discord/channel.hpp (limited to 'src/discord/channel.hpp') 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 +#include + +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 IsLocked; + + friend void from_json(const nlohmann::json &j, ThreadMetadataData &m); +}; + +struct ThreadMemberObject { + std::optional ThreadID; + std::optional UserID; + std::string JoinTimestamp; + int Flags; + + friend void from_json(const nlohmann::json &j, ThreadMemberObject &m); +}; + +struct ChannelData { + Snowflake ID; + ChannelType Type; + std::optional GuildID; + std::optional Position; + std::optional> PermissionOverwrites; // shouldnt be accessed + std::optional Name; // null for dm's + std::optional Topic; // null + std::optional IsNSFW; + std::optional LastMessageID; // null + std::optional Bitrate; + std::optional UserLimit; + std::optional RateLimitPerUser; + std::optional> Recipients; // only access id + std::optional> RecipientIDs; + std::optional Icon; // null + std::optional OwnerID; + std::optional ApplicationID; + std::optional ParentID; // null + std::optional LastPinTimestamp; // null + std::optional ThreadMetadata; + std::optional 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 GetOverwrite(Snowflake id) const; + std::vector GetDMRecipients() const; +}; -- cgit v1.2.3