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/guild.hpp | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/discord/guild.hpp (limited to 'src/discord/guild.hpp') diff --git a/src/discord/guild.hpp b/src/discord/guild.hpp new file mode 100644 index 0000000..3c3828d --- /dev/null +++ b/src/discord/guild.hpp @@ -0,0 +1,100 @@ +#pragma once +#include "json.hpp" +#include "snowflake.hpp" +#include "role.hpp" +#include "channel.hpp" +#include "emoji.hpp" +#include +#include +#include + +enum class GuildApplicationStatus { + STARTED, + PENDING, + REJECTED, + APPROVED, + UNKNOWN, +}; + +struct GuildApplicationData { + Snowflake UserID; + Snowflake GuildID; + GuildApplicationStatus ApplicationStatus; + std::optional RejectionReason; + std::optional LastSeen; + std::optional CreatedAt; + + friend void from_json(const nlohmann::json &j, GuildApplicationData &m); +}; + +// a bot is apparently only supposed to receive the `id` and `unavailable` as false +// but user tokens seem to get the full objects (minus users) + +// everythings optional cuz of muh partial guild object +// anything not marked optional in https://discord.com/developers/docs/resources/guild#guild-object is guaranteed to be set when returned from Store::GetGuild +struct GuildData { + Snowflake ID; + std::string Name; + std::string Icon; // null + std::string Splash; // null + std::optional DiscoverySplash; // null + std::optional IsOwner; + std::optional OwnerID; + std::optional Permissions; + std::optional PermissionsNew; + std::optional VoiceRegion; + std::optional AFKChannelID; // null + std::optional AFKTimeout; + std::optional IsEmbedEnabled; // deprecated + std::optional EmbedChannelID; // null, deprecated + std::optional VerificationLevel; + std::optional DefaultMessageNotifications; + std::optional ExplicitContentFilter; + std::optional> Roles; // only access id + std::optional> Emojis; // only access id + std::optional> Features; + std::optional MFALevel; + std::optional ApplicationID; // null + std::optional IsWidgetEnabled; + std::optional WidgetChannelID; // null + std::optional SystemChannelID; // null + std::optional SystemChannelFlags; + std::optional RulesChannelID; // null + std::optional JoinedAt; // * + std::optional IsLarge; // * + std::optional IsUnavailable; // * + std::optional MemberCount; // * + // std::vector VoiceStates; // opt* + // std::vector Members; // opt* - incomplete anyways + std::optional> Channels; // * + // std::vector Presences; // opt* + std::optional MaxPresences; // null + std::optional MaxMembers; + std::optional VanityURL; // null + std::optional Description; // null + std::optional BannerHash; // null + std::optional PremiumTier; + std::optional PremiumSubscriptionCount; + std::optional PreferredLocale; + std::optional PublicUpdatesChannelID; // null + std::optional MaxVideoChannelUsers; + std::optional ApproximateMemberCount; + std::optional ApproximatePresenceCount; + std::optional> Threads; // only with permissions to view, id only + + // undocumented + // std::map GuildHashes; + bool IsLazy = false; + + // * - documentation says only sent in GUILD_CREATE, but these can be sent anyways in the READY event + + friend void from_json(const nlohmann::json &j, GuildData &m); + void update_from_json(const nlohmann::json &j); + + bool HasFeature(const std::string &feature); + bool HasIcon() const; + bool HasAnimatedIcon() const; + std::string GetIconURL(std::string ext = "png", std::string size = "32") const; + std::vector GetSortedChannels(Snowflake ignore = Snowflake::Invalid) const; + std::vector FetchRoles() const; // sorted +}; -- cgit v1.2.3