mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Expose guild type.
Refactor constants to be more compile time efficient.
This commit is contained in:
parent
08a5ba3154
commit
e9f5111a33
@ -12,11 +12,12 @@ namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQMOD_DECL_TYPENAME(SqDppCachePolicy, _SC("SqDppCachePolicy"))
|
||||
SQMOD_DECL_TYPENAME(SqDppUptime, _SC("SqDppUptime"))
|
||||
SQMOD_DECL_TYPENAME(SqDppIconHash, _SC("SqDppIconHash"))
|
||||
SQMOD_DECL_TYPENAME(SqDppUptime, _SC("SqDppUptime"))
|
||||
SQMOD_DECL_TYPENAME(SqDppActivity, _SC("SqDppActivity"))
|
||||
SQMOD_DECL_TYPENAME(SqDppPresence, _SC("SqDppPresence"))
|
||||
SQMOD_DECL_TYPENAME(SqDppVoiceState, _SC("SqDppVoiceState"))
|
||||
SQMOD_DECL_TYPENAME(SqDppGuildMember, _SC("SqDppGuildMember"))
|
||||
SQMOD_DECL_TYPENAME(SqDppGuild, _SC("SqDppGuild"))
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -132,126 +133,315 @@ void Register_DPPTy(HSQUIRRELVM vm, Table & ns)
|
||||
.Func(_SC("_tojson"), &DpVoiceState::BuildJSON)
|
||||
// Member Properties
|
||||
.Prop(_SC("Valid"), &DpVoiceState::IsValid)
|
||||
.Prop(_SC("JSON"), &DpVoiceState::BuildJSON)
|
||||
.Prop(_SC("GuildID"), &DpVoiceState::GetGuildID)
|
||||
.Prop(_SC("ChannelID"), &DpVoiceState::GetChannelID)
|
||||
.Prop(_SC("UserID"), &DpVoiceState::GetUserID)
|
||||
.Prop(_SC("SessionID"), &DpVoiceState::GetSessionID)
|
||||
.Prop(_SC("Flags"), &DpVoiceState::GetFlags, &DpVoiceState::SetFlags)
|
||||
.Prop(_SC("JSON"), &DpVoiceState::BuildJSON)
|
||||
.Prop(_SC("Deaf"), &DpVoiceState::IsDeaf)
|
||||
.Prop(_SC("Mute"), &DpVoiceState::IsMute)
|
||||
.Prop(_SC("SelfMute"), &DpVoiceState::IsSelfMute)
|
||||
.Prop(_SC("SelfDeaf"), &DpVoiceState::IsSelfDeaf)
|
||||
.Prop(_SC("IsDeaf"), &DpVoiceState::IsDeaf)
|
||||
.Prop(_SC("IsMute"), &DpVoiceState::IsMute)
|
||||
.Prop(_SC("IsSelfMute"), &DpVoiceState::IsSelfMute)
|
||||
.Prop(_SC("IsSelfDeaf"), &DpVoiceState::IsSelfDeaf)
|
||||
.Prop(_SC("SelfStream"), &DpVoiceState::SelfStream)
|
||||
.Prop(_SC("SelfVideo"), &DpVoiceState::SelfVideo)
|
||||
.Prop(_SC("Supressed"), &DpVoiceState::IsSupressed)
|
||||
.Prop(_SC("IsSupressed"), &DpVoiceState::IsSupressed)
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ns.Bind(_SC("GuildMember"),
|
||||
Class< DpGuildMember, NoConstructor< DpGuildMember > >(vm, SqDppGuildMember::Str)
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqDppGuildMember::Fn)
|
||||
.Func(_SC("_tojson"), &DpGuildMember::BuildJSON)
|
||||
// Member Properties
|
||||
.Prop(_SC("Valid"), &DpGuildMember::IsValid)
|
||||
.Prop(_SC("JSON"), &DpGuildMember::BuildJSON)
|
||||
.Prop(_SC("Nickname"), &DpGuildMember::GetNickname)
|
||||
.Prop(_SC("GuildID"), &DpGuildMember::GetGuildID)
|
||||
.Prop(_SC("UserID"), &DpGuildMember::GetUserID)
|
||||
.Prop(_SC("JoinedAt"), &DpGuildMember::GetJoinedAt)
|
||||
.Prop(_SC("PremiumSince"), &DpGuildMember::GetPremiumSince)
|
||||
.Prop(_SC("Flags"), &DpGuildMember::GetFlags)
|
||||
.Prop(_SC("IsDeaf"), &DpGuildMember::IsDeaf)
|
||||
.Prop(_SC("IsMuted"), &DpGuildMember::IsMuted)
|
||||
.Prop(_SC("IsPending"), &DpGuildMember::IsPending)
|
||||
// Member Methods
|
||||
.Func(_SC("GetRoles"), &DpGuildMember::GetRoles)
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ns.Bind(_SC("Guild"),
|
||||
Class< DpGuild, NoConstructor< DpGuild > >(vm, SqDppGuild::Str)
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqDppGuild::Fn)
|
||||
.Func(_SC("_tojson"), &DpGuild::BuildJSON)
|
||||
// Member Properties
|
||||
.Prop(_SC("Valid"), &DpGuild::IsValid)
|
||||
.Prop(_SC("JSON"), &DpGuild::BuildJSON)
|
||||
.Prop(_SC("ShardID"), &DpGuild::GetShardID)
|
||||
.Prop(_SC("Flags"), &DpGuild::GetFlags)
|
||||
.Prop(_SC("Name"), &DpGuild::GetName)
|
||||
.Prop(_SC("Description"), &DpGuild::GetDescription)
|
||||
.Prop(_SC("VanityUrlCode"), &DpGuild::GetVanityUrlCode)
|
||||
.Prop(_SC("Icon"), &DpGuild::GetIcon)
|
||||
.Prop(_SC("Splash"), &DpGuild::GetSplash)
|
||||
.Prop(_SC("DiscoverySplash"), &DpGuild::GetDiscoverySplash)
|
||||
.Prop(_SC("OwnerID"), &DpGuild::GetOwnerID)
|
||||
.Prop(_SC("VoiceRegion"), &DpGuild::GetVoiceRegion)
|
||||
.Prop(_SC("AfkChannelID"), &DpGuild::GetAfkChannelID)
|
||||
.Prop(_SC("AfkTimeout"), &DpGuild::GetAfkTimeout)
|
||||
.Prop(_SC("WidgetChannelID"), &DpGuild::GetWidgetChannelID)
|
||||
.Prop(_SC("VerificationLevel"), &DpGuild::GetVerificationLevel)
|
||||
.Prop(_SC("DefaultMessageNotifications"), &DpGuild::GetDefaultMessageNotifications)
|
||||
.Prop(_SC("ExplicitContentFilter"), &DpGuild::GetExplicitContentFilter)
|
||||
.Prop(_SC("MfaLevel"), &DpGuild::GetMfaLevel)
|
||||
.Prop(_SC("ApplicationID"), &DpGuild::GetApplicationID)
|
||||
.Prop(_SC("SystemChannelID"), &DpGuild::GetSystemChannelID)
|
||||
.Prop(_SC("RulesChannelID"), &DpGuild::GetRulesChannelID)
|
||||
.Prop(_SC("MemberCount"), &DpGuild::GetMemberCount)
|
||||
.Prop(_SC("Banner"), &DpGuild::GetBanner)
|
||||
.Prop(_SC("PremiumTier"), &DpGuild::GetPremiumTier)
|
||||
.Prop(_SC("PremiumSubscriptionCount"), &DpGuild::GetPremiumSubscriptionCount)
|
||||
.Prop(_SC("PublicUpdatesChannelID"), &DpGuild::GetPublicUpdatesChannelID)
|
||||
.Prop(_SC("MaxVideoChannelUsers"), &DpGuild::GetMaxVideoChannelUsers)
|
||||
.Prop(_SC("IsLarge"), &DpGuild::IsLarge)
|
||||
.Prop(_SC("IsUnavailable"), &DpGuild::IsUnavailable)
|
||||
.Prop(_SC("WidgetEnabled"), &DpGuild::WidgetEnabled)
|
||||
.Prop(_SC("HasInviteSplash"), &DpGuild::HasInviteSplash)
|
||||
.Prop(_SC("HasVipRegions"), &DpGuild::HasVipRegions)
|
||||
.Prop(_SC("HasVanityURL"), &DpGuild::HasVanityURL)
|
||||
.Prop(_SC("IsVerified"), &DpGuild::IsVerified)
|
||||
.Prop(_SC("IsPartnered"), &DpGuild::IsPartnered)
|
||||
.Prop(_SC("IsCommunity"), &DpGuild::IsCommunity)
|
||||
.Prop(_SC("HasCommerce"), &DpGuild::HasCommerce)
|
||||
.Prop(_SC("HasNews"), &DpGuild::HasNews)
|
||||
.Prop(_SC("IsDiscoverable"), &DpGuild::IsDiscoverable)
|
||||
.Prop(_SC("IsFeatureable"), &DpGuild::IsFeatureable)
|
||||
.Prop(_SC("HasAnimatedIcon"), &DpGuild::HasAnimatedIcon)
|
||||
.Prop(_SC("BasBanner"), &DpGuild::BasBanner)
|
||||
.Prop(_SC("WelcomeScreenEnabled"), &DpGuild::WelcomeScreenEnabled)
|
||||
.Prop(_SC("HasMemberVerificationGate"), &DpGuild::HasMemberVerificationGate)
|
||||
.Prop(_SC("IsPreviewEnabled"), &DpGuild::IsPreviewEnabled)
|
||||
.Prop(_SC("HasAnimatedIconHash"), &DpGuild::HasAnimatedIconHash)
|
||||
// Member Methods
|
||||
.Func(_SC("BuildJSON"), &DpGuild::BuildJSON_)
|
||||
.Func(_SC("GetRoles"), &DpGuild::GetRoles)
|
||||
.Func(_SC("GetChannels"), &DpGuild::GetChannels)
|
||||
.Func(_SC("GetThreads"), &DpGuild::GetThreads)
|
||||
.Func(_SC("GetMembers"), &DpGuild::GetMembers)
|
||||
.Func(_SC("GetVoiceMembers"), &DpGuild::GetVoiceMembers)
|
||||
.Func(_SC("GetEmojis"), &DpGuild::GetEmojis)
|
||||
.Func(_SC("RehashMembers"), &DpGuild::RehashMembers)
|
||||
.Func(_SC("ConnectMemberVoice"), &DpGuild::ConnectMemberVoice)
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Register_DPPConst(HSQUIRRELVM vm, Table & ns)
|
||||
static const EnumElement g_DpLogLevelEnum[] = {
|
||||
{_SC("Trace"), static_cast< SQInteger >(dpp::ll_trace)},
|
||||
{_SC("Debug"), static_cast< SQInteger >(dpp::ll_debug)},
|
||||
{_SC("Info"), static_cast< SQInteger >(dpp::ll_info)},
|
||||
{_SC("Warning"), static_cast< SQInteger >(dpp::ll_warning)},
|
||||
{_SC("Error"), static_cast< SQInteger >(dpp::ll_error)},
|
||||
{_SC("Critical"), static_cast< SQInteger >(dpp::ll_critical)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpImageTypeEnum[] = {
|
||||
{_SC("PNG"), static_cast< SQInteger >(dpp::i_png)},
|
||||
{_SC("JPG"), static_cast< SQInteger >(dpp::i_jpg)},
|
||||
{_SC("GIF"), static_cast< SQInteger >(dpp::i_gif)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpCachePolicyEnum[] = {
|
||||
{_SC("Aggressive"), static_cast< SQInteger >(dpp::cp_aggressive)},
|
||||
{_SC("Lazy"), static_cast< SQInteger >(dpp::cp_lazy)},
|
||||
{_SC("None"), static_cast< SQInteger >(dpp::cp_none)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpClusterIntentsEnum[] = {
|
||||
{_SC("Guilds"), static_cast< SQInteger >(dpp::i_guilds)},
|
||||
{_SC("GuildMembers"), static_cast< SQInteger >(dpp::i_guild_members)},
|
||||
{_SC("GuildBans"), static_cast< SQInteger >(dpp::i_guild_bans)},
|
||||
{_SC("GuildEmojis"), static_cast< SQInteger >(dpp::i_guild_emojis)},
|
||||
{_SC("GuildIntegrations"), static_cast< SQInteger >(dpp::i_guild_integrations)},
|
||||
{_SC("GuildWebhooks"), static_cast< SQInteger >(dpp::i_guild_webhooks)},
|
||||
{_SC("GuildInvites"), static_cast< SQInteger >(dpp::i_guild_invites)},
|
||||
{_SC("GuildVoiceStates"), static_cast< SQInteger >(dpp::i_guild_voice_states)},
|
||||
{_SC("GuildPresences"), static_cast< SQInteger >(dpp::i_guild_presences)},
|
||||
{_SC("GuildMessages"), static_cast< SQInteger >(dpp::i_guild_messages)},
|
||||
{_SC("GuildMessageReactions"), static_cast< SQInteger >(dpp::i_guild_message_reactions)},
|
||||
{_SC("GuildMessageTyping"), static_cast< SQInteger >(dpp::i_guild_message_typing)},
|
||||
{_SC("DirectMessages"), static_cast< SQInteger >(dpp::i_direct_messages)},
|
||||
{_SC("DirectMessageReactions"), static_cast< SQInteger >(dpp::i_direct_message_reactions)},
|
||||
{_SC("DirectMessageTyping"), static_cast< SQInteger >(dpp::i_direct_message_typing)},
|
||||
{_SC("Default"), static_cast< SQInteger >(dpp::i_default_intents)},
|
||||
{_SC("Privileged"), static_cast< SQInteger >(dpp::i_privileged_intents)},
|
||||
{_SC("All"), static_cast< SQInteger >(dpp::i_all_intents)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpPresenceFlagsEnum[] = {
|
||||
{_SC("DesktopOnline"), static_cast< SQInteger >(dpp::p_desktop_online)},
|
||||
{_SC("DesktopDND"), static_cast< SQInteger >(dpp::p_desktop_dnd)},
|
||||
{_SC("DesktopIdle"), static_cast< SQInteger >(dpp::p_desktop_idle)},
|
||||
{_SC("WebWnline"), static_cast< SQInteger >(dpp::p_web_online)},
|
||||
{_SC("WebDND"), static_cast< SQInteger >(dpp::p_web_dnd)},
|
||||
{_SC("WebIdle"), static_cast< SQInteger >(dpp::p_web_idle)},
|
||||
{_SC("MobileOnline"), static_cast< SQInteger >(dpp::p_mobile_online)},
|
||||
{_SC("MobileDND"), static_cast< SQInteger >(dpp::p_mobile_dnd)},
|
||||
{_SC("MobileIdle"), static_cast< SQInteger >(dpp::p_mobile_idle)},
|
||||
{_SC("StatusOnline"), static_cast< SQInteger >(dpp::p_status_online)},
|
||||
{_SC("StatusDND"), static_cast< SQInteger >(dpp::p_status_dnd)},
|
||||
{_SC("StatusIdle"), static_cast< SQInteger >(dpp::p_status_idle)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpPresenceStatusEnum[] = {
|
||||
{_SC("Offline"), static_cast< SQInteger >(dpp::ps_offline)},
|
||||
{_SC("Online"), static_cast< SQInteger >(dpp::ps_online)},
|
||||
{_SC("DND"), static_cast< SQInteger >(dpp::ps_dnd)},
|
||||
{_SC("Idle"), static_cast< SQInteger >(dpp::ps_idle)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpDesktopStatusBitsEnum[] = {
|
||||
{_SC("ShiftDesktop"), static_cast< SQInteger >(PF_SHIFT_DESKTOP)},
|
||||
{_SC("ShiftWeb"), static_cast< SQInteger >(PF_SHIFT_WEB)},
|
||||
{_SC("ShiftMobile"), static_cast< SQInteger >(PF_SHIFT_MOBILE)},
|
||||
{_SC("ShiftMain"), static_cast< SQInteger >(PF_SHIFT_MAIN)},
|
||||
{_SC("StatusMask"), static_cast< SQInteger >(PF_STATUS_MASK)},
|
||||
{_SC("ClearDesktop"), static_cast< SQInteger >(PF_CLEAR_DESKTOP)},
|
||||
{_SC("ClearWeb"), static_cast< SQInteger >(PF_CLEAR_WEB)},
|
||||
{_SC("ClearMobile"), static_cast< SQInteger >(PF_CLEAR_MOBILE)},
|
||||
{_SC("ClearStatus"), static_cast< SQInteger >(PF_CLEAR_STATUS)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpActivityTypeEnum[] = {
|
||||
{_SC("Game"), static_cast< SQInteger >(dpp::at_game)},
|
||||
{_SC("Streaming"), static_cast< SQInteger >(dpp::at_streaming)},
|
||||
{_SC("Listening"), static_cast< SQInteger >(dpp::at_listening)},
|
||||
{_SC("Custom"), static_cast< SQInteger >(dpp::at_custom)},
|
||||
{_SC("Competing"), static_cast< SQInteger >(dpp::at_competing)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpActivityFlagsEnum[] = {
|
||||
{_SC("Instance"), static_cast< SQInteger >(dpp::af_instance)},
|
||||
{_SC("Join"), static_cast< SQInteger >(dpp::af_join)},
|
||||
{_SC("Spectate"), static_cast< SQInteger >(dpp::af_spectate)},
|
||||
{_SC("JoinRequest"), static_cast< SQInteger >(dpp::af_join_request)},
|
||||
{_SC("Sync"), static_cast< SQInteger >(dpp::af_sync)},
|
||||
{_SC("Play"), static_cast< SQInteger >(dpp::af_play)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpUserFlagsEnum[] = {
|
||||
{_SC("Bot"), static_cast< SQInteger >(dpp::u_bot)},
|
||||
{_SC("System"), static_cast< SQInteger >(dpp::u_system)},
|
||||
{_SC("MfaEnabled"), static_cast< SQInteger >(dpp::u_mfa_enabled)},
|
||||
{_SC("Verified"), static_cast< SQInteger >(dpp::u_verified)},
|
||||
{_SC("NitroFull"), static_cast< SQInteger >(dpp::u_nitro_full)},
|
||||
{_SC("NitroClassic"), static_cast< SQInteger >(dpp::u_nitro_classic)},
|
||||
{_SC("DiscordEmployee"), static_cast< SQInteger >(dpp::u_discord_employee)},
|
||||
{_SC("PartneredOwner"), static_cast< SQInteger >(dpp::u_partnered_owner)},
|
||||
{_SC("HypesquadEvents"), static_cast< SQInteger >(dpp::u_hypesquad_events)},
|
||||
{_SC("Bughunter1"), static_cast< SQInteger >(dpp::u_bughunter_1)},
|
||||
{_SC("HouseBravery"), static_cast< SQInteger >(dpp::u_house_bravery)},
|
||||
{_SC("HouseBrilliance"), static_cast< SQInteger >(dpp::u_house_brilliance)},
|
||||
{_SC("HouseBalanace"), static_cast< SQInteger >(dpp::u_house_balanace)},
|
||||
{_SC("EarlySupporter"), static_cast< SQInteger >(dpp::u_early_supporter)},
|
||||
{_SC("TeamUser"), static_cast< SQInteger >(dpp::u_team_user)},
|
||||
{_SC("Bughunter2"), static_cast< SQInteger >(dpp::u_bughunter_2)},
|
||||
{_SC("VerifiedBot"), static_cast< SQInteger >(dpp::u_verified_bot)},
|
||||
{_SC("VerifiedBotDev"), static_cast< SQInteger >(dpp::u_verified_bot_dev)},
|
||||
{_SC("AnimatedIcon"), static_cast< SQInteger >(dpp::u_animated_icon)},
|
||||
{_SC("CertifiedModerator"), static_cast< SQInteger >(dpp::u_certified_moderator)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpRegionEnum[] = {
|
||||
{_SC("Brazil"), static_cast< SQInteger >(dpp::r_brazil)},
|
||||
{_SC("CentralEurope"), static_cast< SQInteger >(dpp::r_central_europe)},
|
||||
{_SC("HongKong"), static_cast< SQInteger >(dpp::r_hong_kong)},
|
||||
{_SC("India"), static_cast< SQInteger >(dpp::r_india)},
|
||||
{_SC("Japan"), static_cast< SQInteger >(dpp::r_japan)},
|
||||
{_SC("Russia"), static_cast< SQInteger >(dpp::r_russia)},
|
||||
{_SC("Singapore"), static_cast< SQInteger >(dpp::r_singapore)},
|
||||
{_SC("SouthAfrica"), static_cast< SQInteger >(dpp::r_south_africa)},
|
||||
{_SC("Sydney"), static_cast< SQInteger >(dpp::r_sydney)},
|
||||
{_SC("UsCentral"), static_cast< SQInteger >(dpp::r_us_central)},
|
||||
{_SC("UsEast"), static_cast< SQInteger >(dpp::r_us_east)},
|
||||
{_SC("UsSouth"), static_cast< SQInteger >(dpp::r_us_south)},
|
||||
{_SC("UsWest"), static_cast< SQInteger >(dpp::r_us_west)},
|
||||
{_SC("WesternEurope"), static_cast< SQInteger >(dpp::r_western_europe)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpGuildFlagsEnum[] = {
|
||||
{_SC("Large"), static_cast< SQInteger >(dpp::g_large)},
|
||||
{_SC("Unavailable"), static_cast< SQInteger >(dpp::g_unavailable)},
|
||||
{_SC("WidgetEnabled"), static_cast< SQInteger >(dpp::g_widget_enabled)},
|
||||
{_SC("InviteSplash"), static_cast< SQInteger >(dpp::g_invite_splash)},
|
||||
{_SC("VipRegions"), static_cast< SQInteger >(dpp::g_vip_regions)},
|
||||
{_SC("VanityURL"), static_cast< SQInteger >(dpp::g_vanity_url)},
|
||||
{_SC("Verified"), static_cast< SQInteger >(dpp::g_verified)},
|
||||
{_SC("Partnered"), static_cast< SQInteger >(dpp::g_partnered)},
|
||||
{_SC("Community"), static_cast< SQInteger >(dpp::g_community)},
|
||||
{_SC("Commerce"), static_cast< SQInteger >(dpp::g_commerce)},
|
||||
{_SC("News"), static_cast< SQInteger >(dpp::g_news)},
|
||||
{_SC("Discoverable"), static_cast< SQInteger >(dpp::g_discoverable)},
|
||||
{_SC("Featureable"), static_cast< SQInteger >(dpp::g_featureable)},
|
||||
{_SC("AnimatedIcon"), static_cast< SQInteger >(dpp::g_animated_icon)},
|
||||
{_SC("Banner"), static_cast< SQInteger >(dpp::g_banner)},
|
||||
{_SC("WelcomeScreenEnabled"), static_cast< SQInteger >(dpp::g_welcome_screen_enabled)},
|
||||
{_SC("MemberVerificationGate"), static_cast< SQInteger >(dpp::g_member_verification_gate)},
|
||||
{_SC("PreviewEnabled"), static_cast< SQInteger >(dpp::g_preview_enabled)},
|
||||
{_SC("NoJoinNotifications"), static_cast< SQInteger >(dpp::g_no_join_notifications)},
|
||||
{_SC("NoBoostNotifications"), static_cast< SQInteger >(dpp::g_no_boost_notifications)},
|
||||
{_SC("HasAnimatedIcon"), static_cast< SQInteger >(dpp::g_has_animated_icon)}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpGuildMemberFlagsEnum[] = {
|
||||
{_SC("Deaf"), static_cast< SQInteger >(dpp::gm_deaf)},
|
||||
{_SC("Mute"), static_cast< SQInteger >(dpp::gm_mute)},
|
||||
{_SC("Pending"), static_cast< SQInteger >(dpp::gm_pending)}
|
||||
};
|
||||
/*
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpEnum[] = {
|
||||
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElement g_DpEnum[] = {
|
||||
|
||||
};
|
||||
*/
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static const EnumElements g_EnumList[] = {
|
||||
{_SC("SqDiscordLogLevel"), g_DpLogLevelEnum},
|
||||
{_SC("SqDiscordImageType"), g_DpImageTypeEnum},
|
||||
{_SC("SqDiscordCachePolicy"), g_DpCachePolicyEnum},
|
||||
{_SC("SqDiscordClusterIntents"), g_DpClusterIntentsEnum},
|
||||
{_SC("SqDiscordPresenceFlags"), g_DpPresenceFlagsEnum},
|
||||
{_SC("SqDiscordPresenceStatus"), g_DpPresenceStatusEnum},
|
||||
{_SC("SqDiscordDesktopStatusBits"), g_DpDesktopStatusBitsEnum},
|
||||
{_SC("SqDiscordActivityType"), g_DpActivityTypeEnum},
|
||||
{_SC("SqDiscordActivityFlags"), g_DpActivityFlagsEnum},
|
||||
{_SC("SqDiscordUserFlags"), g_DpUserFlagsEnum},
|
||||
{_SC("SqDiscordRegion"), g_DpRegionEnum},
|
||||
{_SC("SqDiscordGuildFlags"), g_DpGuildFlagsEnum},
|
||||
{_SC("SqDiscordGuildMemberFlags"), g_DpGuildMemberFlagsEnum}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Register_DPPConst(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordLogLevel"), Enumeration(vm)
|
||||
.Const(_SC("Trace"), static_cast< SQInteger >(dpp::ll_trace))
|
||||
.Const(_SC("Debug"), static_cast< SQInteger >(dpp::ll_debug))
|
||||
.Const(_SC("Info"), static_cast< SQInteger >(dpp::ll_info))
|
||||
.Const(_SC("Warning"), static_cast< SQInteger >(dpp::ll_warning))
|
||||
.Const(_SC("Error"), static_cast< SQInteger >(dpp::ll_error))
|
||||
.Const(_SC("Critical"), static_cast< SQInteger >(dpp::ll_critical))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordImageType"), Enumeration(vm)
|
||||
.Const(_SC("PNG"), static_cast< SQInteger >(dpp::i_png))
|
||||
.Const(_SC("JPG"), static_cast< SQInteger >(dpp::i_jpg))
|
||||
.Const(_SC("GIF"), static_cast< SQInteger >(dpp::i_gif))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordCachePolicy"), Enumeration(vm)
|
||||
.Const(_SC("Aggressive"), static_cast< SQInteger >(dpp::cp_aggressive))
|
||||
.Const(_SC("Lazy"), static_cast< SQInteger >(dpp::cp_lazy))
|
||||
.Const(_SC("None"), static_cast< SQInteger >(dpp::cp_none))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordClusterIntents"), Enumeration(vm)
|
||||
.Const(_SC("Guilds"), static_cast< SQInteger >(dpp::i_guilds))
|
||||
.Const(_SC("GuildMembers"), static_cast< SQInteger >(dpp::i_guild_members))
|
||||
.Const(_SC("GuildBans"), static_cast< SQInteger >(dpp::i_guild_bans))
|
||||
.Const(_SC("GuildEmojis"), static_cast< SQInteger >(dpp::i_guild_emojis))
|
||||
.Const(_SC("GuildIntegrations"), static_cast< SQInteger >(dpp::i_guild_integrations))
|
||||
.Const(_SC("GuildWebhooks"), static_cast< SQInteger >(dpp::i_guild_webhooks))
|
||||
.Const(_SC("GuildInvites"), static_cast< SQInteger >(dpp::i_guild_invites))
|
||||
.Const(_SC("GuildVoiceStates"), static_cast< SQInteger >(dpp::i_guild_voice_states))
|
||||
.Const(_SC("GuildPresences"), static_cast< SQInteger >(dpp::i_guild_presences))
|
||||
.Const(_SC("GuildMessages"), static_cast< SQInteger >(dpp::i_guild_messages))
|
||||
.Const(_SC("GuildMessageReactions"), static_cast< SQInteger >(dpp::i_guild_message_reactions))
|
||||
.Const(_SC("GuildMessageTyping"), static_cast< SQInteger >(dpp::i_guild_message_typing))
|
||||
.Const(_SC("DirectMessages"), static_cast< SQInteger >(dpp::i_direct_messages))
|
||||
.Const(_SC("DirectMessageReactions"), static_cast< SQInteger >(dpp::i_direct_message_reactions))
|
||||
.Const(_SC("DirectMessageTyping"), static_cast< SQInteger >(dpp::i_direct_message_typing))
|
||||
.Const(_SC("Default"), static_cast< SQInteger >(dpp::i_default_intents))
|
||||
.Const(_SC("Privileged"), static_cast< SQInteger >(dpp::i_privileged_intents))
|
||||
.Const(_SC("All"), static_cast< SQInteger >(dpp::i_all_intents))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordPresenceFlags"), Enumeration(vm)
|
||||
.Const(_SC("DesktopOnline"), static_cast< SQInteger >(dpp::p_desktop_online))
|
||||
.Const(_SC("DesktopDND"), static_cast< SQInteger >(dpp::p_desktop_dnd))
|
||||
.Const(_SC("DesktopIdle"), static_cast< SQInteger >(dpp::p_desktop_idle))
|
||||
.Const(_SC("WebWnline"), static_cast< SQInteger >(dpp::p_web_online))
|
||||
.Const(_SC("WebDND"), static_cast< SQInteger >(dpp::p_web_dnd))
|
||||
.Const(_SC("WebIdle"), static_cast< SQInteger >(dpp::p_web_idle))
|
||||
.Const(_SC("MobileOnline"), static_cast< SQInteger >(dpp::p_mobile_online))
|
||||
.Const(_SC("MobileDND"), static_cast< SQInteger >(dpp::p_mobile_dnd))
|
||||
.Const(_SC("MobileIdle"), static_cast< SQInteger >(dpp::p_mobile_idle))
|
||||
.Const(_SC("StatusOnline"), static_cast< SQInteger >(dpp::p_status_online))
|
||||
.Const(_SC("StatusDND"), static_cast< SQInteger >(dpp::p_status_dnd))
|
||||
.Const(_SC("StatusIdle"), static_cast< SQInteger >(dpp::p_status_idle))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordPresenceStatus"), Enumeration(vm)
|
||||
.Const(_SC("Offline"), static_cast< SQInteger >(dpp::ps_offline))
|
||||
.Const(_SC("Online"), static_cast< SQInteger >(dpp::ps_online))
|
||||
.Const(_SC("DND"), static_cast< SQInteger >(dpp::ps_dnd))
|
||||
.Const(_SC("Idle"), static_cast< SQInteger >(dpp::ps_idle))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordDesktopStatusBits"), Enumeration(vm)
|
||||
.Const(_SC("ShiftDesktop"), static_cast< SQInteger >(PF_SHIFT_DESKTOP))
|
||||
.Const(_SC("ShiftWeb"), static_cast< SQInteger >(PF_SHIFT_WEB))
|
||||
.Const(_SC("ShiftMobile"), static_cast< SQInteger >(PF_SHIFT_MOBILE))
|
||||
.Const(_SC("ShiftMain"), static_cast< SQInteger >(PF_SHIFT_MAIN))
|
||||
.Const(_SC("StatusMask"), static_cast< SQInteger >(PF_STATUS_MASK))
|
||||
.Const(_SC("ClearDesktop"), static_cast< SQInteger >(PF_CLEAR_DESKTOP))
|
||||
.Const(_SC("ClearWeb"), static_cast< SQInteger >(PF_CLEAR_WEB))
|
||||
.Const(_SC("ClearMobile"), static_cast< SQInteger >(PF_CLEAR_MOBILE))
|
||||
.Const(_SC("ClearStatus"), static_cast< SQInteger >(PF_CLEAR_STATUS))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordActivityType"), Enumeration(vm)
|
||||
.Const(_SC("Game"), static_cast< SQInteger >(dpp::at_game))
|
||||
.Const(_SC("Streaming"), static_cast< SQInteger >(dpp::at_streaming))
|
||||
.Const(_SC("Listening"), static_cast< SQInteger >(dpp::at_listening))
|
||||
.Const(_SC("Custom"), static_cast< SQInteger >(dpp::at_custom))
|
||||
.Const(_SC("Competing"), static_cast< SQInteger >(dpp::at_competing))
|
||||
);
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ConstTable(vm).Enum(_SC("SqDiscordActivityFlags"), Enumeration(vm)
|
||||
.Const(_SC("Instance"), static_cast< SQInteger >(dpp::af_instance))
|
||||
.Const(_SC("Join"), static_cast< SQInteger >(dpp::af_join))
|
||||
.Const(_SC("Spectate"), static_cast< SQInteger >(dpp::af_spectate))
|
||||
.Const(_SC("JoinRequest"), static_cast< SQInteger >(dpp::af_join_request))
|
||||
.Const(_SC("Sync"), static_cast< SQInteger >(dpp::af_sync))
|
||||
.Const(_SC("Play"), static_cast< SQInteger >(dpp::af_play))
|
||||
);
|
||||
RegisterEnumerations(vm, g_EnumList);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
@ -3,6 +3,9 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Core/Utility.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <chrono>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <dpp/dpp.h>
|
||||
|
||||
@ -468,35 +471,40 @@ struct DpVoiceState
|
||||
* Referenced voice state instance.
|
||||
*/
|
||||
Ptr mPtr{nullptr};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Whether the referenced pointer is owned.
|
||||
* Wether the referenced pointer is owned.
|
||||
*/
|
||||
bool mOwned{false};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
DpVoiceState() noexcept = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
explicit DpVoiceState(Ptr::pointer ptr, bool owned = false) noexcept
|
||||
: mPtr(ptr), mOwned(owned)
|
||||
{
|
||||
}
|
||||
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
explicit DpVoiceState(const Ptr::element_type & o) noexcept
|
||||
: DpVoiceState(new Ptr::element_type(o), true)
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
explicit DpVoiceState(Ptr::element_type && o) noexcept
|
||||
: DpVoiceState(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor (disabled).
|
||||
*/
|
||||
DpVoiceState(const DpVoiceState & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
DpVoiceState(DpVoiceState && o) noexcept = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
@ -505,19 +513,16 @@ struct DpVoiceState
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator (disabled).
|
||||
*/
|
||||
DpVoiceState & operator = (const DpVoiceState & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
DpVoiceState & operator = (DpVoiceState && o) noexcept
|
||||
{
|
||||
if (this != &o)
|
||||
{
|
||||
if (this != &o) {
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
// Transfer members values
|
||||
@ -526,93 +531,218 @@ struct DpVoiceState
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed handle.
|
||||
*/
|
||||
void Validate() const { if (!mPtr) STHROWF("Invalid discord voice state handle"); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed handle and retrieve a const reference to it.
|
||||
*/
|
||||
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check whether a valid instance is managed.
|
||||
* Check wether a valid instance is managed.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id this voice state is for (optional).
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id this voice state is for (optional).
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetChannelID() const { return Valid().channel_id; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id this voice state is for (optional).
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id this voice state is for (optional).
|
||||
*/
|
||||
SQMOD_NODISCARD const std::string & GetSessionID() const { return Valid().session_id; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id this voice state is for (optional).
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetFlags() const { return Valid().flags; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id this voice state is for (optional).
|
||||
*/
|
||||
void SetFlags(SQInteger flags) const { Valid().flags = flags; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id this voice state is for (optional).
|
||||
*/
|
||||
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if user is deafened.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsDeaf() const { return Valid().is_deaf(); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if user is muted.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsMute() const { return Valid().is_mute(); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if user muted themselves.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsSelfMute() const { return Valid().is_self_mute(); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if user deafened themselves.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsSelfDeaf() const { return Valid().is_self_deaf(); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if user is streamig.
|
||||
*/
|
||||
SQMOD_NODISCARD bool SelfStream() const { return Valid().self_stream(); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if user is in video.
|
||||
*/
|
||||
SQMOD_NODISCARD bool SelfVideo() const { return Valid().self_video(); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if user is surpressed.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsSupressed() const { return Valid().is_supressed(); }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Represents a guild on Discord (AKA a server).
|
||||
*/
|
||||
struct DpGuildMember
|
||||
{
|
||||
using Ptr = std::unique_ptr< dpp::guild_member >;
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Referenced guild member instance.
|
||||
*/
|
||||
Ptr mPtr{nullptr};
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Wether the referenced pointer is owned.
|
||||
*/
|
||||
bool mOwned{false};
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
DpGuildMember() noexcept = default;
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
explicit DpGuildMember(Ptr::pointer ptr, bool owned = false) noexcept
|
||||
: mPtr(ptr), mOwned(owned)
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
explicit DpGuildMember(const Ptr::element_type & o) noexcept
|
||||
: DpGuildMember(new Ptr::element_type(o), true)
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
explicit DpGuildMember(Ptr::element_type && o) noexcept
|
||||
: DpGuildMember(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor (disabled).
|
||||
*/
|
||||
DpGuildMember(const DpGuildMember & o) = delete;
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
DpGuildMember(DpGuildMember && o) noexcept = default;
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~DpGuildMember() noexcept
|
||||
{
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator (disabled).
|
||||
*/
|
||||
DpGuildMember & operator = (const DpGuildMember & o) = delete;
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
DpGuildMember & operator = (DpGuildMember && o) noexcept
|
||||
{
|
||||
if (this != &o) {
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
// Transfer members values
|
||||
mPtr = std::move(o.mPtr);
|
||||
mOwned = o.mOwned;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed handle.
|
||||
*/
|
||||
void Validate() const { if (!mPtr) STHROWF("Invalid discord voice state handle"); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed handle and retrieve a const reference to it.
|
||||
*/
|
||||
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check wether a valid instance is managed.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the gickname, or empty string if they don't have a nickname on this guild.
|
||||
*/
|
||||
SQMOD_NODISCARD const std::string & GetNickname() const { return Valid().nickname; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild id.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the user id.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the list of roles this user has on this guild.
|
||||
*/
|
||||
SQMOD_NODISCARD Array GetRoles() const
|
||||
{
|
||||
return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().roles.size()))
|
||||
.AppendFromVector(Valid().roles);
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the date and time since the user joined the guild.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetJoinedAt() const
|
||||
{
|
||||
return std::chrono::time_point_cast< std::chrono::seconds >(
|
||||
std::chrono::system_clock::from_time_t(Valid().joined_at)
|
||||
).time_since_epoch().count();
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the date and time since the user has boosted the guild guild.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetPremiumSince() const
|
||||
{
|
||||
return std::chrono::time_point_cast< std::chrono::seconds >(
|
||||
std::chrono::system_clock::from_time_t(Valid().premium_since)
|
||||
).time_since_epoch().count();
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the set of flags built from the bitmask defined by dpp::guild_member_flags.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Build JSON string for the member object.
|
||||
*/
|
||||
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check wether the user is deafened.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsDeaf() const { return Valid().is_deaf(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check wether the user is muted.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsMuted() const { return Valid().is_muted(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check wether the user is pending verification by membership screening.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsPending() const { return Valid().is_pending(); }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Represents a guild on Discord (AKA a server)
|
||||
*/
|
||||
@ -623,35 +753,40 @@ struct DpGuild
|
||||
* Referenced voice state instance.
|
||||
*/
|
||||
Ptr mPtr{nullptr};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Whether the referenced pointer is owned.
|
||||
* Wether the referenced pointer is owned.
|
||||
*/
|
||||
bool mOwned{false};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
DpGuild() noexcept = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
explicit DpGuild(Ptr::pointer ptr, bool owned = false) noexcept
|
||||
: mPtr(ptr), mOwned(owned)
|
||||
{
|
||||
}
|
||||
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
*/
|
||||
explicit DpGuild(const Ptr::element_type & o) noexcept
|
||||
: DpGuild(new Ptr::element_type(o), true)
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
explicit DpGuild(Ptr::element_type && o) noexcept
|
||||
: DpGuild(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||
{ }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor (disabled).
|
||||
*/
|
||||
DpGuild(const DpGuild & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
DpGuild(DpGuild && o) noexcept = default;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
@ -660,19 +795,16 @@ struct DpGuild
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator (disabled).
|
||||
*/
|
||||
DpGuild & operator = (const DpGuild & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
DpGuild & operator = (DpGuild && o) noexcept
|
||||
{
|
||||
if (this != &o)
|
||||
{
|
||||
if (this != &o) {
|
||||
// Do we own this to try delete it?
|
||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||
// Transfer members values
|
||||
@ -681,22 +813,279 @@ struct DpGuild
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed handle.
|
||||
*/
|
||||
void Validate() const { if (!mPtr) STHROWF("Invalid discord guild handle"); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Validate the managed handle and retrieve a const reference to it.
|
||||
*/
|
||||
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check whether a valid instance is managed.
|
||||
* Check wether a valid instance is managed.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the shard ID of the guild.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetShardID() const { return static_cast< SQInteger >(Valid().shard_id); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the flags bitmask as defined by values within dpp::guild_flags.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild name.
|
||||
*/
|
||||
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the server description for communities.
|
||||
*/
|
||||
SQMOD_NODISCARD const std::string & GetDescription() const { return Valid().description; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the vanity url code for verified or partnered servers and boost level 3.
|
||||
*/
|
||||
SQMOD_NODISCARD const std::string & GetVanityUrlCode() const { return Valid().vanity_url_code; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild icon hash.
|
||||
*/
|
||||
SQMOD_NODISCARD const dpp::utility::iconhash & GetIcon() const { return Valid().icon; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild splash hash.
|
||||
*/
|
||||
SQMOD_NODISCARD const dpp::utility::iconhash & GetSplash() const { return Valid().splash; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild discovery splash hash.
|
||||
*/
|
||||
SQMOD_NODISCARD const dpp::utility::iconhash & GetDiscoverySplash() const { return Valid().discovery_splash; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the snowflake id of guild owner.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetOwnerID() const { return Valid().owner_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the guild voice region.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetVoiceRegion() const { return static_cast< SQInteger >(Valid().voice_region); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the snowflake ID of AFK voice channel or 0.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetAfkChannelID() const { return Valid().afk_channel_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the voice AFK timeout before moving users to AFK channel.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetAfkTimeout() const { return static_cast< SQInteger >(Valid().afk_timeout); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the snowflake ID of widget channel, or 0.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetWidgetChannelID() const { return Valid().widget_channel_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the verification level of server.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetVerificationLevel() const { return static_cast< SQInteger >(Valid().verification_level); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the setting for how notifications are to be delivered to users.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetDefaultMessageNotifications() const { return static_cast< SQInteger >(Valid().default_message_notifications); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check wether or not explicit content filtering is enable and what setting it is.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetExplicitContentFilter() const { return static_cast< SQInteger >(Valid().explicit_content_filter); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check wether multi factor authentication is required for moderators or not.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetMfaLevel() const { return static_cast< SQInteger >(Valid().mfa_level); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the ID of creating application, if any, or 0.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetApplicationID() const { return Valid().application_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the ID of system channel where discord update messages are sent.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetSystemChannelID() const { return Valid().system_channel_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the ID of rules channel for communities.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetRulesChannelID() const { return Valid().rules_channel_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the approximate member count. May be sent as zero.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetMemberCount() const { return static_cast< SQInteger >(Valid().member_count); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the server banner hash.
|
||||
*/
|
||||
SQMOD_NODISCARD const dpp::utility::iconhash & GetBanner() const { return Valid().banner; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the boost level.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetPremiumTier() const { return static_cast< SQInteger >(Valid().premium_tier); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the number of boosters.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetPremiumSubscriptionCount() const { return static_cast< SQInteger >(Valid().premium_subscription_count); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve public updates channel ID or 0.
|
||||
*/
|
||||
SQMOD_NODISCARD dpp::snowflake GetPublicUpdatesChannelID() const { return Valid().public_updates_channel_id; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the maximum users in a video channel, or 0.
|
||||
*/
|
||||
SQMOD_NODISCARD SQInteger GetMaxVideoChannelUsers() const { return static_cast< SQInteger >(Valid().max_video_channel_users); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a roles defined on this server.
|
||||
*/
|
||||
SQMOD_NODISCARD Array GetRoles() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().roles.size())).AppendFromVector(Valid().roles); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a list of channels on this server.
|
||||
*/
|
||||
SQMOD_NODISCARD Array GetChannels() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().channels.size())).AppendFromVector(Valid().channels); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a list of threads on this server.
|
||||
*/
|
||||
SQMOD_NODISCARD Array GetThreads() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().threads.size())).AppendFromVector(Valid().threads); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a list of guild members. Note that when you first receive the guild create event,
|
||||
* this may be empty or near empty. This depends upon your dpp::intents and the size of your bot.
|
||||
* It will be filled by guild member chunk requests.
|
||||
*/
|
||||
SQMOD_NODISCARD Table GetMembers() const
|
||||
{
|
||||
Table t(SqVM(), static_cast< SQInteger >(Valid().members.size()));
|
||||
// Attempt to convert the [members] associative container into a script table
|
||||
const auto r = t.InsertFromMapWith(mPtr->members, [](HSQUIRRELVM vm, auto id, auto & m) -> SQRESULT {
|
||||
// The [id] is a dpp::snowflake which is basically a uint64_t so let's leave that as is
|
||||
sq_pushinteger(vm, static_cast< SQInteger >(id));
|
||||
// Wrap the dpp::guild_member type into a DpGuildMember instance
|
||||
ClassType< DpGuildMember >::PushInstance(vm, new DpGuildMember(m));
|
||||
// The elements are now on the stack and can be inserted in the table
|
||||
return SQ_OK;
|
||||
});
|
||||
// Did anything fail?
|
||||
if (SQ_FAILED(r))
|
||||
{
|
||||
STHROWF("Unable to convert [members] container");
|
||||
}
|
||||
// Return the resulted table
|
||||
return t;
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a list of members in voice channels in the guild.
|
||||
*/
|
||||
SQMOD_NODISCARD Table GetVoiceMembers() const
|
||||
{
|
||||
Table t(SqVM(), static_cast< SQInteger >(Valid().voice_members.size()));
|
||||
// Attempt to convert the [voice_members] associative container into a script table
|
||||
const auto r = t.InsertFromMapWith(mPtr->voice_members, [](HSQUIRRELVM vm, auto id, auto & m) -> SQRESULT {
|
||||
// The [id] is a dpp::snowflake which is basically a uint64_t so let's leave that as is
|
||||
sq_pushinteger(vm, static_cast< SQInteger >(id));
|
||||
// Wrap the dpp::guild_member type into a DpGuildMember instance
|
||||
ClassType< DpVoiceState >::PushInstance(vm, new DpVoiceState(m));
|
||||
// The elements are now on the stack and can be inserted in the table
|
||||
return SQ_OK;
|
||||
});
|
||||
// Did anything fail?
|
||||
if (SQ_FAILED(r))
|
||||
{
|
||||
STHROWF("Unable to convert [voice_members] container");
|
||||
}
|
||||
// Return the resulted table
|
||||
return t;
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve a list of emojis.
|
||||
*/
|
||||
SQMOD_NODISCARD Array GetEmojis() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().emojis.size())).AppendFromVector(Valid().emojis); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Build a JSON string from this object.
|
||||
*/
|
||||
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Build a JSON string from this object. If [with_id] is True then ID is to be included in the JSON.
|
||||
*/
|
||||
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Rehash members map.
|
||||
*/
|
||||
SQMOD_NODISCARD DpGuild & RehashMembers() { Valid().rehash_members(); return *this; }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Connect to a voice channel another guild member is in.
|
||||
* Returns true if the user specified is in a voice channel, false if they aren't.
|
||||
*/
|
||||
SQMOD_NODISCARD bool ConnectMemberVoice(SQInteger user_id) { return Valid().connect_member_voice(user_id); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Is a large server (>250 users).
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsLarge() { return Valid().is_large(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Is unavailable due to outage (most other fields will be blank or outdated).
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsUnavailable() { return Valid().is_unavailable(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Widget is enabled for this server.
|
||||
*/
|
||||
SQMOD_NODISCARD bool WidgetEnabled() { return Valid().widget_enabled(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has an invite splash.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasInviteSplash() { return Valid().has_invite_splash(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has VIP regions.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasVipRegions() { return Valid().has_vip_regions(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild can have a vanity URL.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasVanityURL() { return Valid().has_vanity_url(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild is a verified server.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsVerified() { return Valid().is_verified(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild is a discord partner server.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsPartnered() { return Valid().is_partnered(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has enabled community.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsCommunity() { return Valid().is_community(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has enabled commerce channels.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasCommerce() { return Valid().has_commerce(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has news channel.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasNews() { return Valid().has_news(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild is discoverable.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsDiscoverable() { return Valid().is_discoverable(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild is featureable.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsFeatureable() { return Valid().is_featureable(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild is allowed an animated icon.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasAnimatedIcon() { return Valid().has_animated_icon(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has a banner image.
|
||||
*/
|
||||
SQMOD_NODISCARD bool BasBanner() { return Valid().has_banner(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has enabled welcome screen.
|
||||
*/
|
||||
SQMOD_NODISCARD bool WelcomeScreenEnabled() { return Valid().is_welcome_screen_enabled(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has enabled membership screening.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasMemberVerificationGate() { return Valid().has_member_verification_gate(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Guild has preview enabled.
|
||||
*/
|
||||
SQMOD_NODISCARD bool IsPreviewEnabled() { return Valid().is_preview_enabled(); }
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Server icon is actually an animated gif.
|
||||
*/
|
||||
SQMOD_NODISCARD bool HasAnimatedIconHash() { return Valid().has_animated_icon_hash(); }
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
Loading…
Reference in New Issue
Block a user