mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Restructure discord API files.
This commit is contained in:
parent
17875509c0
commit
13fc02e9ca
@ -136,7 +136,21 @@ target_link_libraries(SqModule Squirrel fmt::fmt SimpleINI TinyDir xxHash Concur
|
|||||||
if(ENABLE_DISCORD)
|
if(ENABLE_DISCORD)
|
||||||
target_link_libraries(SqModule DPP)
|
target_link_libraries(SqModule DPP)
|
||||||
target_compile_definitions(SqModule PRIVATE VCMP_ENABLE_DISCORD=1)
|
target_compile_definitions(SqModule PRIVATE VCMP_ENABLE_DISCORD=1)
|
||||||
target_sources(SqModule PRIVATE Library/DPP.cpp Library/DPP.hpp Library/DPPEv.cpp Library/DPPEv.hpp Library/DPPTy.cpp Library/DPPTy.hpp)
|
target_sources(SqModule PRIVATE
|
||||||
|
Library/DPP.cpp Library/DPP.hpp
|
||||||
|
Library/DPP/Channel.cpp Library/DPP/Channel.hpp
|
||||||
|
Library/DPP/Client.cpp Library/DPP/Client.hpp
|
||||||
|
Library/DPP/Cluster.cpp Library/DPP/Cluster.hpp
|
||||||
|
Library/DPP/Command.cpp Library/DPP/Command.hpp
|
||||||
|
Library/DPP/Constants.cpp Library/DPP/Constants.hpp
|
||||||
|
Library/DPP/Events.cpp Library/DPP/Events.hpp
|
||||||
|
Library/DPP/Guild.cpp Library/DPP/Guild.hpp
|
||||||
|
Library/DPP/Integration.cpp Library/DPP/Integration.hpp
|
||||||
|
Library/DPP/Message.cpp Library/DPP/Message.hpp
|
||||||
|
Library/DPP/Other.cpp Library/DPP/Other.hpp
|
||||||
|
Library/DPP/Role.cpp Library/DPP/Role.hpp
|
||||||
|
Library/DPP/User.cpp Library/DPP/User.hpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
# Link to POCO libraries
|
# Link to POCO libraries
|
||||||
target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net Poco::JSON Poco::XML)
|
target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net Poco::JSON Poco::XML)
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/DPP.hpp"
|
#include "Library/DPP.hpp"
|
||||||
#include "Core/Signal.hpp"
|
#include "Library/DPP/Cluster.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <sqratConst.h>
|
#include <sqratConst.h>
|
||||||
@ -11,9 +8,6 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQMOD_DECL_TYPENAME(SqDppCluster, _SC("SqDppCluster"))
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void TerminateDPP()
|
void TerminateDPP()
|
||||||
{
|
{
|
||||||
@ -35,766 +29,44 @@ void ProcessDPP()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void Register_DPPTy(HSQUIRRELVM vm, Table & ns);
|
extern void Register_DPP_Channel(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_DPPEv(HSQUIRRELVM vm, Table & ns);
|
extern void Register_DPP_Client(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Cluster(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Command(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Constants(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Events(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Guild(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Integration(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Message(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Other(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Role(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_User(HSQUIRRELVM vm, Table & ns);
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_DPP(HSQUIRRELVM vm)
|
void Register_DPP(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
Table ns(vm);
|
Table ns(vm);
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_DPP_Constants(vm, ns);
|
||||||
|
Register_DPP_Client(vm, ns);
|
||||||
|
Register_DPP_Integration(vm, ns);
|
||||||
|
Register_DPP_Command(vm, ns);
|
||||||
|
Register_DPP_Message(vm, ns);
|
||||||
|
Register_DPP_Channel(vm, ns);
|
||||||
|
Register_DPP_Other(vm, ns);
|
||||||
|
Register_DPP_Role(vm, ns);
|
||||||
|
Register_DPP_User(vm, ns);
|
||||||
|
Register_DPP_Guild(vm, ns);
|
||||||
{
|
{
|
||||||
Table ens(vm);
|
Table ens(vm);
|
||||||
Register_DPPEv(vm, ens);
|
Register_DPP_Events(vm, ens);
|
||||||
ns.Bind(_SC("Events"), ens);
|
ns.Bind(_SC("Events"), ens);
|
||||||
}
|
}
|
||||||
// Register base types
|
Register_DPP_Cluster(vm, ns);
|
||||||
Register_DPPTy(vm, ns);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ns.Bind(_SC("Cluster"),
|
|
||||||
Class< DpCluster, NoCopy< DpCluster > >(vm, SqDppCluster::Str)
|
|
||||||
// Constructors
|
|
||||||
.Ctor< StackStrF & >()
|
|
||||||
.Ctor< StackStrF &, SQInteger >()
|
|
||||||
.Ctor< StackStrF &, SQInteger, SQInteger >()
|
|
||||||
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger >()
|
|
||||||
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger >()
|
|
||||||
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger, bool >()
|
|
||||||
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger, bool, const DpCachePolicy & >()
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppCluster::Fn)
|
|
||||||
// Member Properties
|
|
||||||
.Prop(_SC("On"), &DpCluster::GetEvents)
|
|
||||||
.Prop(_SC("UpTime"), &DpCluster::UpTime)
|
|
||||||
// Member Methods
|
|
||||||
.Func(_SC("Start"), &DpCluster::Start)
|
|
||||||
.Func(_SC("Log"), &DpCluster::Log)
|
|
||||||
.Func(_SC("GetDmChannel"), &DpCluster::GetDmChannel)
|
|
||||||
.Func(_SC("SetDmChannel"), &DpCluster::SetDmChannel)
|
|
||||||
.Func(_SC("SetPresence"), &DpCluster::SetPresence)
|
|
||||||
.Func(_SC("EnableEvent"), &DpCluster::EnableEvent)
|
|
||||||
.Func(_SC("DisableEvent"), &DpCluster::DisableEvent)
|
|
||||||
);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
ns.Func(_SC("HasVoice"), dpp::utility::has_voice);
|
ns.Func(_SC("HasVoice"), dpp::utility::has_voice);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
RootTable(vm).Bind(_SC("SqDiscord"), ns);
|
RootTable(vm).Bind(_SC("SqDiscord"), ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQMOD_NODISCARD LightObj EventToScriptObject(uint8_t type, uintptr_t data);
|
|
||||||
void EventInvokeCleanup(uint8_t type, uintptr_t data);
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::Process(bool force)
|
|
||||||
{
|
|
||||||
// Is there a valid connection?
|
|
||||||
if (!mC && !force)
|
|
||||||
{
|
|
||||||
return; // No point in going forward
|
|
||||||
}
|
|
||||||
DpInternalEvent event;
|
|
||||||
// Retrieve each event individually and process it
|
|
||||||
for (size_t count = mQueue.size_approx(), n = 0; n <= count; ++n)
|
|
||||||
{
|
|
||||||
// Try to get an event from the queue
|
|
||||||
if (mQueue.try_dequeue(event))
|
|
||||||
{
|
|
||||||
// Fetch the type of event
|
|
||||||
const auto type = event.GetType();
|
|
||||||
// Fetch the event itself
|
|
||||||
const auto data = event.GetData();
|
|
||||||
// Is this a valid event and is anyone listening to it?
|
|
||||||
if (event.mData == 0 || mEvents[type].first == nullptr || mEvents[type].first->IsEmpty())
|
|
||||||
{
|
|
||||||
continue; // Move on
|
|
||||||
}
|
|
||||||
// Transform the event instance into a script object
|
|
||||||
LightObj obj = EventToScriptObject(type, data);
|
|
||||||
// Allow the script to take ownership of the event instance now
|
|
||||||
event.Reset();
|
|
||||||
// Forward the call to the associated signal
|
|
||||||
(*mEvents[type].first)(obj);
|
|
||||||
// Allow the event instance to clean itself
|
|
||||||
EventInvokeCleanup(type, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================================================================
|
|
||||||
* Event handlers.
|
|
||||||
*/
|
|
||||||
void DpCluster::OnVoiceStateUpdate(const dpp::voice_state_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceStateUpdate, new DpVoiceStateUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnLog(const dpp::log_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::Log, new DpLogEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildJoinRequestDelete(const dpp::guild_join_request_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildJoinRequestDelete, new DpGuildJoinRequestDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnInteractionCreate(const dpp::interaction_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::InteractionCreate, new DpInteractionCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnButtonClick(const dpp::button_click_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ButtonClick, new DpButtonClickEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnSelectClick(const dpp::select_click_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::SelectClick, new DpSelectClickEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildDelete(const dpp::guild_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildDelete, new DpGuildDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnChannelDelete(const dpp::channel_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelDelete, new DpChannelDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnChannelUpdate(const dpp::channel_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelUpdate, new DpChannelUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnReady(const dpp::ready_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::Ready, new DpReadyEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageDelete(const dpp::message_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageDelete, new DpMessageDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnApplicationCommandDelete(const dpp::application_command_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandDelete, new DpApplicationCommandDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildMemberRemove(const dpp::guild_member_remove_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberRemove, new DpGuildMemberRemoveEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnApplicationCommandCreate(const dpp::application_command_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandCreate, new DpApplicationCommandCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnResumed(const dpp::resumed_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::Resumed, new DpResumedEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildRoleCreate(const dpp::guild_role_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleCreate, new DpGuildRoleCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnTypingStart(const dpp::typing_start_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::TypingStart, new DpTypingStartEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageReactionAdd(const dpp::message_reaction_add_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionAdd, new DpMessageReactionAddEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildMembersChunk(const dpp::guild_members_chunk_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMembersChunk, new DpGuildMembersChunkEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageReactionRemove(const dpp::message_reaction_remove_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemove, new DpMessageReactionRemoveEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildCreate(const dpp::guild_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildCreate, new DpGuildCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnChannelCreate(const dpp::channel_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelCreate, new DpChannelCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageReactionRemoveEmoji(const dpp::message_reaction_remove_emoji_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemoveEmoji, new DpMessageReactionRemoveEmojiEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageDeleteBulk(const dpp::message_delete_bulk_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageDeleteBulk, new DpMessageDeleteBulkEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildRoleUpdate(const dpp::guild_role_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleUpdate, new DpGuildRoleUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildRoleDelete(const dpp::guild_role_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleDelete, new DpGuildRoleDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnChannelPinsUpdate(const dpp::channel_pins_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelPinsUpdate, new DpChannelPinsUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageReactionRemoveAll(const dpp::message_reaction_remove_all_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemoveAll, new DpMessageReactionRemoveAllEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnVoiceServerUpdate(const dpp::voice_server_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceServerUpdate, new DpVoiceServerUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildEmojisUpdate(const dpp::guild_emojis_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildEmojisUpdate, new DpGuildEmojisUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildStickersUpdate(const dpp::guild_stickers_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildStickersUpdate, new DpGuildStickersUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnPresenceUpdate(const dpp::presence_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::PresenceUpdate, new DpPresenceUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnWebhooksUpdate(const dpp::webhooks_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::WebhooksUpdate, new DpWebhooksUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildMemberAdd(const dpp::guild_member_add_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberAdd, new DpGuildMemberAddEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnInviteDelete(const dpp::invite_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::InviteDelete, new DpInviteDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildUpdate(const dpp::guild_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildUpdate, new DpGuildUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildIntegrationsUpdate(const dpp::guild_integrations_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildIntegrationsUpdate, new DpGuildIntegrationsUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildMemberUpdate(const dpp::guild_member_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberUpdate, new DpGuildMemberUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnApplicationCommandUpdate(const dpp::application_command_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandUpdate, new DpApplicationCommandUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnInviteCreate(const dpp::invite_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::InviteCreate, new DpInviteCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageUpdate(const dpp::message_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageUpdate, new DpMessageUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnUserUpdate(const dpp::user_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::UserUpdate, new DpUserUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnMessageCreate(const dpp::message_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::MessageCreate, new DpMessageCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildBanAdd(const dpp::guild_ban_add_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildBanAdd, new DpGuildBanAddEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnGuildBanRemove(const dpp::guild_ban_remove_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::GuildBanRemove, new DpGuildBanRemoveEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnIntegrationCreate(const dpp::integration_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationCreate, new DpIntegrationCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnIntegrationUpdate(const dpp::integration_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationUpdate, new DpIntegrationUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnIntegrationDelete(const dpp::integration_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationDelete, new DpIntegrationDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnThreadCreate(const dpp::thread_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadCreate, new DpThreadCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnThreadUpdate(const dpp::thread_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadUpdate, new DpThreadUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnThreadDelete(const dpp::thread_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadDelete, new DpThreadDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnThreadListSync(const dpp::thread_list_sync_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadListSync, new DpThreadListSyncEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnThreadMemberUpdate(const dpp::thread_member_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadMemberUpdate, new DpThreadMemberUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnThreadMembersUpdate(const dpp::thread_members_update_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadMembersUpdate, new DpThreadMembersUpdateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnVoiceBufferSend(const dpp::voice_buffer_send_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceBufferSend, new DpVoiceBufferSendEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnVoiceUserTalking(const dpp::voice_user_talking_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceUserTalking, new DpVoiceUserTalkingEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnVoiceReady(const dpp::voice_ready_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceReady, new DpVoiceReadyEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnVoiceReceive(const dpp::voice_receive_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceReceive, new DpVoiceReceiveEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnVoiceTrackMarker(const dpp::voice_track_marker_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceTrackMarker, new DpVoiceTrackMarkerEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnStageInstanceCreate(const dpp::stage_instance_create_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::StageInstanceCreate, new DpStageInstanceCreateEvent(ev)));
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpCluster::OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev)
|
|
||||||
{
|
|
||||||
mQueue.enqueue(DpInternalEvent(DpEventID::StageInstanceDelete, new DpStageInstanceDeleteEvent(ev)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
DpCluster & DpCluster::EnableEvent(SQInteger id)
|
|
||||||
{
|
|
||||||
switch (id)
|
|
||||||
{
|
|
||||||
case DpEventID::VoiceStateUpdate: mC->on_voice_state_update([this](auto && e) { OnVoiceStateUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::Log: mC->on_log([this](auto && e) { OnLog(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildJoinRequestDelete: mC->on_guild_join_request_delete([this](auto && e) { OnGuildJoinRequestDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::InteractionCreate: mC->on_interaction_create([this](auto && e) { OnInteractionCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ButtonClick: mC->on_button_click([this](auto && e) { OnButtonClick(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::SelectClick: mC->on_select_click([this](auto && e) { OnSelectClick(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildDelete: mC->on_guild_delete([this](auto && e) { OnGuildDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ChannelDelete: mC->on_channel_delete([this](auto && e) { OnChannelDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ChannelUpdate: mC->on_channel_update([this](auto && e) { OnChannelUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::Ready: mC->on_ready([this](auto && e) { OnReady(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageDelete: mC->on_message_delete([this](auto && e) { OnMessageDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ApplicationCommandDelete: mC->on_application_command_delete([this](auto && e) { OnApplicationCommandDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildMemberRemove: mC->on_guild_member_remove([this](auto && e) { OnGuildMemberRemove(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ApplicationCommandCreate: mC->on_application_command_create([this](auto && e) { OnApplicationCommandCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::Resumed: mC->on_resumed([this](auto && e) { OnResumed(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildRoleCreate: mC->on_guild_role_create([this](auto && e) { OnGuildRoleCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::TypingStart: mC->on_typing_start([this](auto && e) { OnTypingStart(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageReactionAdd: mC->on_message_reaction_add([this](auto && e) { OnMessageReactionAdd(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildMembersChunk: mC->on_guild_members_chunk([this](auto && e) { OnGuildMembersChunk(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageReactionRemove: mC->on_message_reaction_remove([this](auto && e) { OnMessageReactionRemove(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildCreate: mC->on_guild_create([this](auto && e) { OnGuildCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ChannelCreate: mC->on_channel_create([this](auto && e) { OnChannelCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageReactionRemoveEmoji: mC->on_message_reaction_remove_emoji([this](auto && e) { OnMessageReactionRemoveEmoji(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageDeleteBulk: mC->on_message_delete_bulk([this](auto && e) { OnMessageDeleteBulk(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildRoleUpdate: mC->on_guild_role_update([this](auto && e) { OnGuildRoleUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildRoleDelete: mC->on_guild_role_delete([this](auto && e) { OnGuildRoleDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ChannelPinsUpdate: mC->on_channel_pins_update([this](auto && e) { OnChannelPinsUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageReactionRemoveAll: mC->on_message_reaction_remove_all([this](auto && e) { OnMessageReactionRemoveAll(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::VoiceServerUpdate: mC->on_voice_server_update([this](auto && e) { OnVoiceServerUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildEmojisUpdate: mC->on_guild_emojis_update([this](auto && e) { OnGuildEmojisUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildStickersUpdate: mC->on_guild_stickers_update([this](auto && e) { OnGuildStickersUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::PresenceUpdate: mC->on_presence_update([this](auto && e) { OnPresenceUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::WebhooksUpdate: mC->on_webhooks_update([this](auto && e) { OnWebhooksUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildMemberAdd: mC->on_guild_member_add([this](auto && e) { OnGuildMemberAdd(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::InviteDelete: mC->on_invite_delete([this](auto && e) { OnInviteDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildUpdate: mC->on_guild_update([this](auto && e) { OnGuildUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildIntegrationsUpdate: mC->on_guild_integrations_update([this](auto && e) { OnGuildIntegrationsUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildMemberUpdate: mC->on_guild_member_update([this](auto && e) { OnGuildMemberUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ApplicationCommandUpdate: mC->on_application_command_update([this](auto && e) { OnApplicationCommandUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::InviteCreate: mC->on_invite_create([this](auto && e) { OnInviteCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageUpdate: mC->on_message_update([this](auto && e) { OnMessageUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::UserUpdate: mC->on_user_update([this](auto && e) { OnUserUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::MessageCreate: mC->on_message_create([this](auto && e) { OnMessageCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildBanAdd: mC->on_guild_ban_add([this](auto && e) { OnGuildBanAdd(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::GuildBanRemove: mC->on_guild_ban_remove([this](auto && e) { OnGuildBanRemove(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::IntegrationCreate: mC->on_integration_create([this](auto && e) { OnIntegrationCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::IntegrationUpdate: mC->on_integration_update([this](auto && e) { OnIntegrationUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::IntegrationDelete: mC->on_integration_delete([this](auto && e) { OnIntegrationDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ThreadCreate: mC->on_thread_create([this](auto && e) { OnThreadCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ThreadUpdate: mC->on_thread_update([this](auto && e) { OnThreadUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ThreadDelete: mC->on_thread_delete([this](auto && e) { OnThreadDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ThreadListSync: mC->on_thread_list_sync([this](auto && e) { OnThreadListSync(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ThreadMemberUpdate: mC->on_thread_member_update([this](auto && e) { OnThreadMemberUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::ThreadMembersUpdate: mC->on_thread_members_update([this](auto && e) { OnThreadMembersUpdate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::VoiceBufferSend: mC->on_voice_buffer_send([this](auto && e) { OnVoiceBufferSend(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::VoiceUserTalking: mC->on_voice_user_talking([this](auto && e) { OnVoiceUserTalking(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::VoiceReady: mC->on_voice_ready([this](auto && e) { OnVoiceReady(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::VoiceReceive: mC->on_voice_receive([this](auto && e) { OnVoiceReceive(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::VoiceTrackMarker: mC->on_voice_track_marker([this](auto && e) { OnVoiceTrackMarker(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::StageInstanceCreate: mC->on_stage_instance_create([this](auto && e) { OnStageInstanceCreate(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::StageInstanceDelete: mC->on_stage_instance_delete([this](auto && e) { OnStageInstanceDelete(std::forward< decltype(e) >(e)); }); break;
|
|
||||||
case DpEventID::Max: // Fall through
|
|
||||||
default: STHROWF("Invalid discord event identifier {}", id);
|
|
||||||
}
|
|
||||||
// Allow chaining
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
DpCluster & DpCluster::DisableEvent(SQInteger id)
|
|
||||||
{
|
|
||||||
switch (id)
|
|
||||||
{
|
|
||||||
case DpEventID::VoiceStateUpdate: mC->on_voice_state_update(std::function<void(const dpp::voice_state_update_t&)>{}); break;
|
|
||||||
case DpEventID::Log: mC->on_log(std::function<void(const dpp::log_t&)>{}); break;
|
|
||||||
case DpEventID::GuildJoinRequestDelete: mC->on_guild_join_request_delete(std::function<void(const dpp::guild_join_request_delete_t&)>{}); break;
|
|
||||||
case DpEventID::InteractionCreate: mC->on_interaction_create(std::function<void(const dpp::interaction_create_t&)>{}); break;
|
|
||||||
case DpEventID::ButtonClick: mC->on_button_click(std::function<void(const dpp::button_click_t&)>{}); break;
|
|
||||||
case DpEventID::SelectClick: mC->on_select_click(std::function<void(const dpp::select_click_t&)>{}); break;
|
|
||||||
case DpEventID::GuildDelete: mC->on_guild_delete(std::function<void(const dpp::guild_delete_t&)>{}); break;
|
|
||||||
case DpEventID::ChannelDelete: mC->on_channel_delete(std::function<void(const dpp::channel_delete_t&)>{}); break;
|
|
||||||
case DpEventID::ChannelUpdate: mC->on_channel_update(std::function<void(const dpp::channel_update_t&)>{}); break;
|
|
||||||
case DpEventID::Ready: mC->on_ready(std::function<void(const dpp::ready_t&)>{}); break;
|
|
||||||
case DpEventID::MessageDelete: mC->on_message_delete(std::function<void(const dpp::message_delete_t&)>{}); break;
|
|
||||||
case DpEventID::ApplicationCommandDelete: mC->on_application_command_delete(std::function<void(const dpp::application_command_delete_t&)>{}); break;
|
|
||||||
case DpEventID::GuildMemberRemove: mC->on_guild_member_remove(std::function<void(const dpp::guild_member_remove_t&)>{}); break;
|
|
||||||
case DpEventID::ApplicationCommandCreate: mC->on_application_command_create(std::function<void(const dpp::application_command_create_t&)>{}); break;
|
|
||||||
case DpEventID::Resumed: mC->on_resumed(std::function<void(const dpp::resumed_t&)>{}); break;
|
|
||||||
case DpEventID::GuildRoleCreate: mC->on_guild_role_create(std::function<void(const dpp::guild_role_create_t&)>{}); break;
|
|
||||||
case DpEventID::TypingStart: mC->on_typing_start(std::function<void(const dpp::typing_start_t&)>{}); break;
|
|
||||||
case DpEventID::MessageReactionAdd: mC->on_message_reaction_add(std::function<void(const dpp::message_reaction_add_t&)>{}); break;
|
|
||||||
case DpEventID::GuildMembersChunk: mC->on_guild_members_chunk(std::function<void(const dpp::guild_members_chunk_t&)>{}); break;
|
|
||||||
case DpEventID::MessageReactionRemove: mC->on_message_reaction_remove(std::function<void(const dpp::message_reaction_remove_t&)>{}); break;
|
|
||||||
case DpEventID::GuildCreate: mC->on_guild_create(std::function<void(const dpp::guild_create_t&)>{}); break;
|
|
||||||
case DpEventID::ChannelCreate: mC->on_channel_create(std::function<void(const dpp::channel_create_t&)>{}); break;
|
|
||||||
case DpEventID::MessageReactionRemoveEmoji: mC->on_message_reaction_remove_emoji(std::function<void(const dpp::message_reaction_remove_emoji_t&)>{}); break;
|
|
||||||
case DpEventID::MessageDeleteBulk: mC->on_message_delete_bulk(std::function<void(const dpp::message_delete_bulk_t&)>{}); break;
|
|
||||||
case DpEventID::GuildRoleUpdate: mC->on_guild_role_update(std::function<void(const dpp::guild_role_update_t&)>{}); break;
|
|
||||||
case DpEventID::GuildRoleDelete: mC->on_guild_role_delete(std::function<void(const dpp::guild_role_delete_t&)>{}); break;
|
|
||||||
case DpEventID::ChannelPinsUpdate: mC->on_channel_pins_update(std::function<void(const dpp::channel_pins_update_t&)>{}); break;
|
|
||||||
case DpEventID::MessageReactionRemoveAll: mC->on_message_reaction_remove_all(std::function<void(const dpp::message_reaction_remove_all_t&)>{}); break;
|
|
||||||
case DpEventID::VoiceServerUpdate: mC->on_voice_server_update(std::function<void(const dpp::voice_server_update_t&)>{}); break;
|
|
||||||
case DpEventID::GuildEmojisUpdate: mC->on_guild_emojis_update(std::function<void(const dpp::guild_emojis_update_t&)>{}); break;
|
|
||||||
case DpEventID::GuildStickersUpdate: mC->on_guild_stickers_update(std::function<void(const dpp::guild_stickers_update_t&)>{}); break;
|
|
||||||
case DpEventID::PresenceUpdate: mC->on_presence_update(std::function<void(const dpp::presence_update_t&)>{}); break;
|
|
||||||
case DpEventID::WebhooksUpdate: mC->on_webhooks_update(std::function<void(const dpp::webhooks_update_t&)>{}); break;
|
|
||||||
case DpEventID::GuildMemberAdd: mC->on_guild_member_add(std::function<void(const dpp::guild_member_add_t&)>{}); break;
|
|
||||||
case DpEventID::InviteDelete: mC->on_invite_delete(std::function<void(const dpp::invite_delete_t&)>{}); break;
|
|
||||||
case DpEventID::GuildUpdate: mC->on_guild_update(std::function<void(const dpp::guild_update_t&)>{}); break;
|
|
||||||
case DpEventID::GuildIntegrationsUpdate: mC->on_guild_integrations_update(std::function<void(const dpp::guild_integrations_update_t&)>{}); break;
|
|
||||||
case DpEventID::GuildMemberUpdate: mC->on_guild_member_update(std::function<void(const dpp::guild_member_update_t&)>{}); break;
|
|
||||||
case DpEventID::ApplicationCommandUpdate: mC->on_application_command_update(std::function<void(const dpp::application_command_update_t&)>{}); break;
|
|
||||||
case DpEventID::InviteCreate: mC->on_invite_create(std::function<void(const dpp::invite_create_t&)>{}); break;
|
|
||||||
case DpEventID::MessageUpdate: mC->on_message_update(std::function<void(const dpp::message_update_t&)>{}); break;
|
|
||||||
case DpEventID::UserUpdate: mC->on_user_update(std::function<void(const dpp::user_update_t&)>{}); break;
|
|
||||||
case DpEventID::MessageCreate: mC->on_message_create(std::function<void(const dpp::message_create_t&)>{}); break;
|
|
||||||
case DpEventID::GuildBanAdd: mC->on_guild_ban_add(std::function<void(const dpp::guild_ban_add_t&)>{}); break;
|
|
||||||
case DpEventID::GuildBanRemove: mC->on_guild_ban_remove(std::function<void(const dpp::guild_ban_remove_t&)>{}); break;
|
|
||||||
case DpEventID::IntegrationCreate: mC->on_integration_create(std::function<void(const dpp::integration_create_t&)>{}); break;
|
|
||||||
case DpEventID::IntegrationUpdate: mC->on_integration_update(std::function<void(const dpp::integration_update_t&)>{}); break;
|
|
||||||
case DpEventID::IntegrationDelete: mC->on_integration_delete(std::function<void(const dpp::integration_delete_t&)>{}); break;
|
|
||||||
case DpEventID::ThreadCreate: mC->on_thread_create(std::function<void(const dpp::thread_create_t&)>{}); break;
|
|
||||||
case DpEventID::ThreadUpdate: mC->on_thread_update(std::function<void(const dpp::thread_update_t&)>{}); break;
|
|
||||||
case DpEventID::ThreadDelete: mC->on_thread_delete(std::function<void(const dpp::thread_delete_t&)>{}); break;
|
|
||||||
case DpEventID::ThreadListSync: mC->on_thread_list_sync(std::function<void(const dpp::thread_list_sync_t&)>{}); break;
|
|
||||||
case DpEventID::ThreadMemberUpdate: mC->on_thread_member_update(std::function<void(const dpp::thread_member_update_t&)>{}); break;
|
|
||||||
case DpEventID::ThreadMembersUpdate: mC->on_thread_members_update(std::function<void(const dpp::thread_members_update_t&)>{}); break;
|
|
||||||
case DpEventID::VoiceBufferSend: mC->on_voice_buffer_send(std::function<void(const dpp::voice_buffer_send_t&)>{}); break;
|
|
||||||
case DpEventID::VoiceUserTalking: mC->on_voice_user_talking(std::function<void(const dpp::voice_user_talking_t&)>{}); break;
|
|
||||||
case DpEventID::VoiceReady: mC->on_voice_ready(std::function<void(const dpp::voice_ready_t&)>{}); break;
|
|
||||||
case DpEventID::VoiceReceive: mC->on_voice_receive(std::function<void(const dpp::voice_receive_t&)>{}); break;
|
|
||||||
case DpEventID::VoiceTrackMarker: mC->on_voice_track_marker(std::function<void(const dpp::voice_track_marker_t&)>{}); break;
|
|
||||||
case DpEventID::StageInstanceCreate: mC->on_stage_instance_create(std::function<void(const dpp::stage_instance_create_t&)>{}); break;
|
|
||||||
case DpEventID::StageInstanceDelete: mC->on_stage_instance_delete(std::function<void(const dpp::stage_instance_delete_t&)>{}); break;
|
|
||||||
case DpEventID::Max: // Fall through
|
|
||||||
default: STHROWF("Invalid discord event identifier {}", id);
|
|
||||||
}
|
|
||||||
// Allow chaining
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void DpInternalEvent::Release()
|
|
||||||
{
|
|
||||||
// Make sure we actually manage something
|
|
||||||
if (mData == 0) return;
|
|
||||||
// Fetch the type of data
|
|
||||||
const auto type = GetType();
|
|
||||||
// Fetch the data itself
|
|
||||||
const auto data = GetData();
|
|
||||||
// Identify data type
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DpEventID::VoiceStateUpdate: delete reinterpret_cast< DpVoiceStateUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::Log: delete reinterpret_cast< DpLogEvent * >(data); break;
|
|
||||||
case DpEventID::GuildJoinRequestDelete: delete reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::InteractionCreate: delete reinterpret_cast< DpInteractionCreateEvent * >(data); break;
|
|
||||||
case DpEventID::ButtonClick: delete reinterpret_cast< DpButtonClickEvent * >(data); break;
|
|
||||||
case DpEventID::SelectClick: delete reinterpret_cast< DpSelectClickEvent * >(data); break;
|
|
||||||
case DpEventID::GuildDelete: delete reinterpret_cast< DpGuildDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::ChannelDelete: delete reinterpret_cast< DpChannelDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::ChannelUpdate: delete reinterpret_cast< DpChannelUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::Ready: delete reinterpret_cast< DpReadyEvent * >(data); break;
|
|
||||||
case DpEventID::MessageDelete: delete reinterpret_cast< DpMessageDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::ApplicationCommandDelete: delete reinterpret_cast< DpApplicationCommandDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::GuildMemberRemove: delete reinterpret_cast< DpGuildMemberRemoveEvent * >(data); break;
|
|
||||||
case DpEventID::ApplicationCommandCreate: delete reinterpret_cast< DpApplicationCommandCreateEvent * >(data); break;
|
|
||||||
case DpEventID::Resumed: delete reinterpret_cast< DpResumedEvent * >(data); break;
|
|
||||||
case DpEventID::GuildRoleCreate: delete reinterpret_cast< DpGuildRoleCreateEvent * >(data); break;
|
|
||||||
case DpEventID::TypingStart: delete reinterpret_cast< DpTypingStartEvent * >(data); break;
|
|
||||||
case DpEventID::MessageReactionAdd: delete reinterpret_cast< DpMessageReactionAddEvent * >(data); break;
|
|
||||||
case DpEventID::GuildMembersChunk: delete reinterpret_cast< DpGuildMembersChunkEvent * >(data); break;
|
|
||||||
case DpEventID::MessageReactionRemove: delete reinterpret_cast< DpMessageReactionRemoveEvent * >(data); break;
|
|
||||||
case DpEventID::GuildCreate: delete reinterpret_cast< DpGuildCreateEvent * >(data); break;
|
|
||||||
case DpEventID::ChannelCreate: delete reinterpret_cast< DpChannelCreateEvent * >(data); break;
|
|
||||||
case DpEventID::MessageReactionRemoveEmoji: delete reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data); break;
|
|
||||||
case DpEventID::MessageDeleteBulk: delete reinterpret_cast< DpMessageDeleteBulkEvent * >(data); break;
|
|
||||||
case DpEventID::GuildRoleUpdate: delete reinterpret_cast< DpGuildRoleUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::GuildRoleDelete: delete reinterpret_cast< DpGuildRoleDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::ChannelPinsUpdate: delete reinterpret_cast< DpChannelPinsUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::MessageReactionRemoveAll: delete reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data); break;
|
|
||||||
case DpEventID::VoiceServerUpdate: delete reinterpret_cast< DpVoiceServerUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::GuildEmojisUpdate: delete reinterpret_cast< DpGuildEmojisUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::GuildStickersUpdate: delete reinterpret_cast< DpGuildStickersUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::PresenceUpdate: delete reinterpret_cast< DpPresenceUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::WebhooksUpdate: delete reinterpret_cast< DpWebhooksUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::GuildMemberAdd: delete reinterpret_cast< DpGuildMemberAddEvent * >(data); break;
|
|
||||||
case DpEventID::InviteDelete: delete reinterpret_cast< DpInviteDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::GuildUpdate: delete reinterpret_cast< DpGuildUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::GuildIntegrationsUpdate: delete reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::GuildMemberUpdate: delete reinterpret_cast< DpGuildMemberUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::ApplicationCommandUpdate: delete reinterpret_cast< DpApplicationCommandUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::InviteCreate: delete reinterpret_cast< DpInviteCreateEvent * >(data); break;
|
|
||||||
case DpEventID::MessageUpdate: delete reinterpret_cast< DpMessageUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::UserUpdate: delete reinterpret_cast< DpUserUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::MessageCreate: delete reinterpret_cast< DpMessageCreateEvent * >(data); break;
|
|
||||||
case DpEventID::GuildBanAdd: delete reinterpret_cast< DpGuildBanAddEvent * >(data); break;
|
|
||||||
case DpEventID::GuildBanRemove: delete reinterpret_cast< DpGuildBanRemoveEvent * >(data); break;
|
|
||||||
case DpEventID::IntegrationCreate: delete reinterpret_cast< DpIntegrationCreateEvent * >(data); break;
|
|
||||||
case DpEventID::IntegrationUpdate: delete reinterpret_cast< DpIntegrationUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::IntegrationDelete: delete reinterpret_cast< DpIntegrationDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::ThreadCreate: delete reinterpret_cast< DpThreadCreateEvent * >(data); break;
|
|
||||||
case DpEventID::ThreadUpdate: delete reinterpret_cast< DpThreadUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::ThreadDelete: delete reinterpret_cast< DpThreadDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::ThreadListSync: delete reinterpret_cast< DpThreadListSyncEvent * >(data); break;
|
|
||||||
case DpEventID::ThreadMemberUpdate: delete reinterpret_cast< DpThreadMemberUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::ThreadMembersUpdate: delete reinterpret_cast< DpThreadMembersUpdateEvent * >(data); break;
|
|
||||||
case DpEventID::VoiceBufferSend: delete reinterpret_cast< DpVoiceBufferSendEvent * >(data); break;
|
|
||||||
case DpEventID::VoiceUserTalking: delete reinterpret_cast< DpVoiceUserTalkingEvent * >(data); break;
|
|
||||||
case DpEventID::VoiceReady: delete reinterpret_cast< DpVoiceReadyEvent * >(data); break;
|
|
||||||
case DpEventID::VoiceReceive: delete reinterpret_cast< DpVoiceReceiveEvent * >(data); break;
|
|
||||||
case DpEventID::VoiceTrackMarker: delete reinterpret_cast< DpVoiceTrackMarkerEvent * >(data); break;
|
|
||||||
case DpEventID::StageInstanceCreate: delete reinterpret_cast< DpStageInstanceCreateEvent * >(data); break;
|
|
||||||
case DpEventID::StageInstanceDelete: delete reinterpret_cast< DpStageInstanceDeleteEvent * >(data); break;
|
|
||||||
case DpEventID::Max: // Fall through
|
|
||||||
default: LogFtl("Unrecognized discord event instance type"); assert(0); break;
|
|
||||||
}
|
|
||||||
// Forget about it
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQMOD_NODISCARD LightObj EventToScriptObject(uint8_t type, uintptr_t data)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DpEventID::VoiceStateUpdate: return LightObj(reinterpret_cast< DpVoiceStateUpdateEvent * >(data));
|
|
||||||
case DpEventID::Log: return LightObj(reinterpret_cast< DpLogEvent * >(data));
|
|
||||||
case DpEventID::GuildJoinRequestDelete: return LightObj(reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data));
|
|
||||||
case DpEventID::InteractionCreate: return LightObj(reinterpret_cast< DpInteractionCreateEvent * >(data));
|
|
||||||
case DpEventID::ButtonClick: return LightObj(reinterpret_cast< DpButtonClickEvent * >(data));
|
|
||||||
case DpEventID::SelectClick: return LightObj(reinterpret_cast< DpSelectClickEvent * >(data));
|
|
||||||
case DpEventID::GuildDelete: return LightObj(reinterpret_cast< DpGuildDeleteEvent * >(data));
|
|
||||||
case DpEventID::ChannelDelete: return LightObj(reinterpret_cast< DpChannelDeleteEvent * >(data));
|
|
||||||
case DpEventID::ChannelUpdate: return LightObj(reinterpret_cast< DpChannelUpdateEvent * >(data));
|
|
||||||
case DpEventID::Ready: return LightObj(reinterpret_cast< DpReadyEvent * >(data));
|
|
||||||
case DpEventID::MessageDelete: return LightObj(reinterpret_cast< DpMessageDeleteEvent * >(data));
|
|
||||||
case DpEventID::ApplicationCommandDelete: return LightObj(reinterpret_cast< DpApplicationCommandDeleteEvent * >(data));
|
|
||||||
case DpEventID::GuildMemberRemove: return LightObj(reinterpret_cast< DpGuildMemberRemoveEvent * >(data));
|
|
||||||
case DpEventID::ApplicationCommandCreate: return LightObj(reinterpret_cast< DpApplicationCommandCreateEvent * >(data));
|
|
||||||
case DpEventID::Resumed: return LightObj(reinterpret_cast< DpResumedEvent * >(data));
|
|
||||||
case DpEventID::GuildRoleCreate: return LightObj(reinterpret_cast< DpGuildRoleCreateEvent * >(data));
|
|
||||||
case DpEventID::TypingStart: return LightObj(reinterpret_cast< DpTypingStartEvent * >(data));
|
|
||||||
case DpEventID::MessageReactionAdd: return LightObj(reinterpret_cast< DpMessageReactionAddEvent * >(data));
|
|
||||||
case DpEventID::GuildMembersChunk: return LightObj(reinterpret_cast< DpGuildMembersChunkEvent * >(data));
|
|
||||||
case DpEventID::MessageReactionRemove: return LightObj(reinterpret_cast< DpMessageReactionRemoveEvent * >(data));
|
|
||||||
case DpEventID::GuildCreate: return LightObj(reinterpret_cast< DpGuildCreateEvent * >(data));
|
|
||||||
case DpEventID::ChannelCreate: return LightObj(reinterpret_cast< DpChannelCreateEvent * >(data));
|
|
||||||
case DpEventID::MessageReactionRemoveEmoji: return LightObj(reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data));
|
|
||||||
case DpEventID::MessageDeleteBulk: return LightObj(reinterpret_cast< DpMessageDeleteBulkEvent * >(data));
|
|
||||||
case DpEventID::GuildRoleUpdate: return LightObj(reinterpret_cast< DpGuildRoleUpdateEvent * >(data));
|
|
||||||
case DpEventID::GuildRoleDelete: return LightObj(reinterpret_cast< DpGuildRoleDeleteEvent * >(data));
|
|
||||||
case DpEventID::ChannelPinsUpdate: return LightObj(reinterpret_cast< DpChannelPinsUpdateEvent * >(data));
|
|
||||||
case DpEventID::MessageReactionRemoveAll: return LightObj(reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data));
|
|
||||||
case DpEventID::VoiceServerUpdate: return LightObj(reinterpret_cast< DpVoiceServerUpdateEvent * >(data));
|
|
||||||
case DpEventID::GuildEmojisUpdate: return LightObj(reinterpret_cast< DpGuildEmojisUpdateEvent * >(data));
|
|
||||||
case DpEventID::GuildStickersUpdate: return LightObj(reinterpret_cast< DpGuildStickersUpdateEvent * >(data));
|
|
||||||
case DpEventID::PresenceUpdate: return LightObj(reinterpret_cast< DpPresenceUpdateEvent * >(data));
|
|
||||||
case DpEventID::WebhooksUpdate: return LightObj(reinterpret_cast< DpWebhooksUpdateEvent * >(data));
|
|
||||||
case DpEventID::GuildMemberAdd: return LightObj(reinterpret_cast< DpGuildMemberAddEvent * >(data));
|
|
||||||
case DpEventID::InviteDelete: return LightObj(reinterpret_cast< DpInviteDeleteEvent * >(data));
|
|
||||||
case DpEventID::GuildUpdate: return LightObj(reinterpret_cast< DpGuildUpdateEvent * >(data));
|
|
||||||
case DpEventID::GuildIntegrationsUpdate: return LightObj(reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data));
|
|
||||||
case DpEventID::GuildMemberUpdate: return LightObj(reinterpret_cast< DpGuildMemberUpdateEvent * >(data));
|
|
||||||
case DpEventID::ApplicationCommandUpdate: return LightObj(reinterpret_cast< DpApplicationCommandUpdateEvent * >(data));
|
|
||||||
case DpEventID::InviteCreate: return LightObj(reinterpret_cast< DpInviteCreateEvent * >(data));
|
|
||||||
case DpEventID::MessageUpdate: return LightObj(reinterpret_cast< DpMessageUpdateEvent * >(data));
|
|
||||||
case DpEventID::UserUpdate: return LightObj(reinterpret_cast< DpUserUpdateEvent * >(data));
|
|
||||||
case DpEventID::MessageCreate: return LightObj(reinterpret_cast< DpMessageCreateEvent * >(data));
|
|
||||||
case DpEventID::GuildBanAdd: return LightObj(reinterpret_cast< DpGuildBanAddEvent * >(data));
|
|
||||||
case DpEventID::GuildBanRemove: return LightObj(reinterpret_cast< DpGuildBanRemoveEvent * >(data));
|
|
||||||
case DpEventID::IntegrationCreate: return LightObj(reinterpret_cast< DpIntegrationCreateEvent * >(data));
|
|
||||||
case DpEventID::IntegrationUpdate: return LightObj(reinterpret_cast< DpIntegrationUpdateEvent * >(data));
|
|
||||||
case DpEventID::IntegrationDelete: return LightObj(reinterpret_cast< DpIntegrationDeleteEvent * >(data));
|
|
||||||
case DpEventID::ThreadCreate: return LightObj(reinterpret_cast< DpThreadCreateEvent * >(data));
|
|
||||||
case DpEventID::ThreadUpdate: return LightObj(reinterpret_cast< DpThreadUpdateEvent * >(data));
|
|
||||||
case DpEventID::ThreadDelete: return LightObj(reinterpret_cast< DpThreadDeleteEvent * >(data));
|
|
||||||
case DpEventID::ThreadListSync: return LightObj(reinterpret_cast< DpThreadListSyncEvent * >(data));
|
|
||||||
case DpEventID::ThreadMemberUpdate: return LightObj(reinterpret_cast< DpThreadMemberUpdateEvent * >(data));
|
|
||||||
case DpEventID::ThreadMembersUpdate: return LightObj(reinterpret_cast< DpThreadMembersUpdateEvent * >(data));
|
|
||||||
case DpEventID::VoiceBufferSend: return LightObj(reinterpret_cast< DpVoiceBufferSendEvent * >(data));
|
|
||||||
case DpEventID::VoiceUserTalking: return LightObj(reinterpret_cast< DpVoiceUserTalkingEvent * >(data));
|
|
||||||
case DpEventID::VoiceReady: return LightObj(reinterpret_cast< DpVoiceReadyEvent * >(data));
|
|
||||||
case DpEventID::VoiceReceive: return LightObj(reinterpret_cast< DpVoiceReceiveEvent * >(data));
|
|
||||||
case DpEventID::VoiceTrackMarker: return LightObj(reinterpret_cast< DpVoiceTrackMarkerEvent * >(data));
|
|
||||||
case DpEventID::StageInstanceCreate: return LightObj(reinterpret_cast< DpStageInstanceCreateEvent * >(data));
|
|
||||||
case DpEventID::StageInstanceDelete: return LightObj(reinterpret_cast< DpStageInstanceDeleteEvent * >(data));
|
|
||||||
case DpEventID::Max: // Fall through
|
|
||||||
default: assert(0); return LightObj{};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void EventInvokeCleanup(uint8_t type, uintptr_t data)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case DpEventID::VoiceStateUpdate: reinterpret_cast< DpVoiceStateUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::Log: reinterpret_cast< DpLogEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildJoinRequestDelete: reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::InteractionCreate: reinterpret_cast< DpInteractionCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ButtonClick: reinterpret_cast< DpButtonClickEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::SelectClick: reinterpret_cast< DpSelectClickEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildDelete: reinterpret_cast< DpGuildDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ChannelDelete: reinterpret_cast< DpChannelDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ChannelUpdate: reinterpret_cast< DpChannelUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::Ready: reinterpret_cast< DpReadyEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageDelete: reinterpret_cast< DpMessageDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ApplicationCommandDelete: reinterpret_cast< DpApplicationCommandDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildMemberRemove: reinterpret_cast< DpGuildMemberRemoveEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ApplicationCommandCreate: reinterpret_cast< DpApplicationCommandCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::Resumed: reinterpret_cast< DpResumedEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildRoleCreate: reinterpret_cast< DpGuildRoleCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::TypingStart: reinterpret_cast< DpTypingStartEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageReactionAdd: reinterpret_cast< DpMessageReactionAddEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildMembersChunk: reinterpret_cast< DpGuildMembersChunkEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageReactionRemove: reinterpret_cast< DpMessageReactionRemoveEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildCreate: reinterpret_cast< DpGuildCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ChannelCreate: reinterpret_cast< DpChannelCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageReactionRemoveEmoji: reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageDeleteBulk: reinterpret_cast< DpMessageDeleteBulkEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildRoleUpdate: reinterpret_cast< DpGuildRoleUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildRoleDelete: reinterpret_cast< DpGuildRoleDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ChannelPinsUpdate: reinterpret_cast< DpChannelPinsUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageReactionRemoveAll: reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::VoiceServerUpdate: reinterpret_cast< DpVoiceServerUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildEmojisUpdate: reinterpret_cast< DpGuildEmojisUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildStickersUpdate: reinterpret_cast< DpGuildStickersUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::PresenceUpdate: reinterpret_cast< DpPresenceUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::WebhooksUpdate: reinterpret_cast< DpWebhooksUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildMemberAdd: reinterpret_cast< DpGuildMemberAddEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::InviteDelete: reinterpret_cast< DpInviteDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildUpdate: reinterpret_cast< DpGuildUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildIntegrationsUpdate: reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildMemberUpdate: reinterpret_cast< DpGuildMemberUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ApplicationCommandUpdate: reinterpret_cast< DpApplicationCommandUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::InviteCreate: reinterpret_cast< DpInviteCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageUpdate: reinterpret_cast< DpMessageUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::UserUpdate: reinterpret_cast< DpUserUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::MessageCreate: reinterpret_cast< DpMessageCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildBanAdd: reinterpret_cast< DpGuildBanAddEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::GuildBanRemove: reinterpret_cast< DpGuildBanRemoveEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::IntegrationCreate: reinterpret_cast< DpIntegrationCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::IntegrationUpdate: reinterpret_cast< DpIntegrationUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::IntegrationDelete: reinterpret_cast< DpIntegrationDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ThreadCreate: reinterpret_cast< DpThreadCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ThreadUpdate: reinterpret_cast< DpThreadUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ThreadDelete: reinterpret_cast< DpThreadDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ThreadListSync: reinterpret_cast< DpThreadListSyncEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ThreadMemberUpdate: reinterpret_cast< DpThreadMemberUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::ThreadMembersUpdate: reinterpret_cast< DpThreadMembersUpdateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::VoiceBufferSend: reinterpret_cast< DpVoiceBufferSendEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::VoiceUserTalking: reinterpret_cast< DpVoiceUserTalkingEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::VoiceReady: reinterpret_cast< DpVoiceReadyEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::VoiceReceive: reinterpret_cast< DpVoiceReceiveEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::VoiceTrackMarker: reinterpret_cast< DpVoiceTrackMarkerEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::StageInstanceCreate: reinterpret_cast< DpStageInstanceCreateEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::StageInstanceDelete: reinterpret_cast< DpStageInstanceDeleteEvent * >(data)->Cleanup(); break;
|
|
||||||
case DpEventID::Max: // Fall through
|
|
||||||
default: assert(0); return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -1,428 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/DPPEv.hpp"
|
#include "Core/Utility.hpp"
|
||||||
#include "Library/DPPTy.hpp"
|
|
||||||
#include "Core/Signal.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <chrono>
|
|
||||||
#include <memory>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include <concurrentqueue.h>
|
|
||||||
#include <dpp/dpp.h>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
|
||||||
* WebSocket frame.
|
|
||||||
*/
|
|
||||||
struct DpInternalEvent
|
|
||||||
{
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Event data.
|
|
||||||
*/
|
|
||||||
uint64_t mData{0llu};
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
DpInternalEvent() noexcept = default;
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
DpInternalEvent(uint64_t type, void * data) noexcept
|
|
||||||
: mData((type << 56u) | reinterpret_cast< uint64_t >(data))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Copy constructor (disabled).
|
|
||||||
*/
|
|
||||||
DpInternalEvent(const DpInternalEvent & o) = delete;
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Move constructor.
|
|
||||||
*/
|
|
||||||
DpInternalEvent(DpInternalEvent && o) noexcept
|
|
||||||
: mData(o.mData)
|
|
||||||
{
|
|
||||||
o.mData = 0llu; // Take ownership
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Destructor.
|
|
||||||
*/
|
|
||||||
~DpInternalEvent()
|
|
||||||
{
|
|
||||||
Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Copy assignment operator (disabled).
|
|
||||||
*/
|
|
||||||
DpInternalEvent & operator = (const DpInternalEvent & o) = delete;
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Move assignment operator.
|
|
||||||
*/
|
|
||||||
DpInternalEvent & operator = (DpInternalEvent && o) noexcept
|
|
||||||
{
|
|
||||||
if (mData != o.mData)
|
|
||||||
{
|
|
||||||
// Release current information
|
|
||||||
Release();
|
|
||||||
// Replicate members
|
|
||||||
mData = o.mData;
|
|
||||||
// Take ownership
|
|
||||||
o.mData = 0llu;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Forget about the managed event data.
|
|
||||||
*/
|
|
||||||
void Reset() noexcept
|
|
||||||
{
|
|
||||||
mData = 0llu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Retrieve the event type.
|
|
||||||
*/
|
|
||||||
SQMOD_NODISCARD uint8_t GetType() const noexcept
|
|
||||||
{
|
|
||||||
return static_cast< uint8_t >((mData >> 56u) & 0xFFllu);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Retrieve the event data.
|
|
||||||
*/
|
|
||||||
SQMOD_NODISCARD uintptr_t GetData() const noexcept
|
|
||||||
{
|
|
||||||
return static_cast< uintptr_t >((~(0xFFllu << 56u)) & mData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Release associated event data, if any.
|
|
||||||
*/
|
|
||||||
void Release();
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
|
||||||
* The cluster class represents a group of shards and a command queue for sending and receiving
|
|
||||||
* commands from discord via HTTP.
|
|
||||||
*/
|
|
||||||
struct DpCluster : public SqChainedInstances< DpCluster >
|
|
||||||
{
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Queue of events generated from other threads.
|
|
||||||
*/
|
|
||||||
using EventQueue = moodycamel::ConcurrentQueue< DpInternalEvent >;
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Managed cluster instance.
|
|
||||||
*/
|
|
||||||
std::unique_ptr< dpp::cluster > mC{nullptr};
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Event queue.
|
|
||||||
*/
|
|
||||||
EventQueue mQueue{4096};
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
explicit DpCluster(StackStrF & token)
|
|
||||||
: mC(std::make_unique< dpp::cluster >(token.ToStr()))
|
|
||||||
, mQueue(4096)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
DpCluster(StackStrF & token, SQInteger intents)
|
|
||||||
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents)))
|
|
||||||
, mQueue(4096)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards)
|
|
||||||
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards)))
|
|
||||||
, mQueue(4096)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id)
|
|
||||||
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id)))
|
|
||||||
, mQueue(4096)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters)
|
|
||||||
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters)))
|
|
||||||
, mQueue(4096)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters, bool compressed)
|
|
||||||
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters), compressed))
|
|
||||||
, mQueue(4096)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Explicit constructor.
|
|
||||||
*/
|
|
||||||
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters, bool compressed, const DpCachePolicy & cp)
|
|
||||||
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters), compressed, cp.ToNative()))
|
|
||||||
, mQueue(4096)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Destructor.
|
|
||||||
*/
|
|
||||||
~DpCluster()
|
|
||||||
{
|
|
||||||
DropEvents();
|
|
||||||
// Forget about this instance
|
|
||||||
UnchainInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Start the cluster, connecting all its shards. Returns once all shards are connected.
|
|
||||||
*/
|
|
||||||
DpCluster & Start()
|
|
||||||
{
|
|
||||||
LogInf("Before start...");
|
|
||||||
mC->start(true);
|
|
||||||
LogInf("After start...");
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Log a message to whatever log the user is using.
|
|
||||||
*/
|
|
||||||
DpCluster & Log(SQInteger severity, StackStrF & message)
|
|
||||||
{
|
|
||||||
mC->log(static_cast< dpp::loglevel >(severity), message.ToStr());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Get the dm channel for a user id.
|
|
||||||
*/
|
|
||||||
SQMOD_NODISCARD dpp::snowflake GetDmChannel(dpp::snowflake user_id) const
|
|
||||||
{
|
|
||||||
return mC->get_dm_channel(static_cast< dpp::snowflake >(user_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Set the dm channel id for a user id.
|
|
||||||
*/
|
|
||||||
DpCluster & SetDmChannel(dpp::snowflake user_id, dpp::snowflake channel_id)
|
|
||||||
{
|
|
||||||
mC->set_dm_channel(user_id, channel_id);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Returns the uptime of the cluster.
|
|
||||||
*/
|
|
||||||
SQMOD_NODISCARD dpp::utility::uptime UpTime() const
|
|
||||||
{
|
|
||||||
return mC->uptime();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Returns the uptime of the cluster.
|
|
||||||
*/
|
|
||||||
DpCluster & SetPresence(const DpPresence & p)
|
|
||||||
{
|
|
||||||
mC->set_presence(p.Valid());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
LightObj mSqEvents{}; // Table containing the emitted cluster events.
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Retrieve the events table of this cluster.
|
|
||||||
*/
|
|
||||||
SQMOD_NODISCARD LightObj & GetEvents()
|
|
||||||
{
|
|
||||||
return mSqEvents;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Cluster signals.
|
|
||||||
*/
|
|
||||||
std::array< SignalPair, static_cast< size_t >(DpEventID::Max) > mEvents{};
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Process the cluster.
|
|
||||||
*/
|
|
||||||
void Process(bool force = false);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Terminate the cluster.
|
|
||||||
*/
|
|
||||||
void Terminate()
|
|
||||||
{
|
|
||||||
// Delete the cluster instance
|
|
||||||
mC.reset();
|
|
||||||
// Release associated script objects
|
|
||||||
mSqEvents.Release();
|
|
||||||
// Release event signal objects
|
|
||||||
DropEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Enable a certain event for the cluster.
|
|
||||||
*/
|
|
||||||
DpCluster & EnableEvent(SQInteger id);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Disable a certain event for the cluster.
|
|
||||||
*/
|
|
||||||
DpCluster & DisableEvent(SQInteger id);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Initialize the cluster.
|
|
||||||
*/
|
|
||||||
void Initialize()
|
|
||||||
{
|
|
||||||
InitEvents();
|
|
||||||
// Remember this instance
|
|
||||||
ChainInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Signal initialization.
|
|
||||||
*/
|
|
||||||
void InitEvents()
|
|
||||||
{
|
|
||||||
// Ignore the call if already initialized
|
|
||||||
if (!mSqEvents.IsNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Create a new table on the stack
|
|
||||||
sq_newtableex(SqVM(), 64);
|
|
||||||
// Grab the table object from the stack
|
|
||||||
mSqEvents = LightObj(-1, SqVM());
|
|
||||||
// Pop the table object from the stack
|
|
||||||
sq_pop(SqVM(), 1);
|
|
||||||
// Proceed to initializing the events
|
|
||||||
for (size_t i = 0; i < mEvents.size(); ++i)
|
|
||||||
{
|
|
||||||
InitSignalPair(mEvents[i], mSqEvents, DpEventID::NAME[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Signal termination.
|
|
||||||
*/
|
|
||||||
void DropEvents()
|
|
||||||
{
|
|
||||||
for (auto & e : mEvents)
|
|
||||||
{
|
|
||||||
ResetSignalPair(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Event handlers.
|
|
||||||
*/
|
|
||||||
void OnVoiceStateUpdate(const dpp::voice_state_update_t & ev);
|
|
||||||
void OnLog(const dpp::log_t & ev);
|
|
||||||
void OnGuildJoinRequestDelete(const dpp::guild_join_request_delete_t & ev);
|
|
||||||
void OnInteractionCreate(const dpp::interaction_create_t & ev);
|
|
||||||
void OnButtonClick(const dpp::button_click_t & ev);
|
|
||||||
void OnSelectClick(const dpp::select_click_t & ev);
|
|
||||||
void OnGuildDelete(const dpp::guild_delete_t & ev);
|
|
||||||
void OnChannelDelete(const dpp::channel_delete_t & ev);
|
|
||||||
void OnChannelUpdate(const dpp::channel_update_t & ev);
|
|
||||||
void OnReady(const dpp::ready_t & ev);
|
|
||||||
void OnMessageDelete(const dpp::message_delete_t & ev);
|
|
||||||
void OnApplicationCommandDelete(const dpp::application_command_delete_t & ev);
|
|
||||||
void OnGuildMemberRemove(const dpp::guild_member_remove_t & ev);
|
|
||||||
void OnApplicationCommandCreate(const dpp::application_command_create_t & ev);
|
|
||||||
void OnResumed(const dpp::resumed_t & ev);
|
|
||||||
void OnGuildRoleCreate(const dpp::guild_role_create_t & ev);
|
|
||||||
void OnTypingStart(const dpp::typing_start_t & ev);
|
|
||||||
void OnMessageReactionAdd(const dpp::message_reaction_add_t & ev);
|
|
||||||
void OnGuildMembersChunk(const dpp::guild_members_chunk_t & ev);
|
|
||||||
void OnMessageReactionRemove(const dpp::message_reaction_remove_t & ev);
|
|
||||||
void OnGuildCreate(const dpp::guild_create_t & ev);
|
|
||||||
void OnChannelCreate(const dpp::channel_create_t & ev);
|
|
||||||
void OnMessageReactionRemoveEmoji(const dpp::message_reaction_remove_emoji_t & ev);
|
|
||||||
void OnMessageDeleteBulk(const dpp::message_delete_bulk_t & ev);
|
|
||||||
void OnGuildRoleUpdate(const dpp::guild_role_update_t & ev);
|
|
||||||
void OnGuildRoleDelete(const dpp::guild_role_delete_t & ev);
|
|
||||||
void OnChannelPinsUpdate(const dpp::channel_pins_update_t & ev);
|
|
||||||
void OnMessageReactionRemoveAll(const dpp::message_reaction_remove_all_t & ev);
|
|
||||||
void OnVoiceServerUpdate(const dpp::voice_server_update_t & ev);
|
|
||||||
void OnGuildEmojisUpdate(const dpp::guild_emojis_update_t & ev);
|
|
||||||
void OnGuildStickersUpdate(const dpp::guild_stickers_update_t & ev);
|
|
||||||
void OnPresenceUpdate(const dpp::presence_update_t & ev);
|
|
||||||
void OnWebhooksUpdate(const dpp::webhooks_update_t & ev);
|
|
||||||
void OnGuildMemberAdd(const dpp::guild_member_add_t & ev);
|
|
||||||
void OnInviteDelete(const dpp::invite_delete_t & ev);
|
|
||||||
void OnGuildUpdate(const dpp::guild_update_t & ev);
|
|
||||||
void OnGuildIntegrationsUpdate(const dpp::guild_integrations_update_t & ev);
|
|
||||||
void OnGuildMemberUpdate(const dpp::guild_member_update_t & ev);
|
|
||||||
void OnApplicationCommandUpdate(const dpp::application_command_update_t & ev);
|
|
||||||
void OnInviteCreate(const dpp::invite_create_t & ev);
|
|
||||||
void OnMessageUpdate(const dpp::message_update_t & ev);
|
|
||||||
void OnUserUpdate(const dpp::user_update_t & ev);
|
|
||||||
void OnMessageCreate(const dpp::message_create_t & ev);
|
|
||||||
void OnGuildBanAdd(const dpp::guild_ban_add_t & ev);
|
|
||||||
void OnGuildBanRemove(const dpp::guild_ban_remove_t & ev);
|
|
||||||
void OnIntegrationCreate(const dpp::integration_create_t & ev);
|
|
||||||
void OnIntegrationUpdate(const dpp::integration_update_t & ev);
|
|
||||||
void OnIntegrationDelete(const dpp::integration_delete_t & ev);
|
|
||||||
void OnThreadCreate(const dpp::thread_create_t & ev);
|
|
||||||
void OnThreadUpdate(const dpp::thread_update_t & ev);
|
|
||||||
void OnThreadDelete(const dpp::thread_delete_t & ev);
|
|
||||||
void OnThreadListSync(const dpp::thread_list_sync_t & ev);
|
|
||||||
void OnThreadMemberUpdate(const dpp::thread_member_update_t & ev);
|
|
||||||
void OnThreadMembersUpdate(const dpp::thread_members_update_t & ev);
|
|
||||||
void OnVoiceBufferSend(const dpp::voice_buffer_send_t & ev);
|
|
||||||
void OnVoiceUserTalking(const dpp::voice_user_talking_t & ev);
|
|
||||||
void OnVoiceReady(const dpp::voice_ready_t & ev);
|
|
||||||
void OnVoiceReceive(const dpp::voice_receive_t & ev);
|
|
||||||
void OnVoiceTrackMarker(const dpp::voice_track_marker_t & ev);
|
|
||||||
void OnStageInstanceCreate(const dpp::stage_instance_create_t & ev);
|
|
||||||
void OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
16
module/Library/DPP/Channel.cpp
Normal file
16
module/Library/DPP/Channel.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Channel.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Channel(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
19
module/Library/DPP/Channel.hpp
Normal file
19
module/Library/DPP/Channel.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
16
module/Library/DPP/Client.cpp
Normal file
16
module/Library/DPP/Client.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Client.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Client(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
19
module/Library/DPP/Client.hpp
Normal file
19
module/Library/DPP/Client.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
757
module/Library/DPP/Cluster.cpp
Normal file
757
module/Library/DPP/Cluster.cpp
Normal file
@ -0,0 +1,757 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Cluster.hpp"
|
||||||
|
#include "Library/DPP/Events.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppCluster, _SC("SqDppCluster"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Cluster(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Cluster"),
|
||||||
|
Class< DpCluster, NoCopy< DpCluster > >(vm, SqDppCluster::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor< StackStrF & >()
|
||||||
|
.Ctor< StackStrF &, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger, bool >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger, bool, const DpCachePolicy & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppCluster::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("On"), &DpCluster::GetEvents)
|
||||||
|
.Prop(_SC("UpTime"), &DpCluster::UpTime)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Start"), &DpCluster::Start)
|
||||||
|
.Func(_SC("Log"), &DpCluster::Log)
|
||||||
|
.Func(_SC("GetDmChannel"), &DpCluster::GetDmChannel)
|
||||||
|
.Func(_SC("SetDmChannel"), &DpCluster::SetDmChannel)
|
||||||
|
.Func(_SC("SetPresence"), &DpCluster::SetPresence)
|
||||||
|
.Func(_SC("EnableEvent"), &DpCluster::EnableEvent)
|
||||||
|
.Func(_SC("DisableEvent"), &DpCluster::DisableEvent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD LightObj EventToScriptObject(uint8_t type, uintptr_t data);
|
||||||
|
void EventInvokeCleanup(uint8_t type, uintptr_t data);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::Process(bool force)
|
||||||
|
{
|
||||||
|
// Is there a valid connection?
|
||||||
|
if (!mC && !force)
|
||||||
|
{
|
||||||
|
return; // No point in going forward
|
||||||
|
}
|
||||||
|
DpInternalEvent event;
|
||||||
|
// Retrieve each event individually and process it
|
||||||
|
for (size_t count = mQueue.size_approx(), n = 0; n <= count; ++n)
|
||||||
|
{
|
||||||
|
// Try to get an event from the queue
|
||||||
|
if (mQueue.try_dequeue(event))
|
||||||
|
{
|
||||||
|
// Fetch the type of event
|
||||||
|
const auto type = event.GetType();
|
||||||
|
// Fetch the event itself
|
||||||
|
const auto data = event.GetData();
|
||||||
|
// Is this a valid event and is anyone listening to it?
|
||||||
|
if (event.mData == 0 || mEvents[type].first == nullptr || mEvents[type].first->IsEmpty())
|
||||||
|
{
|
||||||
|
continue; // Move on
|
||||||
|
}
|
||||||
|
// Transform the event instance into a script object
|
||||||
|
LightObj obj = EventToScriptObject(type, data);
|
||||||
|
// Allow the script to take ownership of the event instance now
|
||||||
|
event.Reset();
|
||||||
|
// Forward the call to the associated signal
|
||||||
|
(*mEvents[type].first)(obj);
|
||||||
|
// Allow the event instance to clean itself
|
||||||
|
EventInvokeCleanup(type, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================================================================
|
||||||
|
* Event handlers.
|
||||||
|
*/
|
||||||
|
void DpCluster::OnVoiceStateUpdate(const dpp::voice_state_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceStateUpdate, new DpVoiceStateUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnLog(const dpp::log_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::Log, new DpLogEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildJoinRequestDelete(const dpp::guild_join_request_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildJoinRequestDelete, new DpGuildJoinRequestDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnInteractionCreate(const dpp::interaction_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::InteractionCreate, new DpInteractionCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnButtonClick(const dpp::button_click_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ButtonClick, new DpButtonClickEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnSelectClick(const dpp::select_click_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::SelectClick, new DpSelectClickEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildDelete(const dpp::guild_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildDelete, new DpGuildDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelDelete(const dpp::channel_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelDelete, new DpChannelDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelUpdate(const dpp::channel_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelUpdate, new DpChannelUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnReady(const dpp::ready_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::Ready, new DpReadyEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageDelete(const dpp::message_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageDelete, new DpMessageDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnApplicationCommandDelete(const dpp::application_command_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandDelete, new DpApplicationCommandDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMemberRemove(const dpp::guild_member_remove_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberRemove, new DpGuildMemberRemoveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnApplicationCommandCreate(const dpp::application_command_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandCreate, new DpApplicationCommandCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnResumed(const dpp::resumed_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::Resumed, new DpResumedEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildRoleCreate(const dpp::guild_role_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleCreate, new DpGuildRoleCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnTypingStart(const dpp::typing_start_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::TypingStart, new DpTypingStartEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionAdd(const dpp::message_reaction_add_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionAdd, new DpMessageReactionAddEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMembersChunk(const dpp::guild_members_chunk_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMembersChunk, new DpGuildMembersChunkEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionRemove(const dpp::message_reaction_remove_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemove, new DpMessageReactionRemoveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildCreate(const dpp::guild_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildCreate, new DpGuildCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelCreate(const dpp::channel_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelCreate, new DpChannelCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionRemoveEmoji(const dpp::message_reaction_remove_emoji_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemoveEmoji, new DpMessageReactionRemoveEmojiEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageDeleteBulk(const dpp::message_delete_bulk_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageDeleteBulk, new DpMessageDeleteBulkEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildRoleUpdate(const dpp::guild_role_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleUpdate, new DpGuildRoleUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildRoleDelete(const dpp::guild_role_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleDelete, new DpGuildRoleDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelPinsUpdate(const dpp::channel_pins_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelPinsUpdate, new DpChannelPinsUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionRemoveAll(const dpp::message_reaction_remove_all_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemoveAll, new DpMessageReactionRemoveAllEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceServerUpdate(const dpp::voice_server_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceServerUpdate, new DpVoiceServerUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildEmojisUpdate(const dpp::guild_emojis_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildEmojisUpdate, new DpGuildEmojisUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildStickersUpdate(const dpp::guild_stickers_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildStickersUpdate, new DpGuildStickersUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnPresenceUpdate(const dpp::presence_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::PresenceUpdate, new DpPresenceUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnWebhooksUpdate(const dpp::webhooks_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::WebhooksUpdate, new DpWebhooksUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMemberAdd(const dpp::guild_member_add_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberAdd, new DpGuildMemberAddEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnInviteDelete(const dpp::invite_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::InviteDelete, new DpInviteDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildUpdate(const dpp::guild_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildUpdate, new DpGuildUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildIntegrationsUpdate(const dpp::guild_integrations_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildIntegrationsUpdate, new DpGuildIntegrationsUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMemberUpdate(const dpp::guild_member_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberUpdate, new DpGuildMemberUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnApplicationCommandUpdate(const dpp::application_command_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandUpdate, new DpApplicationCommandUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnInviteCreate(const dpp::invite_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::InviteCreate, new DpInviteCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageUpdate(const dpp::message_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageUpdate, new DpMessageUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnUserUpdate(const dpp::user_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::UserUpdate, new DpUserUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageCreate(const dpp::message_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageCreate, new DpMessageCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildBanAdd(const dpp::guild_ban_add_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildBanAdd, new DpGuildBanAddEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildBanRemove(const dpp::guild_ban_remove_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildBanRemove, new DpGuildBanRemoveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnIntegrationCreate(const dpp::integration_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationCreate, new DpIntegrationCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnIntegrationUpdate(const dpp::integration_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationUpdate, new DpIntegrationUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnIntegrationDelete(const dpp::integration_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationDelete, new DpIntegrationDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadCreate(const dpp::thread_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadCreate, new DpThreadCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadUpdate(const dpp::thread_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadUpdate, new DpThreadUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadDelete(const dpp::thread_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadDelete, new DpThreadDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadListSync(const dpp::thread_list_sync_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadListSync, new DpThreadListSyncEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadMemberUpdate(const dpp::thread_member_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadMemberUpdate, new DpThreadMemberUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadMembersUpdate(const dpp::thread_members_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadMembersUpdate, new DpThreadMembersUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceBufferSend(const dpp::voice_buffer_send_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceBufferSend, new DpVoiceBufferSendEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceUserTalking(const dpp::voice_user_talking_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceUserTalking, new DpVoiceUserTalkingEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceReady(const dpp::voice_ready_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceReady, new DpVoiceReadyEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceReceive(const dpp::voice_receive_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceReceive, new DpVoiceReceiveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceTrackMarker(const dpp::voice_track_marker_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceTrackMarker, new DpVoiceTrackMarkerEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnStageInstanceCreate(const dpp::stage_instance_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::StageInstanceCreate, new DpStageInstanceCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::StageInstanceDelete, new DpStageInstanceDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
DpCluster & DpCluster::EnableEvent(SQInteger id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: mC->on_voice_state_update([this](auto && e) { OnVoiceStateUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Log: mC->on_log([this](auto && e) { OnLog(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: mC->on_guild_join_request_delete([this](auto && e) { OnGuildJoinRequestDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::InteractionCreate: mC->on_interaction_create([this](auto && e) { OnInteractionCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ButtonClick: mC->on_button_click([this](auto && e) { OnButtonClick(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::SelectClick: mC->on_select_click([this](auto && e) { OnSelectClick(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildDelete: mC->on_guild_delete([this](auto && e) { OnGuildDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelDelete: mC->on_channel_delete([this](auto && e) { OnChannelDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelUpdate: mC->on_channel_update([this](auto && e) { OnChannelUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Ready: mC->on_ready([this](auto && e) { OnReady(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageDelete: mC->on_message_delete([this](auto && e) { OnMessageDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: mC->on_application_command_delete([this](auto && e) { OnApplicationCommandDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMemberRemove: mC->on_guild_member_remove([this](auto && e) { OnGuildMemberRemove(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: mC->on_application_command_create([this](auto && e) { OnApplicationCommandCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Resumed: mC->on_resumed([this](auto && e) { OnResumed(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildRoleCreate: mC->on_guild_role_create([this](auto && e) { OnGuildRoleCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::TypingStart: mC->on_typing_start([this](auto && e) { OnTypingStart(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionAdd: mC->on_message_reaction_add([this](auto && e) { OnMessageReactionAdd(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMembersChunk: mC->on_guild_members_chunk([this](auto && e) { OnGuildMembersChunk(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionRemove: mC->on_message_reaction_remove([this](auto && e) { OnMessageReactionRemove(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildCreate: mC->on_guild_create([this](auto && e) { OnGuildCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelCreate: mC->on_channel_create([this](auto && e) { OnChannelCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: mC->on_message_reaction_remove_emoji([this](auto && e) { OnMessageReactionRemoveEmoji(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: mC->on_message_delete_bulk([this](auto && e) { OnMessageDeleteBulk(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: mC->on_guild_role_update([this](auto && e) { OnGuildRoleUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildRoleDelete: mC->on_guild_role_delete([this](auto && e) { OnGuildRoleDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: mC->on_channel_pins_update([this](auto && e) { OnChannelPinsUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: mC->on_message_reaction_remove_all([this](auto && e) { OnMessageReactionRemoveAll(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: mC->on_voice_server_update([this](auto && e) { OnVoiceServerUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: mC->on_guild_emojis_update([this](auto && e) { OnGuildEmojisUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: mC->on_guild_stickers_update([this](auto && e) { OnGuildStickersUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::PresenceUpdate: mC->on_presence_update([this](auto && e) { OnPresenceUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::WebhooksUpdate: mC->on_webhooks_update([this](auto && e) { OnWebhooksUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMemberAdd: mC->on_guild_member_add([this](auto && e) { OnGuildMemberAdd(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::InviteDelete: mC->on_invite_delete([this](auto && e) { OnInviteDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildUpdate: mC->on_guild_update([this](auto && e) { OnGuildUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: mC->on_guild_integrations_update([this](auto && e) { OnGuildIntegrationsUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: mC->on_guild_member_update([this](auto && e) { OnGuildMemberUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: mC->on_application_command_update([this](auto && e) { OnApplicationCommandUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::InviteCreate: mC->on_invite_create([this](auto && e) { OnInviteCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageUpdate: mC->on_message_update([this](auto && e) { OnMessageUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::UserUpdate: mC->on_user_update([this](auto && e) { OnUserUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageCreate: mC->on_message_create([this](auto && e) { OnMessageCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildBanAdd: mC->on_guild_ban_add([this](auto && e) { OnGuildBanAdd(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildBanRemove: mC->on_guild_ban_remove([this](auto && e) { OnGuildBanRemove(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::IntegrationCreate: mC->on_integration_create([this](auto && e) { OnIntegrationCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::IntegrationUpdate: mC->on_integration_update([this](auto && e) { OnIntegrationUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::IntegrationDelete: mC->on_integration_delete([this](auto && e) { OnIntegrationDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadCreate: mC->on_thread_create([this](auto && e) { OnThreadCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadUpdate: mC->on_thread_update([this](auto && e) { OnThreadUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadDelete: mC->on_thread_delete([this](auto && e) { OnThreadDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadListSync: mC->on_thread_list_sync([this](auto && e) { OnThreadListSync(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: mC->on_thread_member_update([this](auto && e) { OnThreadMemberUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: mC->on_thread_members_update([this](auto && e) { OnThreadMembersUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceBufferSend: mC->on_voice_buffer_send([this](auto && e) { OnVoiceBufferSend(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceUserTalking: mC->on_voice_user_talking([this](auto && e) { OnVoiceUserTalking(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceReady: mC->on_voice_ready([this](auto && e) { OnVoiceReady(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceReceive: mC->on_voice_receive([this](auto && e) { OnVoiceReceive(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: mC->on_voice_track_marker([this](auto && e) { OnVoiceTrackMarker(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::StageInstanceCreate: mC->on_stage_instance_create([this](auto && e) { OnStageInstanceCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::StageInstanceDelete: mC->on_stage_instance_delete([this](auto && e) { OnStageInstanceDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: STHROWF("Invalid discord event identifier {}", id);
|
||||||
|
}
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
DpCluster & DpCluster::DisableEvent(SQInteger id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: mC->on_voice_state_update(std::function<void(const dpp::voice_state_update_t&)>{}); break;
|
||||||
|
case DpEventID::Log: mC->on_log(std::function<void(const dpp::log_t&)>{}); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: mC->on_guild_join_request_delete(std::function<void(const dpp::guild_join_request_delete_t&)>{}); break;
|
||||||
|
case DpEventID::InteractionCreate: mC->on_interaction_create(std::function<void(const dpp::interaction_create_t&)>{}); break;
|
||||||
|
case DpEventID::ButtonClick: mC->on_button_click(std::function<void(const dpp::button_click_t&)>{}); break;
|
||||||
|
case DpEventID::SelectClick: mC->on_select_click(std::function<void(const dpp::select_click_t&)>{}); break;
|
||||||
|
case DpEventID::GuildDelete: mC->on_guild_delete(std::function<void(const dpp::guild_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelDelete: mC->on_channel_delete(std::function<void(const dpp::channel_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelUpdate: mC->on_channel_update(std::function<void(const dpp::channel_update_t&)>{}); break;
|
||||||
|
case DpEventID::Ready: mC->on_ready(std::function<void(const dpp::ready_t&)>{}); break;
|
||||||
|
case DpEventID::MessageDelete: mC->on_message_delete(std::function<void(const dpp::message_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: mC->on_application_command_delete(std::function<void(const dpp::application_command_delete_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMemberRemove: mC->on_guild_member_remove(std::function<void(const dpp::guild_member_remove_t&)>{}); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: mC->on_application_command_create(std::function<void(const dpp::application_command_create_t&)>{}); break;
|
||||||
|
case DpEventID::Resumed: mC->on_resumed(std::function<void(const dpp::resumed_t&)>{}); break;
|
||||||
|
case DpEventID::GuildRoleCreate: mC->on_guild_role_create(std::function<void(const dpp::guild_role_create_t&)>{}); break;
|
||||||
|
case DpEventID::TypingStart: mC->on_typing_start(std::function<void(const dpp::typing_start_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionAdd: mC->on_message_reaction_add(std::function<void(const dpp::message_reaction_add_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMembersChunk: mC->on_guild_members_chunk(std::function<void(const dpp::guild_members_chunk_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionRemove: mC->on_message_reaction_remove(std::function<void(const dpp::message_reaction_remove_t&)>{}); break;
|
||||||
|
case DpEventID::GuildCreate: mC->on_guild_create(std::function<void(const dpp::guild_create_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelCreate: mC->on_channel_create(std::function<void(const dpp::channel_create_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: mC->on_message_reaction_remove_emoji(std::function<void(const dpp::message_reaction_remove_emoji_t&)>{}); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: mC->on_message_delete_bulk(std::function<void(const dpp::message_delete_bulk_t&)>{}); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: mC->on_guild_role_update(std::function<void(const dpp::guild_role_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildRoleDelete: mC->on_guild_role_delete(std::function<void(const dpp::guild_role_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: mC->on_channel_pins_update(std::function<void(const dpp::channel_pins_update_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: mC->on_message_reaction_remove_all(std::function<void(const dpp::message_reaction_remove_all_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: mC->on_voice_server_update(std::function<void(const dpp::voice_server_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: mC->on_guild_emojis_update(std::function<void(const dpp::guild_emojis_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: mC->on_guild_stickers_update(std::function<void(const dpp::guild_stickers_update_t&)>{}); break;
|
||||||
|
case DpEventID::PresenceUpdate: mC->on_presence_update(std::function<void(const dpp::presence_update_t&)>{}); break;
|
||||||
|
case DpEventID::WebhooksUpdate: mC->on_webhooks_update(std::function<void(const dpp::webhooks_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMemberAdd: mC->on_guild_member_add(std::function<void(const dpp::guild_member_add_t&)>{}); break;
|
||||||
|
case DpEventID::InviteDelete: mC->on_invite_delete(std::function<void(const dpp::invite_delete_t&)>{}); break;
|
||||||
|
case DpEventID::GuildUpdate: mC->on_guild_update(std::function<void(const dpp::guild_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: mC->on_guild_integrations_update(std::function<void(const dpp::guild_integrations_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: mC->on_guild_member_update(std::function<void(const dpp::guild_member_update_t&)>{}); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: mC->on_application_command_update(std::function<void(const dpp::application_command_update_t&)>{}); break;
|
||||||
|
case DpEventID::InviteCreate: mC->on_invite_create(std::function<void(const dpp::invite_create_t&)>{}); break;
|
||||||
|
case DpEventID::MessageUpdate: mC->on_message_update(std::function<void(const dpp::message_update_t&)>{}); break;
|
||||||
|
case DpEventID::UserUpdate: mC->on_user_update(std::function<void(const dpp::user_update_t&)>{}); break;
|
||||||
|
case DpEventID::MessageCreate: mC->on_message_create(std::function<void(const dpp::message_create_t&)>{}); break;
|
||||||
|
case DpEventID::GuildBanAdd: mC->on_guild_ban_add(std::function<void(const dpp::guild_ban_add_t&)>{}); break;
|
||||||
|
case DpEventID::GuildBanRemove: mC->on_guild_ban_remove(std::function<void(const dpp::guild_ban_remove_t&)>{}); break;
|
||||||
|
case DpEventID::IntegrationCreate: mC->on_integration_create(std::function<void(const dpp::integration_create_t&)>{}); break;
|
||||||
|
case DpEventID::IntegrationUpdate: mC->on_integration_update(std::function<void(const dpp::integration_update_t&)>{}); break;
|
||||||
|
case DpEventID::IntegrationDelete: mC->on_integration_delete(std::function<void(const dpp::integration_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadCreate: mC->on_thread_create(std::function<void(const dpp::thread_create_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadUpdate: mC->on_thread_update(std::function<void(const dpp::thread_update_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadDelete: mC->on_thread_delete(std::function<void(const dpp::thread_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadListSync: mC->on_thread_list_sync(std::function<void(const dpp::thread_list_sync_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: mC->on_thread_member_update(std::function<void(const dpp::thread_member_update_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: mC->on_thread_members_update(std::function<void(const dpp::thread_members_update_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceBufferSend: mC->on_voice_buffer_send(std::function<void(const dpp::voice_buffer_send_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceUserTalking: mC->on_voice_user_talking(std::function<void(const dpp::voice_user_talking_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceReady: mC->on_voice_ready(std::function<void(const dpp::voice_ready_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceReceive: mC->on_voice_receive(std::function<void(const dpp::voice_receive_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: mC->on_voice_track_marker(std::function<void(const dpp::voice_track_marker_t&)>{}); break;
|
||||||
|
case DpEventID::StageInstanceCreate: mC->on_stage_instance_create(std::function<void(const dpp::stage_instance_create_t&)>{}); break;
|
||||||
|
case DpEventID::StageInstanceDelete: mC->on_stage_instance_delete(std::function<void(const dpp::stage_instance_delete_t&)>{}); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: STHROWF("Invalid discord event identifier {}", id);
|
||||||
|
}
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpInternalEvent::Release()
|
||||||
|
{
|
||||||
|
// Make sure we actually manage something
|
||||||
|
if (mData == 0) return;
|
||||||
|
// Fetch the type of data
|
||||||
|
const auto type = GetType();
|
||||||
|
// Fetch the data itself
|
||||||
|
const auto data = GetData();
|
||||||
|
// Identify data type
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: delete reinterpret_cast< DpVoiceStateUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::Log: delete reinterpret_cast< DpLogEvent * >(data); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: delete reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::InteractionCreate: delete reinterpret_cast< DpInteractionCreateEvent * >(data); break;
|
||||||
|
case DpEventID::ButtonClick: delete reinterpret_cast< DpButtonClickEvent * >(data); break;
|
||||||
|
case DpEventID::SelectClick: delete reinterpret_cast< DpSelectClickEvent * >(data); break;
|
||||||
|
case DpEventID::GuildDelete: delete reinterpret_cast< DpGuildDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelDelete: delete reinterpret_cast< DpChannelDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelUpdate: delete reinterpret_cast< DpChannelUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::Ready: delete reinterpret_cast< DpReadyEvent * >(data); break;
|
||||||
|
case DpEventID::MessageDelete: delete reinterpret_cast< DpMessageDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: delete reinterpret_cast< DpApplicationCommandDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMemberRemove: delete reinterpret_cast< DpGuildMemberRemoveEvent * >(data); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: delete reinterpret_cast< DpApplicationCommandCreateEvent * >(data); break;
|
||||||
|
case DpEventID::Resumed: delete reinterpret_cast< DpResumedEvent * >(data); break;
|
||||||
|
case DpEventID::GuildRoleCreate: delete reinterpret_cast< DpGuildRoleCreateEvent * >(data); break;
|
||||||
|
case DpEventID::TypingStart: delete reinterpret_cast< DpTypingStartEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionAdd: delete reinterpret_cast< DpMessageReactionAddEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMembersChunk: delete reinterpret_cast< DpGuildMembersChunkEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionRemove: delete reinterpret_cast< DpMessageReactionRemoveEvent * >(data); break;
|
||||||
|
case DpEventID::GuildCreate: delete reinterpret_cast< DpGuildCreateEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelCreate: delete reinterpret_cast< DpChannelCreateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: delete reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: delete reinterpret_cast< DpMessageDeleteBulkEvent * >(data); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: delete reinterpret_cast< DpGuildRoleUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildRoleDelete: delete reinterpret_cast< DpGuildRoleDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: delete reinterpret_cast< DpChannelPinsUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: delete reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: delete reinterpret_cast< DpVoiceServerUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: delete reinterpret_cast< DpGuildEmojisUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: delete reinterpret_cast< DpGuildStickersUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::PresenceUpdate: delete reinterpret_cast< DpPresenceUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::WebhooksUpdate: delete reinterpret_cast< DpWebhooksUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMemberAdd: delete reinterpret_cast< DpGuildMemberAddEvent * >(data); break;
|
||||||
|
case DpEventID::InviteDelete: delete reinterpret_cast< DpInviteDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::GuildUpdate: delete reinterpret_cast< DpGuildUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: delete reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: delete reinterpret_cast< DpGuildMemberUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: delete reinterpret_cast< DpApplicationCommandUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::InviteCreate: delete reinterpret_cast< DpInviteCreateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageUpdate: delete reinterpret_cast< DpMessageUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::UserUpdate: delete reinterpret_cast< DpUserUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageCreate: delete reinterpret_cast< DpMessageCreateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildBanAdd: delete reinterpret_cast< DpGuildBanAddEvent * >(data); break;
|
||||||
|
case DpEventID::GuildBanRemove: delete reinterpret_cast< DpGuildBanRemoveEvent * >(data); break;
|
||||||
|
case DpEventID::IntegrationCreate: delete reinterpret_cast< DpIntegrationCreateEvent * >(data); break;
|
||||||
|
case DpEventID::IntegrationUpdate: delete reinterpret_cast< DpIntegrationUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::IntegrationDelete: delete reinterpret_cast< DpIntegrationDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadCreate: delete reinterpret_cast< DpThreadCreateEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadUpdate: delete reinterpret_cast< DpThreadUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadDelete: delete reinterpret_cast< DpThreadDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadListSync: delete reinterpret_cast< DpThreadListSyncEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: delete reinterpret_cast< DpThreadMemberUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: delete reinterpret_cast< DpThreadMembersUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceBufferSend: delete reinterpret_cast< DpVoiceBufferSendEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceUserTalking: delete reinterpret_cast< DpVoiceUserTalkingEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceReady: delete reinterpret_cast< DpVoiceReadyEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceReceive: delete reinterpret_cast< DpVoiceReceiveEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: delete reinterpret_cast< DpVoiceTrackMarkerEvent * >(data); break;
|
||||||
|
case DpEventID::StageInstanceCreate: delete reinterpret_cast< DpStageInstanceCreateEvent * >(data); break;
|
||||||
|
case DpEventID::StageInstanceDelete: delete reinterpret_cast< DpStageInstanceDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: LogFtl("Unrecognized discord event instance type"); assert(0); break;
|
||||||
|
}
|
||||||
|
// Forget about it
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD LightObj EventToScriptObject(uint8_t type, uintptr_t data)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: return LightObj(reinterpret_cast< DpVoiceStateUpdateEvent * >(data));
|
||||||
|
case DpEventID::Log: return LightObj(reinterpret_cast< DpLogEvent * >(data));
|
||||||
|
case DpEventID::GuildJoinRequestDelete: return LightObj(reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data));
|
||||||
|
case DpEventID::InteractionCreate: return LightObj(reinterpret_cast< DpInteractionCreateEvent * >(data));
|
||||||
|
case DpEventID::ButtonClick: return LightObj(reinterpret_cast< DpButtonClickEvent * >(data));
|
||||||
|
case DpEventID::SelectClick: return LightObj(reinterpret_cast< DpSelectClickEvent * >(data));
|
||||||
|
case DpEventID::GuildDelete: return LightObj(reinterpret_cast< DpGuildDeleteEvent * >(data));
|
||||||
|
case DpEventID::ChannelDelete: return LightObj(reinterpret_cast< DpChannelDeleteEvent * >(data));
|
||||||
|
case DpEventID::ChannelUpdate: return LightObj(reinterpret_cast< DpChannelUpdateEvent * >(data));
|
||||||
|
case DpEventID::Ready: return LightObj(reinterpret_cast< DpReadyEvent * >(data));
|
||||||
|
case DpEventID::MessageDelete: return LightObj(reinterpret_cast< DpMessageDeleteEvent * >(data));
|
||||||
|
case DpEventID::ApplicationCommandDelete: return LightObj(reinterpret_cast< DpApplicationCommandDeleteEvent * >(data));
|
||||||
|
case DpEventID::GuildMemberRemove: return LightObj(reinterpret_cast< DpGuildMemberRemoveEvent * >(data));
|
||||||
|
case DpEventID::ApplicationCommandCreate: return LightObj(reinterpret_cast< DpApplicationCommandCreateEvent * >(data));
|
||||||
|
case DpEventID::Resumed: return LightObj(reinterpret_cast< DpResumedEvent * >(data));
|
||||||
|
case DpEventID::GuildRoleCreate: return LightObj(reinterpret_cast< DpGuildRoleCreateEvent * >(data));
|
||||||
|
case DpEventID::TypingStart: return LightObj(reinterpret_cast< DpTypingStartEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionAdd: return LightObj(reinterpret_cast< DpMessageReactionAddEvent * >(data));
|
||||||
|
case DpEventID::GuildMembersChunk: return LightObj(reinterpret_cast< DpGuildMembersChunkEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionRemove: return LightObj(reinterpret_cast< DpMessageReactionRemoveEvent * >(data));
|
||||||
|
case DpEventID::GuildCreate: return LightObj(reinterpret_cast< DpGuildCreateEvent * >(data));
|
||||||
|
case DpEventID::ChannelCreate: return LightObj(reinterpret_cast< DpChannelCreateEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: return LightObj(reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data));
|
||||||
|
case DpEventID::MessageDeleteBulk: return LightObj(reinterpret_cast< DpMessageDeleteBulkEvent * >(data));
|
||||||
|
case DpEventID::GuildRoleUpdate: return LightObj(reinterpret_cast< DpGuildRoleUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildRoleDelete: return LightObj(reinterpret_cast< DpGuildRoleDeleteEvent * >(data));
|
||||||
|
case DpEventID::ChannelPinsUpdate: return LightObj(reinterpret_cast< DpChannelPinsUpdateEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionRemoveAll: return LightObj(reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data));
|
||||||
|
case DpEventID::VoiceServerUpdate: return LightObj(reinterpret_cast< DpVoiceServerUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildEmojisUpdate: return LightObj(reinterpret_cast< DpGuildEmojisUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildStickersUpdate: return LightObj(reinterpret_cast< DpGuildStickersUpdateEvent * >(data));
|
||||||
|
case DpEventID::PresenceUpdate: return LightObj(reinterpret_cast< DpPresenceUpdateEvent * >(data));
|
||||||
|
case DpEventID::WebhooksUpdate: return LightObj(reinterpret_cast< DpWebhooksUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildMemberAdd: return LightObj(reinterpret_cast< DpGuildMemberAddEvent * >(data));
|
||||||
|
case DpEventID::InviteDelete: return LightObj(reinterpret_cast< DpInviteDeleteEvent * >(data));
|
||||||
|
case DpEventID::GuildUpdate: return LightObj(reinterpret_cast< DpGuildUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: return LightObj(reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildMemberUpdate: return LightObj(reinterpret_cast< DpGuildMemberUpdateEvent * >(data));
|
||||||
|
case DpEventID::ApplicationCommandUpdate: return LightObj(reinterpret_cast< DpApplicationCommandUpdateEvent * >(data));
|
||||||
|
case DpEventID::InviteCreate: return LightObj(reinterpret_cast< DpInviteCreateEvent * >(data));
|
||||||
|
case DpEventID::MessageUpdate: return LightObj(reinterpret_cast< DpMessageUpdateEvent * >(data));
|
||||||
|
case DpEventID::UserUpdate: return LightObj(reinterpret_cast< DpUserUpdateEvent * >(data));
|
||||||
|
case DpEventID::MessageCreate: return LightObj(reinterpret_cast< DpMessageCreateEvent * >(data));
|
||||||
|
case DpEventID::GuildBanAdd: return LightObj(reinterpret_cast< DpGuildBanAddEvent * >(data));
|
||||||
|
case DpEventID::GuildBanRemove: return LightObj(reinterpret_cast< DpGuildBanRemoveEvent * >(data));
|
||||||
|
case DpEventID::IntegrationCreate: return LightObj(reinterpret_cast< DpIntegrationCreateEvent * >(data));
|
||||||
|
case DpEventID::IntegrationUpdate: return LightObj(reinterpret_cast< DpIntegrationUpdateEvent * >(data));
|
||||||
|
case DpEventID::IntegrationDelete: return LightObj(reinterpret_cast< DpIntegrationDeleteEvent * >(data));
|
||||||
|
case DpEventID::ThreadCreate: return LightObj(reinterpret_cast< DpThreadCreateEvent * >(data));
|
||||||
|
case DpEventID::ThreadUpdate: return LightObj(reinterpret_cast< DpThreadUpdateEvent * >(data));
|
||||||
|
case DpEventID::ThreadDelete: return LightObj(reinterpret_cast< DpThreadDeleteEvent * >(data));
|
||||||
|
case DpEventID::ThreadListSync: return LightObj(reinterpret_cast< DpThreadListSyncEvent * >(data));
|
||||||
|
case DpEventID::ThreadMemberUpdate: return LightObj(reinterpret_cast< DpThreadMemberUpdateEvent * >(data));
|
||||||
|
case DpEventID::ThreadMembersUpdate: return LightObj(reinterpret_cast< DpThreadMembersUpdateEvent * >(data));
|
||||||
|
case DpEventID::VoiceBufferSend: return LightObj(reinterpret_cast< DpVoiceBufferSendEvent * >(data));
|
||||||
|
case DpEventID::VoiceUserTalking: return LightObj(reinterpret_cast< DpVoiceUserTalkingEvent * >(data));
|
||||||
|
case DpEventID::VoiceReady: return LightObj(reinterpret_cast< DpVoiceReadyEvent * >(data));
|
||||||
|
case DpEventID::VoiceReceive: return LightObj(reinterpret_cast< DpVoiceReceiveEvent * >(data));
|
||||||
|
case DpEventID::VoiceTrackMarker: return LightObj(reinterpret_cast< DpVoiceTrackMarkerEvent * >(data));
|
||||||
|
case DpEventID::StageInstanceCreate: return LightObj(reinterpret_cast< DpStageInstanceCreateEvent * >(data));
|
||||||
|
case DpEventID::StageInstanceDelete: return LightObj(reinterpret_cast< DpStageInstanceDeleteEvent * >(data));
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: assert(0); return LightObj{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void EventInvokeCleanup(uint8_t type, uintptr_t data)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: reinterpret_cast< DpVoiceStateUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Log: reinterpret_cast< DpLogEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::InteractionCreate: reinterpret_cast< DpInteractionCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ButtonClick: reinterpret_cast< DpButtonClickEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::SelectClick: reinterpret_cast< DpSelectClickEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildDelete: reinterpret_cast< DpGuildDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelDelete: reinterpret_cast< DpChannelDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelUpdate: reinterpret_cast< DpChannelUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Ready: reinterpret_cast< DpReadyEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageDelete: reinterpret_cast< DpMessageDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: reinterpret_cast< DpApplicationCommandDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMemberRemove: reinterpret_cast< DpGuildMemberRemoveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: reinterpret_cast< DpApplicationCommandCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Resumed: reinterpret_cast< DpResumedEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildRoleCreate: reinterpret_cast< DpGuildRoleCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::TypingStart: reinterpret_cast< DpTypingStartEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionAdd: reinterpret_cast< DpMessageReactionAddEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMembersChunk: reinterpret_cast< DpGuildMembersChunkEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionRemove: reinterpret_cast< DpMessageReactionRemoveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildCreate: reinterpret_cast< DpGuildCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelCreate: reinterpret_cast< DpChannelCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: reinterpret_cast< DpMessageDeleteBulkEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: reinterpret_cast< DpGuildRoleUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildRoleDelete: reinterpret_cast< DpGuildRoleDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: reinterpret_cast< DpChannelPinsUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: reinterpret_cast< DpVoiceServerUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: reinterpret_cast< DpGuildEmojisUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: reinterpret_cast< DpGuildStickersUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::PresenceUpdate: reinterpret_cast< DpPresenceUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::WebhooksUpdate: reinterpret_cast< DpWebhooksUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMemberAdd: reinterpret_cast< DpGuildMemberAddEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::InviteDelete: reinterpret_cast< DpInviteDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildUpdate: reinterpret_cast< DpGuildUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: reinterpret_cast< DpGuildMemberUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: reinterpret_cast< DpApplicationCommandUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::InviteCreate: reinterpret_cast< DpInviteCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageUpdate: reinterpret_cast< DpMessageUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::UserUpdate: reinterpret_cast< DpUserUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageCreate: reinterpret_cast< DpMessageCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildBanAdd: reinterpret_cast< DpGuildBanAddEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildBanRemove: reinterpret_cast< DpGuildBanRemoveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::IntegrationCreate: reinterpret_cast< DpIntegrationCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::IntegrationUpdate: reinterpret_cast< DpIntegrationUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::IntegrationDelete: reinterpret_cast< DpIntegrationDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadCreate: reinterpret_cast< DpThreadCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadUpdate: reinterpret_cast< DpThreadUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadDelete: reinterpret_cast< DpThreadDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadListSync: reinterpret_cast< DpThreadListSyncEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: reinterpret_cast< DpThreadMemberUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: reinterpret_cast< DpThreadMembersUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceBufferSend: reinterpret_cast< DpVoiceBufferSendEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceUserTalking: reinterpret_cast< DpVoiceUserTalkingEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceReady: reinterpret_cast< DpVoiceReadyEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceReceive: reinterpret_cast< DpVoiceReceiveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: reinterpret_cast< DpVoiceTrackMarkerEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::StageInstanceCreate: reinterpret_cast< DpStageInstanceCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::StageInstanceDelete: reinterpret_cast< DpStageInstanceDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: assert(0); return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
431
module/Library/DPP/Cluster.hpp
Normal file
431
module/Library/DPP/Cluster.hpp
Normal file
@ -0,0 +1,431 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
#include "Core/Signal.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Other.hpp"
|
||||||
|
#include "Library/DPP/Constants.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <concurrentqueue.h>
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Internal event proxy.
|
||||||
|
*/
|
||||||
|
struct DpInternalEvent
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event data.
|
||||||
|
*/
|
||||||
|
uint64_t mData{0llu};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpInternalEvent() noexcept = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpInternalEvent(uint64_t type, void * data) noexcept
|
||||||
|
: mData((type << 56u) | reinterpret_cast< uint64_t >(data))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpInternalEvent(const DpInternalEvent & o) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpInternalEvent(DpInternalEvent && o) noexcept
|
||||||
|
: mData(o.mData)
|
||||||
|
{
|
||||||
|
o.mData = 0llu; // Take ownership
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpInternalEvent()
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpInternalEvent & operator = (const DpInternalEvent & o) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpInternalEvent & operator = (DpInternalEvent && o) noexcept
|
||||||
|
{
|
||||||
|
if (mData != o.mData)
|
||||||
|
{
|
||||||
|
// Release current information
|
||||||
|
Release();
|
||||||
|
// Replicate members
|
||||||
|
mData = o.mData;
|
||||||
|
// Take ownership
|
||||||
|
o.mData = 0llu;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Forget about the managed event data.
|
||||||
|
*/
|
||||||
|
void Reset() noexcept
|
||||||
|
{
|
||||||
|
mData = 0llu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the event type.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD uint8_t GetType() const noexcept
|
||||||
|
{
|
||||||
|
return static_cast< uint8_t >((mData >> 56u) & 0xFFllu);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the event data.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD uintptr_t GetData() const noexcept
|
||||||
|
{
|
||||||
|
return static_cast< uintptr_t >((~(0xFFllu << 56u)) & mData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release associated event data, if any.
|
||||||
|
*/
|
||||||
|
void Release();
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* The cluster class represents a group of shards and a command queue for sending and receiving
|
||||||
|
* commands from discord via HTTP.
|
||||||
|
*/
|
||||||
|
struct DpCluster : public SqChainedInstances< DpCluster >
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Queue of events generated from other threads.
|
||||||
|
*/
|
||||||
|
using EventQueue = moodycamel::ConcurrentQueue< DpInternalEvent >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Managed cluster instance.
|
||||||
|
*/
|
||||||
|
std::unique_ptr< dpp::cluster > mC{nullptr};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event queue.
|
||||||
|
*/
|
||||||
|
EventQueue mQueue{4096};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpCluster(StackStrF & token)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr()))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters, bool compressed)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters), compressed))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters, bool compressed, const DpCachePolicy & cp)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters), compressed, cp.ToNative()))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpCluster()
|
||||||
|
{
|
||||||
|
DropEvents();
|
||||||
|
// Forget about this instance
|
||||||
|
UnchainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Start the cluster, connecting all its shards. Returns once all shards are connected.
|
||||||
|
*/
|
||||||
|
DpCluster & Start()
|
||||||
|
{
|
||||||
|
LogInf("Before start...");
|
||||||
|
mC->start(true);
|
||||||
|
LogInf("After start...");
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Log a message to whatever log the user is using.
|
||||||
|
*/
|
||||||
|
DpCluster & Log(SQInteger severity, StackStrF & message)
|
||||||
|
{
|
||||||
|
mC->log(static_cast< dpp::loglevel >(severity), message.ToStr());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Get the dm channel for a user id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetDmChannel(dpp::snowflake user_id) const
|
||||||
|
{
|
||||||
|
return mC->get_dm_channel(static_cast< dpp::snowflake >(user_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set the dm channel id for a user id.
|
||||||
|
*/
|
||||||
|
DpCluster & SetDmChannel(dpp::snowflake user_id, dpp::snowflake channel_id)
|
||||||
|
{
|
||||||
|
mC->set_dm_channel(user_id, channel_id);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Returns the uptime of the cluster.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::utility::uptime UpTime() const
|
||||||
|
{
|
||||||
|
return mC->uptime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Returns the uptime of the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & SetPresence(const DpPresence & p)
|
||||||
|
{
|
||||||
|
mC->set_presence(p.Valid());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
LightObj mSqEvents{}; // Table containing the emitted cluster events.
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the events table of this cluster.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetEvents()
|
||||||
|
{
|
||||||
|
return mSqEvents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Cluster signals.
|
||||||
|
*/
|
||||||
|
std::array< SignalPair, static_cast< size_t >(DpEventID::Max) > mEvents{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Process the cluster.
|
||||||
|
*/
|
||||||
|
void Process(bool force = false);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Terminate the cluster.
|
||||||
|
*/
|
||||||
|
void Terminate()
|
||||||
|
{
|
||||||
|
// Delete the cluster instance
|
||||||
|
mC.reset();
|
||||||
|
// Release associated script objects
|
||||||
|
mSqEvents.Release();
|
||||||
|
// Release event signal objects
|
||||||
|
DropEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Enable a certain event for the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & EnableEvent(SQInteger id);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Disable a certain event for the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & DisableEvent(SQInteger id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Initialize the cluster.
|
||||||
|
*/
|
||||||
|
void Initialize()
|
||||||
|
{
|
||||||
|
InitEvents();
|
||||||
|
// Remember this instance
|
||||||
|
ChainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Signal initialization.
|
||||||
|
*/
|
||||||
|
void InitEvents()
|
||||||
|
{
|
||||||
|
// Ignore the call if already initialized
|
||||||
|
if (!mSqEvents.IsNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Create a new table on the stack
|
||||||
|
sq_newtableex(SqVM(), 64);
|
||||||
|
// Grab the table object from the stack
|
||||||
|
mSqEvents = LightObj(-1, SqVM());
|
||||||
|
// Pop the table object from the stack
|
||||||
|
sq_pop(SqVM(), 1);
|
||||||
|
// Proceed to initializing the events
|
||||||
|
for (size_t i = 0; i < mEvents.size(); ++i)
|
||||||
|
{
|
||||||
|
InitSignalPair(mEvents[i], mSqEvents, DpEventID::NAME[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Signal termination.
|
||||||
|
*/
|
||||||
|
void DropEvents()
|
||||||
|
{
|
||||||
|
for (auto & e : mEvents)
|
||||||
|
{
|
||||||
|
ResetSignalPair(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event handlers.
|
||||||
|
*/
|
||||||
|
void OnVoiceStateUpdate(const dpp::voice_state_update_t & ev);
|
||||||
|
void OnLog(const dpp::log_t & ev);
|
||||||
|
void OnGuildJoinRequestDelete(const dpp::guild_join_request_delete_t & ev);
|
||||||
|
void OnInteractionCreate(const dpp::interaction_create_t & ev);
|
||||||
|
void OnButtonClick(const dpp::button_click_t & ev);
|
||||||
|
void OnSelectClick(const dpp::select_click_t & ev);
|
||||||
|
void OnGuildDelete(const dpp::guild_delete_t & ev);
|
||||||
|
void OnChannelDelete(const dpp::channel_delete_t & ev);
|
||||||
|
void OnChannelUpdate(const dpp::channel_update_t & ev);
|
||||||
|
void OnReady(const dpp::ready_t & ev);
|
||||||
|
void OnMessageDelete(const dpp::message_delete_t & ev);
|
||||||
|
void OnApplicationCommandDelete(const dpp::application_command_delete_t & ev);
|
||||||
|
void OnGuildMemberRemove(const dpp::guild_member_remove_t & ev);
|
||||||
|
void OnApplicationCommandCreate(const dpp::application_command_create_t & ev);
|
||||||
|
void OnResumed(const dpp::resumed_t & ev);
|
||||||
|
void OnGuildRoleCreate(const dpp::guild_role_create_t & ev);
|
||||||
|
void OnTypingStart(const dpp::typing_start_t & ev);
|
||||||
|
void OnMessageReactionAdd(const dpp::message_reaction_add_t & ev);
|
||||||
|
void OnGuildMembersChunk(const dpp::guild_members_chunk_t & ev);
|
||||||
|
void OnMessageReactionRemove(const dpp::message_reaction_remove_t & ev);
|
||||||
|
void OnGuildCreate(const dpp::guild_create_t & ev);
|
||||||
|
void OnChannelCreate(const dpp::channel_create_t & ev);
|
||||||
|
void OnMessageReactionRemoveEmoji(const dpp::message_reaction_remove_emoji_t & ev);
|
||||||
|
void OnMessageDeleteBulk(const dpp::message_delete_bulk_t & ev);
|
||||||
|
void OnGuildRoleUpdate(const dpp::guild_role_update_t & ev);
|
||||||
|
void OnGuildRoleDelete(const dpp::guild_role_delete_t & ev);
|
||||||
|
void OnChannelPinsUpdate(const dpp::channel_pins_update_t & ev);
|
||||||
|
void OnMessageReactionRemoveAll(const dpp::message_reaction_remove_all_t & ev);
|
||||||
|
void OnVoiceServerUpdate(const dpp::voice_server_update_t & ev);
|
||||||
|
void OnGuildEmojisUpdate(const dpp::guild_emojis_update_t & ev);
|
||||||
|
void OnGuildStickersUpdate(const dpp::guild_stickers_update_t & ev);
|
||||||
|
void OnPresenceUpdate(const dpp::presence_update_t & ev);
|
||||||
|
void OnWebhooksUpdate(const dpp::webhooks_update_t & ev);
|
||||||
|
void OnGuildMemberAdd(const dpp::guild_member_add_t & ev);
|
||||||
|
void OnInviteDelete(const dpp::invite_delete_t & ev);
|
||||||
|
void OnGuildUpdate(const dpp::guild_update_t & ev);
|
||||||
|
void OnGuildIntegrationsUpdate(const dpp::guild_integrations_update_t & ev);
|
||||||
|
void OnGuildMemberUpdate(const dpp::guild_member_update_t & ev);
|
||||||
|
void OnApplicationCommandUpdate(const dpp::application_command_update_t & ev);
|
||||||
|
void OnInviteCreate(const dpp::invite_create_t & ev);
|
||||||
|
void OnMessageUpdate(const dpp::message_update_t & ev);
|
||||||
|
void OnUserUpdate(const dpp::user_update_t & ev);
|
||||||
|
void OnMessageCreate(const dpp::message_create_t & ev);
|
||||||
|
void OnGuildBanAdd(const dpp::guild_ban_add_t & ev);
|
||||||
|
void OnGuildBanRemove(const dpp::guild_ban_remove_t & ev);
|
||||||
|
void OnIntegrationCreate(const dpp::integration_create_t & ev);
|
||||||
|
void OnIntegrationUpdate(const dpp::integration_update_t & ev);
|
||||||
|
void OnIntegrationDelete(const dpp::integration_delete_t & ev);
|
||||||
|
void OnThreadCreate(const dpp::thread_create_t & ev);
|
||||||
|
void OnThreadUpdate(const dpp::thread_update_t & ev);
|
||||||
|
void OnThreadDelete(const dpp::thread_delete_t & ev);
|
||||||
|
void OnThreadListSync(const dpp::thread_list_sync_t & ev);
|
||||||
|
void OnThreadMemberUpdate(const dpp::thread_member_update_t & ev);
|
||||||
|
void OnThreadMembersUpdate(const dpp::thread_members_update_t & ev);
|
||||||
|
void OnVoiceBufferSend(const dpp::voice_buffer_send_t & ev);
|
||||||
|
void OnVoiceUserTalking(const dpp::voice_user_talking_t & ev);
|
||||||
|
void OnVoiceReady(const dpp::voice_ready_t & ev);
|
||||||
|
void OnVoiceReceive(const dpp::voice_receive_t & ev);
|
||||||
|
void OnVoiceTrackMarker(const dpp::voice_track_marker_t & ev);
|
||||||
|
void OnStageInstanceCreate(const dpp::stage_instance_create_t & ev);
|
||||||
|
void OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
16
module/Library/DPP/Command.cpp
Normal file
16
module/Library/DPP/Command.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Command.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Command(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
19
module/Library/DPP/Command.hpp
Normal file
19
module/Library/DPP/Command.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
@ -1,5 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/DPPTy.hpp"
|
#include "Library/DPP/Constants.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <sqratConst.h>
|
#include <sqratConst.h>
|
||||||
@ -8,326 +8,69 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQMOD_DECL_TYPENAME(SqDppCachePolicy, _SC("SqDppCachePolicy"))
|
const std::array< const char *, static_cast< size_t >(DpEventID::Max) > DpEventID::NAME{
|
||||||
SQMOD_DECL_TYPENAME(SqDppIconHash, _SC("SqDppIconHash"))
|
"VoiceStateUpdate",
|
||||||
SQMOD_DECL_TYPENAME(SqDppUptime, _SC("SqDppUptime"))
|
"Log",
|
||||||
SQMOD_DECL_TYPENAME(SqDppActivity, _SC("SqDppActivity"))
|
"GuildJoinRequestDelete",
|
||||||
SQMOD_DECL_TYPENAME(SqDppPresence, _SC("SqDppPresence"))
|
"InteractionCreate",
|
||||||
SQMOD_DECL_TYPENAME(SqDppVoiceState, _SC("SqDppVoiceState"))
|
"ButtonClick",
|
||||||
SQMOD_DECL_TYPENAME(SqDppRole, _SC("SqDppRole"))
|
"SelectClick",
|
||||||
SQMOD_DECL_TYPENAME(SqDppUser, _SC("SqDppUser"))
|
"GuildDelete",
|
||||||
SQMOD_DECL_TYPENAME(SqDppGuildMember, _SC("SqDppGuildMember"))
|
"ChannelDelete",
|
||||||
SQMOD_DECL_TYPENAME(SqDppGuild, _SC("SqDppGuild"))
|
"ChannelUpdate",
|
||||||
|
"Ready",
|
||||||
// ------------------------------------------------------------------------------------------------
|
"MessageDelete",
|
||||||
void Register_DPPConst(HSQUIRRELVM vm, Table & ns);
|
"ApplicationCommandDelete",
|
||||||
|
"GuildMemberRemove",
|
||||||
// ------------------------------------------------------------------------------------------------
|
"ApplicationCommandCreate",
|
||||||
void Register_DPPTy(HSQUIRRELVM vm, Table & ns)
|
"Resumed",
|
||||||
{
|
"GuildRoleCreate",
|
||||||
Register_DPPConst(vm, ns);
|
"TypingStart",
|
||||||
// --------------------------------------------------------------------------------------------
|
"MessageReactionAdd",
|
||||||
ns.Bind(_SC("Uptime"),
|
"GuildMembersChunk",
|
||||||
Class< dpp::utility::uptime >(vm, SqDppUptime::Str)
|
"MessageReactionRemove",
|
||||||
// Constructors
|
"GuildCreate",
|
||||||
.Ctor()
|
"ChannelCreate",
|
||||||
// Meta-methods
|
"MessageReactionRemoveEmoji",
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppUptime::Fn)
|
"MessageDeleteBulk",
|
||||||
.Func(_SC("_tostring"), &dpp::utility::uptime::to_string)
|
"GuildRoleUpdate",
|
||||||
// Member Variables
|
"GuildRoleDelete",
|
||||||
.Var(_SC("Days"), &dpp::utility::uptime::days)
|
"ChannelPinsUpdate",
|
||||||
.Var(_SC("Hours"), &dpp::utility::uptime::hours)
|
"MessageReactionRemoveAll",
|
||||||
.Var(_SC("Minutes"), &dpp::utility::uptime::mins)
|
"VoiceServerUpdate",
|
||||||
.Var(_SC("Seconds"), &dpp::utility::uptime::secs)
|
"GuildEmojisUpdate",
|
||||||
// Member Methods
|
"GuildStickersUpdate",
|
||||||
.Func(_SC("ToSeconds"), &dpp::utility::uptime::to_secs)
|
"PresenceUpdate",
|
||||||
.Func(_SC("ToMilliseconds"), &dpp::utility::uptime::to_msecs)
|
"WebhooksUpdate",
|
||||||
);
|
"GuildMemberAdd",
|
||||||
// --------------------------------------------------------------------------------------------
|
"InviteDelete",
|
||||||
ns.Bind(_SC("IconHash"),
|
"GuildUpdate",
|
||||||
Class< dpp::utility::iconhash >(vm, SqDppIconHash::Str)
|
"GuildIntegrationsUpdate",
|
||||||
// Constructors
|
"GuildMemberUpdate",
|
||||||
.Ctor()
|
"ApplicationCommandUpdate",
|
||||||
.Ctor< const std::string & >()
|
"InviteCreate",
|
||||||
// Meta-methods
|
"MessageUpdate",
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppIconHash::Fn)
|
"UserUpdate",
|
||||||
.Func(_SC("_tostring"), &dpp::utility::iconhash::to_string)
|
"MessageCreate",
|
||||||
// Member Variables
|
"GuildBanAdd",
|
||||||
.Var(_SC("High"), &dpp::utility::iconhash::first)
|
"GuildBanRemove",
|
||||||
.Var(_SC("Low"), &dpp::utility::iconhash::second)
|
"IntegrationCreate",
|
||||||
// Member Methods
|
"IntegrationUpdate",
|
||||||
.Func(_SC("Set"), &dpp::utility::iconhash::set)
|
"IntegrationDelete",
|
||||||
);
|
"ThreadCreate",
|
||||||
// --------------------------------------------------------------------------------------------
|
"ThreadUpdate",
|
||||||
ns.Bind(_SC("CachePolicy"),
|
"ThreadDelete",
|
||||||
Class< DpCachePolicy >(vm, SqDppCachePolicy::Str)
|
"ThreadListSync",
|
||||||
// Constructors
|
"ThreadMemberUpdate",
|
||||||
.Ctor()
|
"ThreadMembersUpdate",
|
||||||
.Ctor< SQInteger >()
|
"VoiceBufferSend",
|
||||||
.Ctor< SQInteger, SQInteger >()
|
"VoiceUserTalking",
|
||||||
.Ctor< SQInteger, SQInteger, SQInteger >()
|
"VoiceReady",
|
||||||
// Meta-methods
|
"VoiceReceive",
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppCachePolicy::Fn)
|
"VoiceTrackMarker",
|
||||||
// Member Variables
|
"StageInstanceCreate",
|
||||||
.Var(_SC("UserPolicy"), &DpCachePolicy::mUserPolicy)
|
"StageInstanceDelete"
|
||||||
.Var(_SC("EmojiPolicy"), &DpCachePolicy::mEmojiPolicy)
|
};
|
||||||
.Var(_SC("RolePolicy"), &DpCachePolicy::mRolePolicy)
|
|
||||||
);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ns.Bind(_SC("Activity"),
|
|
||||||
Class< DpActivity, NoCopy< DpActivity > >(vm, SqDppActivity::Str)
|
|
||||||
// Constructors
|
|
||||||
.Ctor()
|
|
||||||
.Ctor< SQInteger, StackStrF &, StackStrF &, StackStrF & >()
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppActivity::Fn)
|
|
||||||
// Member Properties
|
|
||||||
.Prop(_SC("Name"), &DpActivity::GetName, &DpActivity::SetName)
|
|
||||||
.Prop(_SC("State"), &DpActivity::GetState, &DpActivity::SetState)
|
|
||||||
.Prop(_SC("URL"), &DpActivity::GetURL, &DpActivity::SetURL)
|
|
||||||
.Prop(_SC("Type"), &DpActivity::GetType, &DpActivity::SetType)
|
|
||||||
.Prop(_SC("CreatedAt"), &DpActivity::GetCreatedAt, &DpActivity::SetCreatedAt)
|
|
||||||
.Prop(_SC("Start"), &DpActivity::GetStart, &DpActivity::SetStart)
|
|
||||||
.Prop(_SC("End"), &DpActivity::GetEnd, &DpActivity::SetEnd)
|
|
||||||
// Member Methods
|
|
||||||
.Func(_SC("SetName"), &DpActivity::ApplyName)
|
|
||||||
.Func(_SC("SetState"), &DpActivity::ApplyState)
|
|
||||||
.Func(_SC("SetURL"), &DpActivity::ApplyURL)
|
|
||||||
.Func(_SC("SetType"), &DpActivity::ApplyType)
|
|
||||||
.Func(_SC("SetCreatedAt"), &DpActivity::ApplyCreatedAt)
|
|
||||||
.Func(_SC("SetStart"), &DpActivity::ApplyStart)
|
|
||||||
.Func(_SC("SetEnd"), &DpActivity::ApplyEnd)
|
|
||||||
);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ns.Bind(_SC("Presence"),
|
|
||||||
Class< DpPresence, NoCopy< DpPresence > >(vm, SqDppPresence::Str)
|
|
||||||
// Constructors
|
|
||||||
.Ctor()
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppPresence::Fn)
|
|
||||||
// Member Properties
|
|
||||||
.Prop(_SC("Valid"), &DpPresence::IsValid)
|
|
||||||
.Prop(_SC("UserID"), &DpPresence::GetUserID, &DpPresence::SetUserID)
|
|
||||||
.Prop(_SC("GuildID"), &DpPresence::GetGuildID, &DpPresence::SetGuildID)
|
|
||||||
.Prop(_SC("Flags"), &DpPresence::GetFlags, &DpPresence::SetFlags)
|
|
||||||
.Prop(_SC("ActivityCount"), &DpPresence::ActivityCount)
|
|
||||||
.Prop(_SC("DesktopStatus"), &DpPresence::GetDesktopStatus)
|
|
||||||
.Prop(_SC("WebStatus"), &DpPresence::GetWebStatus)
|
|
||||||
.Prop(_SC("MobileStatus"), &DpPresence::GetMobileStatus)
|
|
||||||
.Prop(_SC("Status"), &DpPresence::GetStatus)
|
|
||||||
// Member Methods
|
|
||||||
.Func(_SC("SetUserID"), &DpPresence::ApplyUserID)
|
|
||||||
.Func(_SC("SetGuildID"), &DpPresence::ApplyGuildID)
|
|
||||||
.Func(_SC("SetFlags"), &DpPresence::ApplyFlags)
|
|
||||||
.Func(_SC("AddActivity"), &DpPresence::AddActivity)
|
|
||||||
.Func(_SC("EachActivity"), &DpPresence::EachActivity)
|
|
||||||
.Func(_SC("ClearActivities"), &DpPresence::ClearActivities)
|
|
||||||
.Func(_SC("FilterActivities"), &DpPresence::FilterActivities)
|
|
||||||
.Func(_SC("BuildJSON"), &DpPresence::BuildJSON)
|
|
||||||
);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ns.Bind(_SC("VoiceState"),
|
|
||||||
Class< DpVoiceState, NoConstructor< DpVoiceState > >(vm, SqDppVoiceState::Str)
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppVoiceState::Fn)
|
|
||||||
.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("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("IsSupressed"), &DpVoiceState::IsSupressed)
|
|
||||||
);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ns.Bind(_SC("Role"),
|
|
||||||
Class< DpRole, NoConstructor< DpRole > >(vm, SqDppRole::Str)
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppRole::Fn)
|
|
||||||
.Func(_SC("_tojson"), &DpRole::BuildJSON)
|
|
||||||
// Member Properties
|
|
||||||
.Prop(_SC("Valid"), &DpRole::IsValid)
|
|
||||||
.Prop(_SC("JSON"), &DpRole::BuildJSON)
|
|
||||||
.Prop(_SC("Name"), &DpRole::GetName)
|
|
||||||
.Prop(_SC("GuildID"), &DpRole::GetGuildID)
|
|
||||||
.Prop(_SC("Color"), &DpRole::GetColour)
|
|
||||||
.Prop(_SC("Colour"), &DpRole::GetColour)
|
|
||||||
.Prop(_SC("Position"), &DpRole::GetPosition)
|
|
||||||
.Prop(_SC("Permissions"), &DpRole::GetPermissions)
|
|
||||||
.Prop(_SC("Flags"), &DpRole::GetFlags)
|
|
||||||
.Prop(_SC("IntegrationID"), &DpRole::GetIntegrationID)
|
|
||||||
.Prop(_SC("BotID"), &DpRole::GetBotID)
|
|
||||||
.Prop(_SC("IsHoisted"), &DpRole::IsHoisted)
|
|
||||||
.Prop(_SC("IsMentionable"), &DpRole::IsMentionable)
|
|
||||||
.Prop(_SC("IsManaged"), &DpRole::IsManaged)
|
|
||||||
.Prop(_SC("CanCreateInstantInvite"), &DpRole::CanCreateInstantInvite)
|
|
||||||
.Prop(_SC("CanKickMembers"), &DpRole::CanKickMembers)
|
|
||||||
.Prop(_SC("CanBanMembers"), &DpRole::CanBanMembers)
|
|
||||||
.Prop(_SC("IsAdministrator"), &DpRole::IsAdministrator)
|
|
||||||
.Prop(_SC("CanManageChannels"), &DpRole::CanManageChannels)
|
|
||||||
.Prop(_SC("CanManageGuild"), &DpRole::CanManageGuild)
|
|
||||||
.Prop(_SC("CanAddReactions"), &DpRole::CanAddReactions)
|
|
||||||
.Prop(_SC("CanViewAuditLog"), &DpRole::CanViewAuditLog)
|
|
||||||
.Prop(_SC("IsPrioritySpeaker"), &DpRole::IsPrioritySpeaker)
|
|
||||||
.Prop(_SC("CanStream"), &DpRole::CanStream)
|
|
||||||
.Prop(_SC("CanViewChannel"), &DpRole::CanViewChannel)
|
|
||||||
.Prop(_SC("CanSendMessages"), &DpRole::CanSendMessages)
|
|
||||||
.Prop(_SC("CanSendTtsMessages"), &DpRole::CanSendTtsMessages)
|
|
||||||
.Prop(_SC("CanManageMessages"), &DpRole::CanManageMessages)
|
|
||||||
.Prop(_SC("CanEmbedLinks"), &DpRole::CanEmbedLinks)
|
|
||||||
.Prop(_SC("CanAttachFiles"), &DpRole::CanAttachFiles)
|
|
||||||
.Prop(_SC("CanReadMessageHistory"), &DpRole::CanReadMessageHistory)
|
|
||||||
.Prop(_SC("CanMentionEveryone"), &DpRole::CanMentionEveryone)
|
|
||||||
.Prop(_SC("CanUseExternalEmojis"), &DpRole::CanUseExternalEmojis)
|
|
||||||
.Prop(_SC("CanViewGuildInsights"), &DpRole::CanViewGuildInsights)
|
|
||||||
.Prop(_SC("CanConnect"), &DpRole::CanConnect)
|
|
||||||
.Prop(_SC("CanSpeak"), &DpRole::CanSpeak)
|
|
||||||
.Prop(_SC("CanMuteMembers"), &DpRole::CanMuteMembers)
|
|
||||||
.Prop(_SC("CanDeafenMembers"), &DpRole::CanDeafenMembers)
|
|
||||||
.Prop(_SC("CanMoveMembers"), &DpRole::CanMoveMembers)
|
|
||||||
.Prop(_SC("CanUseVAT"), &DpRole::CanUseVAT)
|
|
||||||
.Prop(_SC("CanChangeNickname"), &DpRole::CanChangeNickname)
|
|
||||||
.Prop(_SC("CanManageNicknames"), &DpRole::CanManageNicknames)
|
|
||||||
.Prop(_SC("CanManageRoles"), &DpRole::CanManageRoles)
|
|
||||||
.Prop(_SC("CanManageWebhooks"), &DpRole::CanManageWebhooks)
|
|
||||||
.Prop(_SC("CanManageEmojis"), &DpRole::CanManageEmojis)
|
|
||||||
.Prop(_SC("CanUseSlashCommands"), &DpRole::CanUseSlashCommands)
|
|
||||||
.Prop(_SC("HasRequestToSpeak"), &DpRole::HasRequestToSpeak)
|
|
||||||
.Prop(_SC("CanManageThreads"), &DpRole::CanManageThreads)
|
|
||||||
.Prop(_SC("HasUsePublicThreads"), &DpRole::HasUsePublicThreads)
|
|
||||||
.Prop(_SC("HasUsePrivateThreads"), &DpRole::HasUsePrivateThreads)
|
|
||||||
// Member Methods
|
|
||||||
.Func(_SC("BuildJSON"), &DpRole::BuildJSON_)
|
|
||||||
);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ns.Bind(_SC("User"),
|
|
||||||
Class< DpUser, NoConstructor< DpUser > >(vm, SqDppUser::Str)
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppUser::Fn)
|
|
||||||
// Member Properties
|
|
||||||
.Prop(_SC("Valid"), &DpUser::IsValid)
|
|
||||||
.Prop(_SC("Username"), &DpUser::GetUsername)
|
|
||||||
.Prop(_SC("Discriminator"), &DpUser::GetDiscriminator)
|
|
||||||
.Prop(_SC("Avatar"), &DpUser::GetAvatar)
|
|
||||||
.Prop(_SC("Flags"), &DpUser::GetFlags)
|
|
||||||
.Prop(_SC("RefCount"), &DpUser::GetRefCount)
|
|
||||||
.Prop(_SC("AvatarURL"), &DpUser::GetAvatarURL)
|
|
||||||
.Prop(_SC("IsBot"), &DpUser::IsBot)
|
|
||||||
.Prop(_SC("IsSystem"), &DpUser::IsSystem)
|
|
||||||
.Prop(_SC("IsMfaEnabled"), &DpUser::IsMfaEnabled)
|
|
||||||
.Prop(_SC("IsVerified"), &DpUser::IsVerified)
|
|
||||||
.Prop(_SC("HasNitroFull"), &DpUser::HasNitroFull)
|
|
||||||
.Prop(_SC("HasNitroClassic"), &DpUser::HasNitroClassic)
|
|
||||||
.Prop(_SC("IsDiscordEmployee"), &DpUser::IsDiscordEmployee)
|
|
||||||
.Prop(_SC("IsPartneredOwner"), &DpUser::IsPartneredOwner)
|
|
||||||
.Prop(_SC("HasHypesquadEvents"), &DpUser::HasHypesquadEvents)
|
|
||||||
.Prop(_SC("IsBughunter1"), &DpUser::IsBughunter1)
|
|
||||||
.Prop(_SC("IsHouseBravery"), &DpUser::IsHouseBravery)
|
|
||||||
.Prop(_SC("IsHouseBrilliance"), &DpUser::IsHouseBrilliance)
|
|
||||||
.Prop(_SC("IsHouseBalanace"), &DpUser::IsHouseBalanace)
|
|
||||||
.Prop(_SC("IsEarlySupporter"), &DpUser::IsEarlySupporter)
|
|
||||||
.Prop(_SC("IsTeamUser"), &DpUser::IsTeamUser)
|
|
||||||
.Prop(_SC("IsBughunter2"), &DpUser::IsBughunter2)
|
|
||||||
.Prop(_SC("IsVerifiedBot"), &DpUser::IsVerifiedBot)
|
|
||||||
.Prop(_SC("IsVerifiedBotDev"), &DpUser::IsVerifiedBotDev)
|
|
||||||
.Prop(_SC("IsCertifiedDoderator"), &DpUser::IsCertifiedDoderator)
|
|
||||||
.Prop(_SC("HasAnimatedIcon"), &DpUser::HasAnimatedIcon)
|
|
||||||
);
|
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static const EnumElement g_DpLogLevelEnum[] = {
|
static const EnumElement g_DpLogLevelEnum[] = {
|
||||||
@ -595,9 +338,18 @@ static const EnumElements g_EnumList[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Register_DPPConst(HSQUIRRELVM vm, Table &)
|
void Register_DPP_Constants(HSQUIRRELVM vm, Table & ns)
|
||||||
{
|
{
|
||||||
RegisterEnumerations(vm, g_EnumList);
|
RegisterEnumerations(vm, g_EnumList);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Enumeration e(vm);
|
||||||
|
// Bind all events using their associated name
|
||||||
|
for (SQInteger i = 0; i < static_cast< SQInteger >(DpEventID::Max); ++i)
|
||||||
|
{
|
||||||
|
e.Const(DpEventID::NAME[i], i);
|
||||||
|
}
|
||||||
|
// Expose the constants
|
||||||
|
ConstTable(vm).Enum(_SC("SqDiscordEvent"), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
91
module/Library/DPP/Constants.hpp
Normal file
91
module/Library/DPP/Constants.hpp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Unique ID for each event.
|
||||||
|
*/
|
||||||
|
struct DpEventID
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* ID enumeration.
|
||||||
|
*/
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
VoiceStateUpdate=0,
|
||||||
|
Log,
|
||||||
|
GuildJoinRequestDelete,
|
||||||
|
InteractionCreate,
|
||||||
|
ButtonClick,
|
||||||
|
SelectClick,
|
||||||
|
GuildDelete,
|
||||||
|
ChannelDelete,
|
||||||
|
ChannelUpdate,
|
||||||
|
Ready,
|
||||||
|
MessageDelete,
|
||||||
|
ApplicationCommandDelete,
|
||||||
|
GuildMemberRemove,
|
||||||
|
ApplicationCommandCreate,
|
||||||
|
Resumed,
|
||||||
|
GuildRoleCreate,
|
||||||
|
TypingStart,
|
||||||
|
MessageReactionAdd,
|
||||||
|
GuildMembersChunk,
|
||||||
|
MessageReactionRemove,
|
||||||
|
GuildCreate,
|
||||||
|
ChannelCreate,
|
||||||
|
MessageReactionRemoveEmoji,
|
||||||
|
MessageDeleteBulk,
|
||||||
|
GuildRoleUpdate,
|
||||||
|
GuildRoleDelete,
|
||||||
|
ChannelPinsUpdate,
|
||||||
|
MessageReactionRemoveAll,
|
||||||
|
VoiceServerUpdate,
|
||||||
|
GuildEmojisUpdate,
|
||||||
|
GuildStickersUpdate,
|
||||||
|
PresenceUpdate,
|
||||||
|
WebhooksUpdate,
|
||||||
|
GuildMemberAdd,
|
||||||
|
InviteDelete,
|
||||||
|
GuildUpdate,
|
||||||
|
GuildIntegrationsUpdate,
|
||||||
|
GuildMemberUpdate,
|
||||||
|
ApplicationCommandUpdate,
|
||||||
|
InviteCreate,
|
||||||
|
MessageUpdate,
|
||||||
|
UserUpdate,
|
||||||
|
MessageCreate,
|
||||||
|
GuildBanAdd,
|
||||||
|
GuildBanRemove,
|
||||||
|
IntegrationCreate,
|
||||||
|
IntegrationUpdate,
|
||||||
|
IntegrationDelete,
|
||||||
|
ThreadCreate,
|
||||||
|
ThreadUpdate,
|
||||||
|
ThreadDelete,
|
||||||
|
ThreadListSync,
|
||||||
|
ThreadMemberUpdate,
|
||||||
|
ThreadMembersUpdate,
|
||||||
|
VoiceBufferSend,
|
||||||
|
VoiceUserTalking,
|
||||||
|
VoiceReady,
|
||||||
|
VoiceReceive,
|
||||||
|
VoiceTrackMarker,
|
||||||
|
StageInstanceCreate,
|
||||||
|
StageInstanceDelete,
|
||||||
|
Max
|
||||||
|
};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* String identification for each event ID.
|
||||||
|
*/
|
||||||
|
static const std::array< const char *, static_cast< size_t >(Max) > NAME;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
@ -1,11 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/DPPEv.hpp"
|
#include "Library/DPP/Events.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include <sqratConst.h>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
@ -74,72 +68,7 @@ SQMOD_DECL_TYPENAME(SqDppStageInstanceCreateEvent, _SC("SqDppStageInstanceCreate
|
|||||||
SQMOD_DECL_TYPENAME(SqDppStageInstanceDeleteEvent, _SC("SqDppStageInstanceDeleteEvent"))
|
SQMOD_DECL_TYPENAME(SqDppStageInstanceDeleteEvent, _SC("SqDppStageInstanceDeleteEvent"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
const std::array< const char *, static_cast< size_t >(DpEventID::Max) > DpEventID::NAME{
|
void Register_DPP_Events(HSQUIRRELVM vm, Table & ns)
|
||||||
"VoiceStateUpdate",
|
|
||||||
"Log",
|
|
||||||
"GuildJoinRequestDelete",
|
|
||||||
"InteractionCreate",
|
|
||||||
"ButtonClick",
|
|
||||||
"SelectClick",
|
|
||||||
"GuildDelete",
|
|
||||||
"ChannelDelete",
|
|
||||||
"ChannelUpdate",
|
|
||||||
"Ready",
|
|
||||||
"MessageDelete",
|
|
||||||
"ApplicationCommandDelete",
|
|
||||||
"GuildMemberRemove",
|
|
||||||
"ApplicationCommandCreate",
|
|
||||||
"Resumed",
|
|
||||||
"GuildRoleCreate",
|
|
||||||
"TypingStart",
|
|
||||||
"MessageReactionAdd",
|
|
||||||
"GuildMembersChunk",
|
|
||||||
"MessageReactionRemove",
|
|
||||||
"GuildCreate",
|
|
||||||
"ChannelCreate",
|
|
||||||
"MessageReactionRemoveEmoji",
|
|
||||||
"MessageDeleteBulk",
|
|
||||||
"GuildRoleUpdate",
|
|
||||||
"GuildRoleDelete",
|
|
||||||
"ChannelPinsUpdate",
|
|
||||||
"MessageReactionRemoveAll",
|
|
||||||
"VoiceServerUpdate",
|
|
||||||
"GuildEmojisUpdate",
|
|
||||||
"GuildStickersUpdate",
|
|
||||||
"PresenceUpdate",
|
|
||||||
"WebhooksUpdate",
|
|
||||||
"GuildMemberAdd",
|
|
||||||
"InviteDelete",
|
|
||||||
"GuildUpdate",
|
|
||||||
"GuildIntegrationsUpdate",
|
|
||||||
"GuildMemberUpdate",
|
|
||||||
"ApplicationCommandUpdate",
|
|
||||||
"InviteCreate",
|
|
||||||
"MessageUpdate",
|
|
||||||
"UserUpdate",
|
|
||||||
"MessageCreate",
|
|
||||||
"GuildBanAdd",
|
|
||||||
"GuildBanRemove",
|
|
||||||
"IntegrationCreate",
|
|
||||||
"IntegrationUpdate",
|
|
||||||
"IntegrationDelete",
|
|
||||||
"ThreadCreate",
|
|
||||||
"ThreadUpdate",
|
|
||||||
"ThreadDelete",
|
|
||||||
"ThreadListSync",
|
|
||||||
"ThreadMemberUpdate",
|
|
||||||
"ThreadMembersUpdate",
|
|
||||||
"VoiceBufferSend",
|
|
||||||
"VoiceUserTalking",
|
|
||||||
"VoiceReady",
|
|
||||||
"VoiceReceive",
|
|
||||||
"VoiceTrackMarker",
|
|
||||||
"StageInstanceCreate",
|
|
||||||
"StageInstanceDelete"
|
|
||||||
};
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void Register_DPPEv(HSQUIRRELVM vm, Table & ns)
|
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
ns.Bind(_SC("VoiceStateUpdate"),
|
ns.Bind(_SC("VoiceStateUpdate"),
|
||||||
@ -696,71 +625,6 @@ void Register_DPPEv(HSQUIRRELVM vm, Table & ns)
|
|||||||
// Member Properties
|
// Member Properties
|
||||||
.Prop(_SC("RawEvent"), &DpStageInstanceDeleteEvent::GetRawEvent)
|
.Prop(_SC("RawEvent"), &DpStageInstanceDeleteEvent::GetRawEvent)
|
||||||
);
|
);
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ConstTable(vm).Enum(_SC("SqDiscordEvent"), Enumeration(vm)
|
|
||||||
.Const(_SC("VoiceStateUpdate"), static_cast< SQInteger >(DpEventID::VoiceStateUpdate))
|
|
||||||
.Const(_SC("Log"), static_cast< SQInteger >(DpEventID::Log))
|
|
||||||
.Const(_SC("GuildJoinRequestDelete"), static_cast< SQInteger >(DpEventID::GuildJoinRequestDelete))
|
|
||||||
.Const(_SC("InteractionCreate"), static_cast< SQInteger >(DpEventID::InteractionCreate))
|
|
||||||
.Const(_SC("ButtonClick"), static_cast< SQInteger >(DpEventID::ButtonClick))
|
|
||||||
.Const(_SC("SelectClick"), static_cast< SQInteger >(DpEventID::SelectClick))
|
|
||||||
.Const(_SC("GuildDelete"), static_cast< SQInteger >(DpEventID::GuildDelete))
|
|
||||||
.Const(_SC("ChannelDelete"), static_cast< SQInteger >(DpEventID::ChannelDelete))
|
|
||||||
.Const(_SC("ChannelUpdate"), static_cast< SQInteger >(DpEventID::ChannelUpdate))
|
|
||||||
.Const(_SC("Ready"), static_cast< SQInteger >(DpEventID::Ready))
|
|
||||||
.Const(_SC("MessageDelete"), static_cast< SQInteger >(DpEventID::MessageDelete))
|
|
||||||
.Const(_SC("ApplicationCommandDelete"), static_cast< SQInteger >(DpEventID::ApplicationCommandDelete))
|
|
||||||
.Const(_SC("GuildMemberRemove"), static_cast< SQInteger >(DpEventID::GuildMemberRemove))
|
|
||||||
.Const(_SC("ApplicationCommandCreate"), static_cast< SQInteger >(DpEventID::ApplicationCommandCreate))
|
|
||||||
.Const(_SC("Resumed"), static_cast< SQInteger >(DpEventID::Resumed))
|
|
||||||
.Const(_SC("GuildRoleCreate"), static_cast< SQInteger >(DpEventID::GuildRoleCreate))
|
|
||||||
.Const(_SC("TypingStart"), static_cast< SQInteger >(DpEventID::TypingStart))
|
|
||||||
.Const(_SC("MessageReactionAdd"), static_cast< SQInteger >(DpEventID::MessageReactionAdd))
|
|
||||||
.Const(_SC("GuildMembersChunk"), static_cast< SQInteger >(DpEventID::GuildMembersChunk))
|
|
||||||
.Const(_SC("MessageReactionRemove"), static_cast< SQInteger >(DpEventID::MessageReactionRemove))
|
|
||||||
.Const(_SC("GuildCreate"), static_cast< SQInteger >(DpEventID::GuildCreate))
|
|
||||||
.Const(_SC("ChannelCreate"), static_cast< SQInteger >(DpEventID::ChannelCreate))
|
|
||||||
.Const(_SC("MessageReactionRemoveEmoji"), static_cast< SQInteger >(DpEventID::MessageReactionRemoveEmoji))
|
|
||||||
.Const(_SC("MessageDeleteBulk"), static_cast< SQInteger >(DpEventID::MessageDeleteBulk))
|
|
||||||
.Const(_SC("GuildRoleUpdate"), static_cast< SQInteger >(DpEventID::GuildRoleUpdate))
|
|
||||||
.Const(_SC("GuildRoleDelete"), static_cast< SQInteger >(DpEventID::GuildRoleDelete))
|
|
||||||
.Const(_SC("ChannelPinsUpdate"), static_cast< SQInteger >(DpEventID::ChannelPinsUpdate))
|
|
||||||
.Const(_SC("MessageReactionRemoveAll"), static_cast< SQInteger >(DpEventID::MessageReactionRemoveAll))
|
|
||||||
.Const(_SC("VoiceServerUpdate"), static_cast< SQInteger >(DpEventID::VoiceServerUpdate))
|
|
||||||
.Const(_SC("GuildEmojisUpdate"), static_cast< SQInteger >(DpEventID::GuildEmojisUpdate))
|
|
||||||
.Const(_SC("GuildStickersUpdate"), static_cast< SQInteger >(DpEventID::GuildStickersUpdate))
|
|
||||||
.Const(_SC("PresenceUpdate"), static_cast< SQInteger >(DpEventID::PresenceUpdate))
|
|
||||||
.Const(_SC("WebhooksUpdate"), static_cast< SQInteger >(DpEventID::WebhooksUpdate))
|
|
||||||
.Const(_SC("GuildMemberAdd"), static_cast< SQInteger >(DpEventID::GuildMemberAdd))
|
|
||||||
.Const(_SC("InviteDelete"), static_cast< SQInteger >(DpEventID::InviteDelete))
|
|
||||||
.Const(_SC("GuildUpdate"), static_cast< SQInteger >(DpEventID::GuildUpdate))
|
|
||||||
.Const(_SC("GuildIntegrationsUpdate"), static_cast< SQInteger >(DpEventID::GuildIntegrationsUpdate))
|
|
||||||
.Const(_SC("GuildMemberUpdate"), static_cast< SQInteger >(DpEventID::GuildMemberUpdate))
|
|
||||||
.Const(_SC("ApplicationCommandUpdate"), static_cast< SQInteger >(DpEventID::ApplicationCommandUpdate))
|
|
||||||
.Const(_SC("InviteCreate"), static_cast< SQInteger >(DpEventID::InviteCreate))
|
|
||||||
.Const(_SC("MessageUpdate"), static_cast< SQInteger >(DpEventID::MessageUpdate))
|
|
||||||
.Const(_SC("UserUpdate"), static_cast< SQInteger >(DpEventID::UserUpdate))
|
|
||||||
.Const(_SC("MessageCreate"), static_cast< SQInteger >(DpEventID::MessageCreate))
|
|
||||||
.Const(_SC("GuildBanAdd"), static_cast< SQInteger >(DpEventID::GuildBanAdd))
|
|
||||||
.Const(_SC("GuildBanRemove"), static_cast< SQInteger >(DpEventID::GuildBanRemove))
|
|
||||||
.Const(_SC("IntegrationCreate"), static_cast< SQInteger >(DpEventID::IntegrationCreate))
|
|
||||||
.Const(_SC("IntegrationUpdate"), static_cast< SQInteger >(DpEventID::IntegrationUpdate))
|
|
||||||
.Const(_SC("IntegrationDelete"), static_cast< SQInteger >(DpEventID::IntegrationDelete))
|
|
||||||
.Const(_SC("ThreadCreate"), static_cast< SQInteger >(DpEventID::ThreadCreate))
|
|
||||||
.Const(_SC("ThreadUpdate"), static_cast< SQInteger >(DpEventID::ThreadUpdate))
|
|
||||||
.Const(_SC("ThreadDelete"), static_cast< SQInteger >(DpEventID::ThreadDelete))
|
|
||||||
.Const(_SC("ThreadListSync"), static_cast< SQInteger >(DpEventID::ThreadListSync))
|
|
||||||
.Const(_SC("ThreadMemberUpdate"), static_cast< SQInteger >(DpEventID::ThreadMemberUpdate))
|
|
||||||
.Const(_SC("ThreadMembersUpdate"), static_cast< SQInteger >(DpEventID::ThreadMembersUpdate))
|
|
||||||
.Const(_SC("VoiceBufferSend"), static_cast< SQInteger >(DpEventID::VoiceBufferSend))
|
|
||||||
.Const(_SC("VoiceUserTalking"), static_cast< SQInteger >(DpEventID::VoiceUserTalking))
|
|
||||||
.Const(_SC("VoiceReady"), static_cast< SQInteger >(DpEventID::VoiceReady))
|
|
||||||
.Const(_SC("VoiceReceive"), static_cast< SQInteger >(DpEventID::VoiceReceive))
|
|
||||||
.Const(_SC("VoiceTrackMarker"), static_cast< SQInteger >(DpEventID::VoiceTrackMarker))
|
|
||||||
.Const(_SC("StageInstanceCreate"), static_cast< SQInteger >(DpEventID::StageInstanceCreate))
|
|
||||||
.Const(_SC("StageInstanceDelete"), static_cast< SQInteger >(DpEventID::StageInstanceDelete))
|
|
||||||
.Const(_SC("Max"), static_cast< SQInteger >(DpEventID::Max))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
@ -1,7 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/DPPTy.hpp"
|
#include "Library/DPP/Channel.hpp"
|
||||||
|
#include "Library/DPP/Client.hpp"
|
||||||
|
#include "Library/DPP/Command.hpp"
|
||||||
|
#include "Library/DPP/Guild.hpp"
|
||||||
|
#include "Library/DPP/Integration.hpp"
|
||||||
|
#include "Library/DPP/Message.hpp"
|
||||||
|
#include "Library/DPP/Other.hpp"
|
||||||
|
#include "Library/DPP/Role.hpp"
|
||||||
|
#include "Library/DPP/User.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -13,85 +21,6 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
|
||||||
* Unique ID for each event.
|
|
||||||
*/
|
|
||||||
struct DpEventID
|
|
||||||
{
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* ID enumeration.
|
|
||||||
*/
|
|
||||||
enum Type
|
|
||||||
{
|
|
||||||
VoiceStateUpdate=0,
|
|
||||||
Log,
|
|
||||||
GuildJoinRequestDelete,
|
|
||||||
InteractionCreate,
|
|
||||||
ButtonClick,
|
|
||||||
SelectClick,
|
|
||||||
GuildDelete,
|
|
||||||
ChannelDelete,
|
|
||||||
ChannelUpdate,
|
|
||||||
Ready,
|
|
||||||
MessageDelete,
|
|
||||||
ApplicationCommandDelete,
|
|
||||||
GuildMemberRemove,
|
|
||||||
ApplicationCommandCreate,
|
|
||||||
Resumed,
|
|
||||||
GuildRoleCreate,
|
|
||||||
TypingStart,
|
|
||||||
MessageReactionAdd,
|
|
||||||
GuildMembersChunk,
|
|
||||||
MessageReactionRemove,
|
|
||||||
GuildCreate,
|
|
||||||
ChannelCreate,
|
|
||||||
MessageReactionRemoveEmoji,
|
|
||||||
MessageDeleteBulk,
|
|
||||||
GuildRoleUpdate,
|
|
||||||
GuildRoleDelete,
|
|
||||||
ChannelPinsUpdate,
|
|
||||||
MessageReactionRemoveAll,
|
|
||||||
VoiceServerUpdate,
|
|
||||||
GuildEmojisUpdate,
|
|
||||||
GuildStickersUpdate,
|
|
||||||
PresenceUpdate,
|
|
||||||
WebhooksUpdate,
|
|
||||||
GuildMemberAdd,
|
|
||||||
InviteDelete,
|
|
||||||
GuildUpdate,
|
|
||||||
GuildIntegrationsUpdate,
|
|
||||||
GuildMemberUpdate,
|
|
||||||
ApplicationCommandUpdate,
|
|
||||||
InviteCreate,
|
|
||||||
MessageUpdate,
|
|
||||||
UserUpdate,
|
|
||||||
MessageCreate,
|
|
||||||
GuildBanAdd,
|
|
||||||
GuildBanRemove,
|
|
||||||
IntegrationCreate,
|
|
||||||
IntegrationUpdate,
|
|
||||||
IntegrationDelete,
|
|
||||||
ThreadCreate,
|
|
||||||
ThreadUpdate,
|
|
||||||
ThreadDelete,
|
|
||||||
ThreadListSync,
|
|
||||||
ThreadMemberUpdate,
|
|
||||||
ThreadMembersUpdate,
|
|
||||||
VoiceBufferSend,
|
|
||||||
VoiceUserTalking,
|
|
||||||
VoiceReady,
|
|
||||||
VoiceReceive,
|
|
||||||
VoiceTrackMarker,
|
|
||||||
StageInstanceCreate,
|
|
||||||
StageInstanceDelete,
|
|
||||||
Max
|
|
||||||
};
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* String identification.
|
|
||||||
*/
|
|
||||||
static const std::array< const char *, static_cast< size_t >(Max) > NAME;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Base class of an event handler.
|
* Base class of an event handler.
|
||||||
*/
|
*/
|
146
module/Library/DPP/Guild.cpp
Normal file
146
module/Library/DPP/Guild.cpp
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Guild.hpp"
|
||||||
|
#include "Library/DPP/Other.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildMember, _SC("SqDppGuildMember"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuild, _SC("SqDppGuild"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Table DpGuild::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Table DpGuild::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Guild(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
464
module/Library/DPP/Guild.hpp
Normal file
464
module/Library/DPP/Guild.hpp
Normal file
@ -0,0 +1,464 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
struct DpGuild
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::guild >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced guild instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
~DpGuild() noexcept
|
||||||
|
{
|
||||||
|
// 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) {
|
||||||
|
// 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 guild 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 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;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a list of members in voice channels in the guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Table GetVoiceMembers() const;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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) const { return Valid().connect_member_voice(user_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Is a large server (>250 users).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsLarge() const { return Valid().is_large(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Is unavailable due to outage (most other fields will be blank or outdated).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsUnavailable() const { return Valid().is_unavailable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Widget is enabled for this server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool WidgetEnabled() const { return Valid().widget_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has an invite splash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasInviteSplash() const { return Valid().has_invite_splash(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has VIP regions.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasVipRegions() const { return Valid().has_vip_regions(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild can have a vanity URL.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasVanityURL() const { return Valid().has_vanity_url(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is a verified server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerified() const { return Valid().is_verified(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is a discord partner server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPartnered() const { return Valid().is_partnered(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled community.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsCommunity() const { return Valid().is_community(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled commerce channels.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasCommerce() const { return Valid().has_commerce(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has news channel.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasNews() const { return Valid().has_news(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is discoverable.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDiscoverable() const { return Valid().is_discoverable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is featureable.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsFeatureable() const { return Valid().is_featureable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is allowed an animated icon.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasAnimatedIcon() const { return Valid().has_animated_icon(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has a banner image.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool BasBanner() const { return Valid().has_banner(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled welcome screen.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool WelcomeScreenEnabled() const { return Valid().is_welcome_screen_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled membership screening.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasMemberVerificationGate() const { return Valid().has_member_verification_gate(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has preview enabled.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPreviewEnabled() const { return Valid().is_preview_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Server icon is actually an animated gif.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasAnimatedIconHash() const { return Valid().has_animated_icon_hash(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
16
module/Library/DPP/Integration.cpp
Normal file
16
module/Library/DPP/Integration.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Integration.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Integration(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
19
module/Library/DPP/Integration.hpp
Normal file
19
module/Library/DPP/Integration.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
16
module/Library/DPP/Message.cpp
Normal file
16
module/Library/DPP/Message.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Message.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Message(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
19
module/Library/DPP/Message.hpp
Normal file
19
module/Library/DPP/Message.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
141
module/Library/DPP/Other.cpp
Normal file
141
module/Library/DPP/Other.cpp
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Other.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppCachePolicy, _SC("SqDppCachePolicy"))
|
||||||
|
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"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Other(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Uptime"),
|
||||||
|
Class< dpp::utility::uptime >(vm, SqDppUptime::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppUptime::Fn)
|
||||||
|
.Func(_SC("_tostring"), &dpp::utility::uptime::to_string)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("Days"), &dpp::utility::uptime::days)
|
||||||
|
.Var(_SC("Hours"), &dpp::utility::uptime::hours)
|
||||||
|
.Var(_SC("Minutes"), &dpp::utility::uptime::mins)
|
||||||
|
.Var(_SC("Seconds"), &dpp::utility::uptime::secs)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("ToSeconds"), &dpp::utility::uptime::to_secs)
|
||||||
|
.Func(_SC("ToMilliseconds"), &dpp::utility::uptime::to_msecs)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IconHash"),
|
||||||
|
Class< dpp::utility::iconhash >(vm, SqDppIconHash::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< const std::string & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppIconHash::Fn)
|
||||||
|
.Func(_SC("_tostring"), &dpp::utility::iconhash::to_string)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("High"), &dpp::utility::iconhash::first)
|
||||||
|
.Var(_SC("Low"), &dpp::utility::iconhash::second)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Set"), &dpp::utility::iconhash::set)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("CachePolicy"),
|
||||||
|
Class< DpCachePolicy >(vm, SqDppCachePolicy::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger >()
|
||||||
|
.Ctor< SQInteger, SQInteger >()
|
||||||
|
.Ctor< SQInteger, SQInteger, SQInteger >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppCachePolicy::Fn)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("UserPolicy"), &DpCachePolicy::mUserPolicy)
|
||||||
|
.Var(_SC("EmojiPolicy"), &DpCachePolicy::mEmojiPolicy)
|
||||||
|
.Var(_SC("RolePolicy"), &DpCachePolicy::mRolePolicy)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Activity"),
|
||||||
|
Class< DpActivity, NoCopy< DpActivity > >(vm, SqDppActivity::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger, StackStrF &, StackStrF &, StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppActivity::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Name"), &DpActivity::GetName, &DpActivity::SetName)
|
||||||
|
.Prop(_SC("State"), &DpActivity::GetState, &DpActivity::SetState)
|
||||||
|
.Prop(_SC("URL"), &DpActivity::GetURL, &DpActivity::SetURL)
|
||||||
|
.Prop(_SC("Type"), &DpActivity::GetType, &DpActivity::SetType)
|
||||||
|
.Prop(_SC("CreatedAt"), &DpActivity::GetCreatedAt, &DpActivity::SetCreatedAt)
|
||||||
|
.Prop(_SC("Start"), &DpActivity::GetStart, &DpActivity::SetStart)
|
||||||
|
.Prop(_SC("End"), &DpActivity::GetEnd, &DpActivity::SetEnd)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetName"), &DpActivity::ApplyName)
|
||||||
|
.Func(_SC("SetState"), &DpActivity::ApplyState)
|
||||||
|
.Func(_SC("SetURL"), &DpActivity::ApplyURL)
|
||||||
|
.Func(_SC("SetType"), &DpActivity::ApplyType)
|
||||||
|
.Func(_SC("SetCreatedAt"), &DpActivity::ApplyCreatedAt)
|
||||||
|
.Func(_SC("SetStart"), &DpActivity::ApplyStart)
|
||||||
|
.Func(_SC("SetEnd"), &DpActivity::ApplyEnd)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Presence"),
|
||||||
|
Class< DpPresence, NoCopy< DpPresence > >(vm, SqDppPresence::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppPresence::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpPresence::IsValid)
|
||||||
|
.Prop(_SC("UserID"), &DpPresence::GetUserID, &DpPresence::SetUserID)
|
||||||
|
.Prop(_SC("GuildID"), &DpPresence::GetGuildID, &DpPresence::SetGuildID)
|
||||||
|
.Prop(_SC("Flags"), &DpPresence::GetFlags, &DpPresence::SetFlags)
|
||||||
|
.Prop(_SC("ActivityCount"), &DpPresence::ActivityCount)
|
||||||
|
.Prop(_SC("DesktopStatus"), &DpPresence::GetDesktopStatus)
|
||||||
|
.Prop(_SC("WebStatus"), &DpPresence::GetWebStatus)
|
||||||
|
.Prop(_SC("MobileStatus"), &DpPresence::GetMobileStatus)
|
||||||
|
.Prop(_SC("Status"), &DpPresence::GetStatus)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetUserID"), &DpPresence::ApplyUserID)
|
||||||
|
.Func(_SC("SetGuildID"), &DpPresence::ApplyGuildID)
|
||||||
|
.Func(_SC("SetFlags"), &DpPresence::ApplyFlags)
|
||||||
|
.Func(_SC("AddActivity"), &DpPresence::AddActivity)
|
||||||
|
.Func(_SC("EachActivity"), &DpPresence::EachActivity)
|
||||||
|
.Func(_SC("ClearActivities"), &DpPresence::ClearActivities)
|
||||||
|
.Func(_SC("FilterActivities"), &DpPresence::FilterActivities)
|
||||||
|
.Func(_SC("BuildJSON"), &DpPresence::BuildJSON)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceState"),
|
||||||
|
Class< DpVoiceState, NoConstructor< DpVoiceState > >(vm, SqDppVoiceState::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceState::Fn)
|
||||||
|
.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("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("IsSupressed"), &DpVoiceState::IsSupressed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
589
module/Library/DPP/Other.hpp
Normal file
589
module/Library/DPP/Other.hpp
Normal file
@ -0,0 +1,589 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents the caching policy of the cluster.
|
||||||
|
*/
|
||||||
|
struct DpCachePolicy
|
||||||
|
{
|
||||||
|
SQInteger mUserPolicy{dpp::cp_aggressive};
|
||||||
|
SQInteger mEmojiPolicy{dpp::cp_aggressive};
|
||||||
|
SQInteger mRolePolicy{dpp::cp_aggressive};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpCachePolicy(SQInteger user) noexcept
|
||||||
|
: mUserPolicy(user), mEmojiPolicy(dpp::cp_aggressive), mRolePolicy(dpp::cp_aggressive)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy(SQInteger user, SQInteger emoji) noexcept
|
||||||
|
: mUserPolicy(user), mEmojiPolicy(emoji), mRolePolicy(dpp::cp_aggressive)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy(SQInteger user, SQInteger emoji, SQInteger role) noexcept
|
||||||
|
: mUserPolicy(user), mEmojiPolicy(emoji), mRolePolicy(role)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy(const DpCachePolicy &) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Convert to native cache policy type.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::cache_policy_t ToNative() const noexcept
|
||||||
|
{
|
||||||
|
return dpp::cache_policy_t{
|
||||||
|
static_cast< dpp::cache_policy_setting_t >(mUserPolicy),
|
||||||
|
static_cast< dpp::cache_policy_setting_t >(mEmojiPolicy),
|
||||||
|
static_cast< dpp::cache_policy_setting_t >(mRolePolicy)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* An activity is a representation of what a user is doing. It might be a game, or a website, or a movie. Whatever.
|
||||||
|
*/
|
||||||
|
struct DpActivity
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::activity >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced activity instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Wether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpActivity() noexcept
|
||||||
|
: DpActivity(new Ptr::element_type(), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivity(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivity(const Ptr::element_type & o) noexcept
|
||||||
|
: DpActivity(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivity(Ptr::element_type && o) noexcept
|
||||||
|
: DpActivity(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpActivity(SQInteger type, StackStrF & name, StackStrF & state, StackStrF & url)
|
||||||
|
: DpActivity(new Ptr::element_type(static_cast< dpp::activity_type >(type), name.ToStr(), state.ToStr(), url.ToStr()), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpActivity(const DpActivity & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpActivity(DpActivity && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpActivity() noexcept
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpActivity & operator = (const DpActivity & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpActivity & operator = (DpActivity && 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 activity 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 name of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the name of the activity.
|
||||||
|
*/
|
||||||
|
void SetName(StackStrF & name) const { Valid().name = name.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the name of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyName(StackStrF & name) { SetName(name); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the state of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetState() const { return Valid().state; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the state of the activity.
|
||||||
|
*/
|
||||||
|
void SetState(StackStrF & state) const { Valid().state = state.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the state of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyState(StackStrF & state) { SetState(state); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the url of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetURL() const { return Valid().url; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the url of the activity.
|
||||||
|
*/
|
||||||
|
void SetURL(StackStrF & url) const { Valid().url = url.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the url of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyURL(StackStrF & url) { SetURL(url); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the type of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetType() const { return static_cast< SQInteger >(Valid().type); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the type of the activity.
|
||||||
|
*/
|
||||||
|
void SetType(SQInteger s) const { Valid().type = static_cast< dpp::activity_type >(s); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the type of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyType(SQInteger s) { SetType(s); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve when the activity was created.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetCreatedAt() const
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::from_time_t(Valid().created_at).time_since_epoch()).count());
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was created.
|
||||||
|
*/
|
||||||
|
void SetCreatedAt(SQInteger s) const
|
||||||
|
{
|
||||||
|
Valid().created_at = std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::seconds{s}});
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was created.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyCreatedAt(SQInteger s) { SetCreatedAt(s); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve when the activity was started.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetStart() const
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::from_time_t(Valid().start).time_since_epoch()).count());
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was started.
|
||||||
|
*/
|
||||||
|
void SetStart(SQInteger s) const
|
||||||
|
{
|
||||||
|
Valid().start = std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::seconds{s}});
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was started.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyStart(SQInteger s) { SetStart(s); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve when the activity was stopped.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetEnd() const
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::from_time_t(Valid().end).time_since_epoch()).count());
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was stopped.
|
||||||
|
*/
|
||||||
|
void SetEnd(SQInteger s) const
|
||||||
|
{
|
||||||
|
Valid().end = std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::seconds{s}});
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was stopped.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyEnd(SQInteger s) { SetEnd(s); return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents user presence, e.g. what game they are playing and if they are online.
|
||||||
|
*/
|
||||||
|
struct DpPresence
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::presence >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced presence instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Wether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpPresence() noexcept
|
||||||
|
: DpPresence(new Ptr::element_type(), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpPresence(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpPresence(const Ptr::element_type & o) noexcept
|
||||||
|
: DpPresence(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpPresence(Ptr::element_type && o) noexcept
|
||||||
|
: DpPresence(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpPresence(const DpPresence & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpPresence(DpPresence && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpPresence() noexcept
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpPresence & operator = (const DpPresence & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpPresence & operator = (DpPresence && 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 presence 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 user that the presence applies to.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the user that the presence applies to.
|
||||||
|
*/
|
||||||
|
void SetUserID(dpp::snowflake id) const { Valid().user_id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the user that the presence applies to.
|
||||||
|
*/
|
||||||
|
DpPresence & ApplyUserID(dpp::snowflake id) { SetUserID(id); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild that the presence applies to.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild that the presence applies to.
|
||||||
|
*/
|
||||||
|
void SetGuildID(dpp::snowflake id) const { Valid().guild_id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild that the presence applies to.
|
||||||
|
*/
|
||||||
|
DpPresence & ApplyGuildID(dpp::snowflake id) { SetGuildID(id); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the presence bit-mask.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the presence bit-mask.
|
||||||
|
*/
|
||||||
|
void SetFlags(SQInteger f) const { Valid().flags = static_cast< uint8_t >(f); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the presence bit-mask.
|
||||||
|
*/
|
||||||
|
DpPresence & ApplyFlags(SQInteger f) { SetFlags(f); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of activities.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger ActivityCount() const { return static_cast< SQInteger >(Valid().activities.size()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Add a new activity.
|
||||||
|
*/
|
||||||
|
DpPresence & AddActivity(const DpActivity & a) { Valid().activities.push_back(a.Valid()); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate all activities.
|
||||||
|
*/
|
||||||
|
DpPresence & EachActivity(Function & fn)
|
||||||
|
{
|
||||||
|
for (const auto & a : Valid().activities)
|
||||||
|
{
|
||||||
|
fn.Execute(a);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of activities.
|
||||||
|
*/
|
||||||
|
DpPresence & ClearActivities(const DpActivity & a) { Valid().activities.clear(); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Filter activities.
|
||||||
|
*/
|
||||||
|
DpPresence & FilterActivities(Function & fn)
|
||||||
|
{
|
||||||
|
std::vector< dpp::activity > list;
|
||||||
|
// Reserve memory in advance
|
||||||
|
list.reserve(Valid().activities.size());
|
||||||
|
// Process each activity individually
|
||||||
|
for (const auto & a : Valid().activities)
|
||||||
|
{
|
||||||
|
auto ret = fn.Eval(a);
|
||||||
|
// (null || true) == keep & false == skip
|
||||||
|
if (!ret.IsNull() || !ret.template Cast< bool >())
|
||||||
|
{
|
||||||
|
list.push_back(a); // Keep this activity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use filtered activities
|
||||||
|
Valid().activities.swap(list);
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build JSON string from this object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the users status on desktop.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetDesktopStatus() const { return static_cast< SQInteger >(Valid().desktop_status()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user's status on web.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetWebStatus() const { return static_cast< SQInteger >(Valid().web_status()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user's status on mobile.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMobileStatus() const { return static_cast< SQInteger >(Valid().mobile_status()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user's status as shown to other users.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetStatus() const { return static_cast< SQInteger >(Valid().status()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents the voice state of a user on a guild.
|
||||||
|
* These are stored in the DpGuild object, and accessible there, or via DpChannel::GetVoiceMembers.
|
||||||
|
*/
|
||||||
|
struct DpVoiceState
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::voicestate >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced voice state instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
~DpVoiceState() noexcept
|
||||||
|
{
|
||||||
|
// 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) {
|
||||||
|
// 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 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(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
74
module/Library/DPP/Role.cpp
Normal file
74
module/Library/DPP/Role.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Role.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppRole, _SC("SqDppRole"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Role(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
ns.Bind(_SC("Role"),
|
||||||
|
Class< DpRole, NoConstructor< DpRole > >(vm, SqDppRole::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppRole::Fn)
|
||||||
|
.Func(_SC("_tojson"), &DpRole::BuildJSON)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpRole::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpRole::BuildJSON)
|
||||||
|
.Prop(_SC("Name"), &DpRole::GetName)
|
||||||
|
.Prop(_SC("GuildID"), &DpRole::GetGuildID)
|
||||||
|
.Prop(_SC("Color"), &DpRole::GetColour)
|
||||||
|
.Prop(_SC("Colour"), &DpRole::GetColour)
|
||||||
|
.Prop(_SC("Position"), &DpRole::GetPosition)
|
||||||
|
.Prop(_SC("Permissions"), &DpRole::GetPermissions)
|
||||||
|
.Prop(_SC("Flags"), &DpRole::GetFlags)
|
||||||
|
.Prop(_SC("IntegrationID"), &DpRole::GetIntegrationID)
|
||||||
|
.Prop(_SC("BotID"), &DpRole::GetBotID)
|
||||||
|
.Prop(_SC("IsHoisted"), &DpRole::IsHoisted)
|
||||||
|
.Prop(_SC("IsMentionable"), &DpRole::IsMentionable)
|
||||||
|
.Prop(_SC("IsManaged"), &DpRole::IsManaged)
|
||||||
|
.Prop(_SC("CanCreateInstantInvite"), &DpRole::CanCreateInstantInvite)
|
||||||
|
.Prop(_SC("CanKickMembers"), &DpRole::CanKickMembers)
|
||||||
|
.Prop(_SC("CanBanMembers"), &DpRole::CanBanMembers)
|
||||||
|
.Prop(_SC("IsAdministrator"), &DpRole::IsAdministrator)
|
||||||
|
.Prop(_SC("CanManageChannels"), &DpRole::CanManageChannels)
|
||||||
|
.Prop(_SC("CanManageGuild"), &DpRole::CanManageGuild)
|
||||||
|
.Prop(_SC("CanAddReactions"), &DpRole::CanAddReactions)
|
||||||
|
.Prop(_SC("CanViewAuditLog"), &DpRole::CanViewAuditLog)
|
||||||
|
.Prop(_SC("IsPrioritySpeaker"), &DpRole::IsPrioritySpeaker)
|
||||||
|
.Prop(_SC("CanStream"), &DpRole::CanStream)
|
||||||
|
.Prop(_SC("CanViewChannel"), &DpRole::CanViewChannel)
|
||||||
|
.Prop(_SC("CanSendMessages"), &DpRole::CanSendMessages)
|
||||||
|
.Prop(_SC("CanSendTtsMessages"), &DpRole::CanSendTtsMessages)
|
||||||
|
.Prop(_SC("CanManageMessages"), &DpRole::CanManageMessages)
|
||||||
|
.Prop(_SC("CanEmbedLinks"), &DpRole::CanEmbedLinks)
|
||||||
|
.Prop(_SC("CanAttachFiles"), &DpRole::CanAttachFiles)
|
||||||
|
.Prop(_SC("CanReadMessageHistory"), &DpRole::CanReadMessageHistory)
|
||||||
|
.Prop(_SC("CanMentionEveryone"), &DpRole::CanMentionEveryone)
|
||||||
|
.Prop(_SC("CanUseExternalEmojis"), &DpRole::CanUseExternalEmojis)
|
||||||
|
.Prop(_SC("CanViewGuildInsights"), &DpRole::CanViewGuildInsights)
|
||||||
|
.Prop(_SC("CanConnect"), &DpRole::CanConnect)
|
||||||
|
.Prop(_SC("CanSpeak"), &DpRole::CanSpeak)
|
||||||
|
.Prop(_SC("CanMuteMembers"), &DpRole::CanMuteMembers)
|
||||||
|
.Prop(_SC("CanDeafenMembers"), &DpRole::CanDeafenMembers)
|
||||||
|
.Prop(_SC("CanMoveMembers"), &DpRole::CanMoveMembers)
|
||||||
|
.Prop(_SC("CanUseVAT"), &DpRole::CanUseVAT)
|
||||||
|
.Prop(_SC("CanChangeNickname"), &DpRole::CanChangeNickname)
|
||||||
|
.Prop(_SC("CanManageNicknames"), &DpRole::CanManageNicknames)
|
||||||
|
.Prop(_SC("CanManageRoles"), &DpRole::CanManageRoles)
|
||||||
|
.Prop(_SC("CanManageWebhooks"), &DpRole::CanManageWebhooks)
|
||||||
|
.Prop(_SC("CanManageEmojis"), &DpRole::CanManageEmojis)
|
||||||
|
.Prop(_SC("CanUseSlashCommands"), &DpRole::CanUseSlashCommands)
|
||||||
|
.Prop(_SC("HasRequestToSpeak"), &DpRole::HasRequestToSpeak)
|
||||||
|
.Prop(_SC("CanManageThreads"), &DpRole::CanManageThreads)
|
||||||
|
.Prop(_SC("HasUsePublicThreads"), &DpRole::HasUsePublicThreads)
|
||||||
|
.Prop(_SC("HasUsePrivateThreads"), &DpRole::HasUsePrivateThreads)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("BuildJSON"), &DpRole::BuildJSON_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
295
module/Library/DPP/Role.hpp
Normal file
295
module/Library/DPP/Role.hpp
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents a role within a DpGuild.
|
||||||
|
*/
|
||||||
|
struct DpRole
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::role >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced role instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Wether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpRole() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpRole(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpRole(const Ptr::element_type & o) noexcept
|
||||||
|
: DpRole(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpRole(Ptr::element_type && o) noexcept
|
||||||
|
: DpRole(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpRole(const DpRole & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpRole(DpRole && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpRole() noexcept
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpRole & operator = (const DpRole & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpRole & operator = (DpRole && 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 role 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 role name.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role guild id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role colour.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetColour() const { return static_cast< SQInteger >(Valid().colour); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role position.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetPosition() const { return static_cast< SQInteger >(Valid().position); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role permissions bitmask values from SqDiscordRolePermissions.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetPermissions() const { return static_cast< SQInteger >(Valid().permissions); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role flags from SqDiscordRoleFlags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role integration id if any (e.g. role is a bot's role created when it was invited).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetIntegrationID() const { return Valid().integration_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role bot id if any (e.g. role is a bot's role created when it was invited).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetBotID() const { return Valid().bot_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role is hoisted.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHoisted() const { return Valid().is_hoisted(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role is mentionable.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsMentionable() const { return Valid().is_mentionable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role is managed (belongs to a bot or application).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsManaged() const { return Valid().is_managed(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has create instant invite permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanCreateInstantInvite() const { return Valid().has_create_instant_invite(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the kick members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanKickMembers() const { return Valid().has_kick_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the ban members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanBanMembers() const { return Valid().has_ban_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the administrator permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsAdministrator() const { return Valid().has_administrator(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage channels permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageChannels() const { return Valid().has_manage_channels(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage guild permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageGuild() const { return Valid().has_manage_guild(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the add reactions permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanAddReactions() const { return Valid().has_add_reactions(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the view audit log permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanViewAuditLog() const { return Valid().has_view_audit_log(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the priority speaker permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPrioritySpeaker() const { return Valid().has_priority_speaker(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the stream permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanStream() const { return Valid().has_stream(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the view channel permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanViewChannel() const { return Valid().has_view_channel(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the send messages permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanSendMessages() const { return Valid().has_send_messages(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the send TTS messages permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanSendTtsMessages() const { return Valid().has_send_tts_messages(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage messages permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageMessages() const { return Valid().has_manage_messages(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the embed links permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanEmbedLinks() const { return Valid().has_embed_links(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the attach files permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanAttachFiles() const { return Valid().has_attach_files(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the read message history permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanReadMessageHistory() const { return Valid().has_read_message_history(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the mention \@everyone and \@here permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanMentionEveryone() const { return Valid().has_mention_everyone(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the use external emojis permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanUseExternalEmojis() const { return Valid().has_use_external_emojis(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the view guild insights permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanViewGuildInsights() const { return Valid().has_view_guild_insights(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the connect voice permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanConnect() const { return Valid().has_connect(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the speak permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanSpeak() const { return Valid().has_speak(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the mute members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanMuteMembers() const { return Valid().has_mute_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the deafen members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanDeafenMembers() const { return Valid().has_deafen_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the move members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanMoveMembers() const { return Valid().has_move_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has use voice activity detection permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanUseVAT() const { return Valid().has_use_vad(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the change nickname permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanChangeNickname() const { return Valid().has_change_nickname(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage nicknames permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageNicknames() const { return Valid().has_manage_nicknames(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage roles permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageRoles() const { return Valid().has_manage_roles(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage webhooks permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageWebhooks() const { return Valid().has_manage_webhooks(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage emojis permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageEmojis() const { return Valid().has_manage_emojis(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the use slash commands permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanUseSlashCommands() const { return Valid().has_use_slash_commands(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the request to speak permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasRequestToSpeak() const { return Valid().has_request_to_speak(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the manage threads permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageThreads() const { return Valid().has_manage_threads(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the use public threads permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasUsePublicThreads() const { return Valid().has_use_public_threads(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the role has the use private threads permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasUsePrivateThreads() const { return Valid().has_use_private_threads(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
48
module/Library/DPP/User.cpp
Normal file
48
module/Library/DPP/User.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/User.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppUser, _SC("SqDppUser"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_User(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
ns.Bind(_SC("User"),
|
||||||
|
Class< DpUser, NoConstructor< DpUser > >(vm, SqDppUser::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppUser::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpUser::IsValid)
|
||||||
|
.Prop(_SC("Username"), &DpUser::GetUsername)
|
||||||
|
.Prop(_SC("Discriminator"), &DpUser::GetDiscriminator)
|
||||||
|
.Prop(_SC("Avatar"), &DpUser::GetAvatar)
|
||||||
|
.Prop(_SC("Flags"), &DpUser::GetFlags)
|
||||||
|
.Prop(_SC("RefCount"), &DpUser::GetRefCount)
|
||||||
|
.Prop(_SC("AvatarURL"), &DpUser::GetAvatarURL)
|
||||||
|
.Prop(_SC("IsBot"), &DpUser::IsBot)
|
||||||
|
.Prop(_SC("IsSystem"), &DpUser::IsSystem)
|
||||||
|
.Prop(_SC("IsMfaEnabled"), &DpUser::IsMfaEnabled)
|
||||||
|
.Prop(_SC("IsVerified"), &DpUser::IsVerified)
|
||||||
|
.Prop(_SC("HasNitroFull"), &DpUser::HasNitroFull)
|
||||||
|
.Prop(_SC("HasNitroClassic"), &DpUser::HasNitroClassic)
|
||||||
|
.Prop(_SC("IsDiscordEmployee"), &DpUser::IsDiscordEmployee)
|
||||||
|
.Prop(_SC("IsPartneredOwner"), &DpUser::IsPartneredOwner)
|
||||||
|
.Prop(_SC("HasHypesquadEvents"), &DpUser::HasHypesquadEvents)
|
||||||
|
.Prop(_SC("IsBughunter1"), &DpUser::IsBughunter1)
|
||||||
|
.Prop(_SC("IsHouseBravery"), &DpUser::IsHouseBravery)
|
||||||
|
.Prop(_SC("IsHouseBrilliance"), &DpUser::IsHouseBrilliance)
|
||||||
|
.Prop(_SC("IsHouseBalanace"), &DpUser::IsHouseBalanace)
|
||||||
|
.Prop(_SC("IsEarlySupporter"), &DpUser::IsEarlySupporter)
|
||||||
|
.Prop(_SC("IsTeamUser"), &DpUser::IsTeamUser)
|
||||||
|
.Prop(_SC("IsBughunter2"), &DpUser::IsBughunter2)
|
||||||
|
.Prop(_SC("IsVerifiedBot"), &DpUser::IsVerifiedBot)
|
||||||
|
.Prop(_SC("IsVerifiedBotDev"), &DpUser::IsVerifiedBotDev)
|
||||||
|
.Prop(_SC("IsCertifiedDoderator"), &DpUser::IsCertifiedDoderator)
|
||||||
|
.Prop(_SC("HasAnimatedIcon"), &DpUser::HasAnimatedIcon)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
200
module/Library/DPP/User.hpp
Normal file
200
module/Library/DPP/User.hpp
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents a user on discord. May or may not be a member of a DpGuild.
|
||||||
|
*/
|
||||||
|
struct DpUser
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::user >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced user instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Wether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpUser() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpUser(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpUser(const Ptr::element_type & o) noexcept
|
||||||
|
: DpUser(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpUser(Ptr::element_type && o) noexcept
|
||||||
|
: DpUser(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpUser(const DpUser & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpUser(DpUser && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpUser() noexcept
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpUser & operator = (const DpUser & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpUser & operator = (DpUser && 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 user 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 user discord username.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetUsername() const { return Valid().username; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user discriminator (aka tag), 4 digits usually displayed with leading zeroes.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetDiscriminator() const { return static_cast< SQInteger >(Valid().discriminator); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user avatar hash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const dpp::utility::iconhash & GetAvatar() const { return Valid().avatar; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user flags built from a bitmask of values in dpp::user_flags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user feference count of how many guilds this user is in.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetRefCount() const { return static_cast< SQInteger >(Valid().refcount); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the avatar url of the user object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetAvatarURL() const { return Valid().get_avatar_url(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is a bot.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsBot() const { return Valid().is_bot(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is a system user (Clyde).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSystem() const { return Valid().is_system(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has multi-factor authentication enabled.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsMfaEnabled() const { return Valid().is_mfa_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has verified account.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerified() const { return Valid().is_verified(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has full nitro.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasNitroFull() const { return Valid().has_nitro_full(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has nitro classic.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasNitroClassic() const { return Valid().has_nitro_classic(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is a discord employee.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDiscordEmployee() const { return Valid().is_discord_employee(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user owns a partnered server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPartneredOwner() const { return Valid().is_partnered_owner(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has hype-squad events.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasHypesquadEvents() const { return Valid().has_hypesquad_events(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has the bug-hunter level 1 badge.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsBughunter1() const { return Valid().is_bughunter_1(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is in house bravery.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHouseBravery() const { return Valid().is_house_bravery(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is in house brilliance.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHouseBrilliance() const { return Valid().is_house_brilliance(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is in house balance.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHouseBalanace() const { return Valid().is_house_balanace(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is an early supporter.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsEarlySupporter() const { return Valid().is_early_supporter(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is a team user.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsTeamUser() const { return Valid().is_team_user(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has the bug-hunter level 2 badge.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsBughunter2() const { return Valid().is_bughunter_2(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has the verified bot badge.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerifiedBot() const { return Valid().is_verified_bot(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is an early verified bot developer.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerifiedBotDev() const { return Valid().is_verified_bot_dev(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user is a certified moderator.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsCertifiedDoderator() const { return Valid().is_certified_moderator(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check wether the user has an animated icon.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasAnimatedIcon() const { return Valid().has_animated_icon(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user