mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-19 03:57:14 +01:00
Compare commits
9 Commits
0f235ff6af
...
62b9504d43
Author | SHA1 | Date | |
---|---|---|---|
|
62b9504d43 | ||
|
26ccfa62b9 | ||
|
83f2ab79e0 | ||
|
57321af0c7 | ||
|
8d908208f0 | ||
|
87cb6a2cba | ||
|
0487f26865 | ||
|
e3c32e4788 | ||
|
b978bc5046 |
@ -150,6 +150,7 @@ if(ENABLE_DISCORD)
|
|||||||
Library/DPP/Other.cpp Library/DPP/Other.hpp
|
Library/DPP/Other.cpp Library/DPP/Other.hpp
|
||||||
Library/DPP/Role.cpp Library/DPP/Role.hpp
|
Library/DPP/Role.cpp Library/DPP/Role.hpp
|
||||||
Library/DPP/User.cpp Library/DPP/User.hpp
|
Library/DPP/User.cpp Library/DPP/User.hpp
|
||||||
|
Library/DPP/Utilities.cpp Library/DPP/Utilities.hpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
# Link to POCO libraries
|
# Link to POCO libraries
|
||||||
|
@ -192,7 +192,7 @@ static const EnumElement g_DpVoiceStateFlagsEnum[] = {
|
|||||||
{_SC("SelfDeaf"), static_cast< SQInteger >(dpp::vs_self_deaf)},
|
{_SC("SelfDeaf"), static_cast< SQInteger >(dpp::vs_self_deaf)},
|
||||||
{_SC("SelfStream"), static_cast< SQInteger >(dpp::vs_self_stream)},
|
{_SC("SelfStream"), static_cast< SQInteger >(dpp::vs_self_stream)},
|
||||||
{_SC("SelfVideo"), static_cast< SQInteger >(dpp::vs_self_video)},
|
{_SC("SelfVideo"), static_cast< SQInteger >(dpp::vs_self_video)},
|
||||||
{_SC("Supress"), static_cast< SQInteger >(dpp::vs_supress)},
|
{_SC("Suppress"), static_cast< SQInteger >(dpp::vs_suppress)},
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -350,7 +350,7 @@ static const EnumElement g_DpStickerFormatEnum[] = {
|
|||||||
static const EnumElement g_DpMessageFlagsEnum[] = {
|
static const EnumElement g_DpMessageFlagsEnum[] = {
|
||||||
{_SC("Crossposted"), static_cast< SQInteger >(dpp::m_crossposted)},
|
{_SC("Crossposted"), static_cast< SQInteger >(dpp::m_crossposted)},
|
||||||
{_SC("IsCrosspost"), static_cast< SQInteger >(dpp::m_is_crosspost)},
|
{_SC("IsCrosspost"), static_cast< SQInteger >(dpp::m_is_crosspost)},
|
||||||
{_SC("SupressEmbeds"), static_cast< SQInteger >(dpp::m_supress_embeds)},
|
{_SC("SuppressEmbeds"), static_cast< SQInteger >(dpp::m_suppress_embeds)},
|
||||||
{_SC("SourceMessageDeleted"), static_cast< SQInteger >(dpp::m_source_message_deleted)},
|
{_SC("SourceMessageDeleted"), static_cast< SQInteger >(dpp::m_source_message_deleted)},
|
||||||
{_SC("Urgent"), static_cast< SQInteger >(dpp::m_urgent)},
|
{_SC("Urgent"), static_cast< SQInteger >(dpp::m_urgent)},
|
||||||
{_SC("Ephemeral"), static_cast< SQInteger >(dpp::m_ephemeral)},
|
{_SC("Ephemeral"), static_cast< SQInteger >(dpp::m_ephemeral)},
|
||||||
|
@ -59,11 +59,7 @@ struct DpGuildMember
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpGuildMember() noexcept
|
~DpGuildMember() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -75,13 +71,24 @@ struct DpGuildMember
|
|||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
// Do we own this to try delete it?
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
Cleanup();
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -201,11 +208,7 @@ struct DpGuild
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpGuild() noexcept
|
~DpGuild() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -217,13 +220,24 @@ struct DpGuild
|
|||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
// Do we own this to try delete it?
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
Cleanup();
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
|
@ -6,7 +6,9 @@ namespace SqMod {
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQMOD_DECL_TYPENAME(SqDppSelectOption, _SC("SqDppSelectOption"))
|
SQMOD_DECL_TYPENAME(SqDppSelectOption, _SC("SqDppSelectOption"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppSelectOptions, _SC("SqDppSelectOptions"))
|
||||||
SQMOD_DECL_TYPENAME(SqDppComponent, _SC("SqDppComponent"))
|
SQMOD_DECL_TYPENAME(SqDppComponent, _SC("SqDppComponent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppComponents, _SC("SqDppComponents"))
|
||||||
SQMOD_DECL_TYPENAME(SqDppEmbedFooter, _SC("SqDppEmbedFooter"))
|
SQMOD_DECL_TYPENAME(SqDppEmbedFooter, _SC("SqDppEmbedFooter"))
|
||||||
SQMOD_DECL_TYPENAME(SqDppEmbedImage, _SC("SqDppEmbedImage"))
|
SQMOD_DECL_TYPENAME(SqDppEmbedImage, _SC("SqDppEmbedImage"))
|
||||||
SQMOD_DECL_TYPENAME(SqDppEmbedProvider, _SC("SqDppEmbedProvider"))
|
SQMOD_DECL_TYPENAME(SqDppEmbedProvider, _SC("SqDppEmbedProvider"))
|
||||||
@ -48,14 +50,39 @@ void Register_DPP_Message(HSQUIRRELVM vm, Table & ns)
|
|||||||
.FmtFunc(_SC("SetEmojiName"), &DpSelectOption::ApplyEmojiName)
|
.FmtFunc(_SC("SetEmojiName"), &DpSelectOption::ApplyEmojiName)
|
||||||
);
|
);
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_DPP_VectorProxy< dpp::select_option, DpSelectOption, SqDppSelectOptions >(vm, ns, _SC("SelectOptions"));
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
ns.Bind(_SC("Component"),
|
ns.Bind(_SC("Component"),
|
||||||
Class< DpComponent, NoConstructor< DpComponent > >(vm, SqDppComponent::Str)
|
Class< DpComponent, NoConstructor< DpComponent > >(vm, SqDppComponent::Str)
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &SqDppComponent::Fn)
|
.SquirrelFunc(_SC("_typename"), &SqDppComponent::Fn)
|
||||||
// Member Properties
|
// Member Properties
|
||||||
.Prop(_SC("Valid"), &DpComponent::IsValid)
|
.Prop(_SC("Valid"), &DpComponent::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpComponent::BuildJSON)
|
||||||
|
.Prop(_SC("Type"), &DpComponent::GetType, &DpComponent::SetType)
|
||||||
|
.Prop(_SC("Label"), &DpComponent::GetLabel, &DpComponent::SetLabel)
|
||||||
|
.Prop(_SC("Style"), &DpComponent::GetStyle, &DpComponent::SetStyle)
|
||||||
|
.Prop(_SC("CustomID"), &DpComponent::GetCustomID, &DpComponent::SetCustomID)
|
||||||
|
.Prop(_SC("URL"), &DpComponent::GetURL, &DpComponent::SetURL)
|
||||||
|
.Prop(_SC("Placeholder"), &DpComponent::GetPlaceholder, &DpComponent::SetPlaceholder)
|
||||||
|
.Prop(_SC("MinValues"), &DpComponent::GetMinValues, &DpComponent::SetMinValues)
|
||||||
|
.Prop(_SC("MaxValues"), &DpComponent::GetMaxValues, &DpComponent::SetMaxValues)
|
||||||
|
.Prop(_SC("Disabled"), &DpComponent::IsDisabled, &DpComponent::SetDisabled)
|
||||||
|
.Prop(_SC("IsAnimated"), &DpComponent::IsAnimated, &DpComponent::SetAnimated)
|
||||||
|
.Prop(_SC("EmojiName"), &DpComponent::GetEmojiName, &DpComponent::SetEmojiName)
|
||||||
|
.Prop(_SC("EmojiID"), &DpComponent::GetEmojiID, &DpComponent::SetEmojiID)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetLabel"), &DpComponent::ApplyLabel)
|
||||||
|
.FmtFunc(_SC("SetCustomID"), &DpComponent::ApplyCustomID)
|
||||||
|
.FmtFunc(_SC("SetURL"), &DpComponent::ApplyURL)
|
||||||
|
.FmtFunc(_SC("SetPlaceholder"), &DpComponent::ApplyPlaceholder)
|
||||||
|
.FmtFunc(_SC("SetDisabled"), &DpComponent::SetDisabled)
|
||||||
|
.FmtFunc(_SC("SetAnimated"), &DpComponent::SetAnimated)
|
||||||
|
.FmtFunc(_SC("SetEmojiName"), &DpComponent::ApplyEmojiName)
|
||||||
);
|
);
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_DPP_VectorProxy< dpp::component, DpComponent, SqDppComponent >(vm, ns, _SC("Components"));
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
ns.Bind(_SC("EmbedFooter"),
|
ns.Bind(_SC("EmbedFooter"),
|
||||||
Class< DpEmbedFooter, NoConstructor< DpEmbedFooter > >(vm, SqDppEmbedFooter::Str)
|
Class< DpEmbedFooter, NoConstructor< DpEmbedFooter > >(vm, SqDppEmbedFooter::Str)
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Utility.hpp"
|
#include "Library/DPP/Utilities.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -73,11 +73,7 @@ struct DpSelectOption
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpSelectOption() noexcept
|
~DpSelectOption() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -88,14 +84,24 @@ struct DpSelectOption
|
|||||||
DpSelectOption & operator = (DpSelectOption && o) noexcept
|
DpSelectOption & operator = (DpSelectOption && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -213,6 +219,12 @@ struct DpComponent
|
|||||||
* Whether the referenced pointer is owned.
|
* Whether the referenced pointer is owned.
|
||||||
*/
|
*/
|
||||||
bool mOwned{false};
|
bool mOwned{false};
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
using Components = DpVectorProxy< dpp::component, DpComponent >;
|
||||||
|
using Options = DpVectorProxy< dpp::select_option, DpSelectOption >;
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
LightObj mSqComponents{};
|
||||||
|
LightObj mSqOptions{};
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
@ -246,11 +258,7 @@ struct DpComponent
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpComponent() noexcept
|
~DpComponent() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -261,14 +269,38 @@ struct DpComponent
|
|||||||
DpComponent & operator = (DpComponent && o) noexcept
|
DpComponent & operator = (DpComponent && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Cleanup components, if any
|
||||||
|
if (!mSqComponents.IsNull())
|
||||||
|
{
|
||||||
|
mSqComponents.CastI< Components >()->Cleanup();
|
||||||
|
// Release script resources
|
||||||
|
mSqComponents.Release();
|
||||||
|
}
|
||||||
|
// Cleanup options, if any
|
||||||
|
if (!mSqOptions.IsNull())
|
||||||
|
{
|
||||||
|
mSqOptions.CastI< Components >()->Cleanup();
|
||||||
|
// Release script resources
|
||||||
|
mSqOptions.Release();
|
||||||
|
}
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -281,7 +313,164 @@ struct DpComponent
|
|||||||
* Check whether a valid instance is managed.
|
* Check whether a valid instance is managed.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build JSON string from this object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated type.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetType() const { return static_cast< SQInteger >(Valid().type); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated type.
|
||||||
|
*/
|
||||||
|
void SetType(SQInteger type) const { Valid().set_type(static_cast< dpp::component_type >(type)); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated label.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetLabel() const { return Valid().label; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated label.
|
||||||
|
*/
|
||||||
|
void SetLabel(StackStrF & label) const { Valid().set_label(label.ToStr()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated label.
|
||||||
|
*/
|
||||||
|
DpComponent & ApplyLabel(StackStrF & label) { SetLabel(label); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated style.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetStyle() const { return static_cast< SQInteger >(Valid().style); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated style.
|
||||||
|
*/
|
||||||
|
void SetStyle(SQInteger style) const { Valid().set_style(static_cast< dpp::component_style >(style)); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated custom id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetCustomID() const { return Valid().custom_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated custom id.
|
||||||
|
*/
|
||||||
|
void SetCustomID(StackStrF & custom_id) const { Valid().set_label(custom_id.ToStr()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated custom id.
|
||||||
|
*/
|
||||||
|
DpComponent & ApplyCustomID(StackStrF & custom_id) { SetCustomID(custom_id); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated URL.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetURL() const { return Valid().url; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated URL.
|
||||||
|
*/
|
||||||
|
void SetURL(StackStrF & url) const { Valid().set_label(url.ToStr()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated URL.
|
||||||
|
*/
|
||||||
|
DpComponent & ApplyURL(StackStrF & url) { SetURL(url); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated placeholder.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetPlaceholder() const { return Valid().placeholder; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated placeholder.
|
||||||
|
*/
|
||||||
|
void SetPlaceholder(StackStrF & placeholder) const { Valid().set_label(placeholder.ToStr()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated placeholder.
|
||||||
|
*/
|
||||||
|
DpComponent & ApplyPlaceholder(StackStrF & placeholder) { SetPlaceholder(placeholder); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated minimum values.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMinValues() const { return static_cast< SQInteger >(Valid().min_values); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated minimum values.
|
||||||
|
*/
|
||||||
|
void SetMinValues(SQInteger value) const { Valid().set_min_values(static_cast< uint32_t >(value)); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated maximum values.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMaxValues() const { return static_cast< SQInteger >(Valid().max_values); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated maximum values.
|
||||||
|
*/
|
||||||
|
void SetMaxValues(SQInteger value) const { Valid().set_max_values(static_cast< uint32_t >(value)); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether this component is disabled.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDisabled() const { return Valid().disabled; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify whether this component is disabled.
|
||||||
|
*/
|
||||||
|
DpComponent & SetDisabled(bool toggle) { Valid().set_disabled(toggle); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated emoji.
|
||||||
|
*/
|
||||||
|
DpComponent & SetEmoji(StackStrF & name, dpp::snowflake id, bool animated) { Valid().set_emoji(name.ToStr(), id, animated); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the emoji is animated.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsAnimated() const { return Valid().emoji.animated; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify whether the emoji is animated.
|
||||||
|
*/
|
||||||
|
DpComponent & SetAnimated(bool anim) { Valid().emoji.animated = anim; return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated emoji name.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetEmojiName() const { return Valid().emoji.name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated emoji name.
|
||||||
|
*/
|
||||||
|
void SetEmojiName(StackStrF & name) const
|
||||||
|
{
|
||||||
|
if (name.mLen > 0)
|
||||||
|
{
|
||||||
|
Valid().emoji.name.assign(name.mPtr, static_cast< size_t >(name.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Valid().emoji.name.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated emoji name.
|
||||||
|
*/
|
||||||
|
DpComponent & ApplyEmojiName(StackStrF & name) { SetEmojiName(name); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated emoji id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetEmojiID() const { return Valid().emoji.id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated emoji id.
|
||||||
|
*/
|
||||||
|
void SetEmojiID(dpp::snowflake id) const { Valid().emoji.id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated components.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetComponents()
|
||||||
|
{
|
||||||
|
if (mSqComponents.IsNull())
|
||||||
|
{
|
||||||
|
mSqComponents = LightObj{SqTypeIdentity< Components >{}, SqVM(), &Valid().components, false};
|
||||||
|
}
|
||||||
|
// Return the associated script object
|
||||||
|
return mSqComponents;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated components.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetOptions()
|
||||||
|
{
|
||||||
|
if (mSqOptions.IsNull())
|
||||||
|
{
|
||||||
|
mSqOptions = LightObj{SqTypeIdentity< Options >{}, SqVM(), &Valid().options, false};
|
||||||
|
}
|
||||||
|
// Return the associated script object
|
||||||
|
return mSqOptions;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@ -331,11 +520,7 @@ struct DpEmbedFooter
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpEmbedFooter() noexcept
|
~DpEmbedFooter() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -346,14 +531,24 @@ struct DpEmbedFooter
|
|||||||
DpEmbedFooter & operator = (DpEmbedFooter && o) noexcept
|
DpEmbedFooter & operator = (DpEmbedFooter && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -416,11 +611,7 @@ struct DpEmbedImage
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpEmbedImage() noexcept
|
~DpEmbedImage() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -431,14 +622,24 @@ struct DpEmbedImage
|
|||||||
DpEmbedImage & operator = (DpEmbedImage && o) noexcept
|
DpEmbedImage & operator = (DpEmbedImage && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -501,11 +702,7 @@ struct DpEmbedProvider
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpEmbedProvider() noexcept
|
~DpEmbedProvider() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -516,14 +713,24 @@ struct DpEmbedProvider
|
|||||||
DpEmbedProvider & operator = (DpEmbedProvider && o) noexcept
|
DpEmbedProvider & operator = (DpEmbedProvider && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -586,11 +793,7 @@ struct DpEmbedAuthor
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpEmbedAuthor() noexcept
|
~DpEmbedAuthor() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -601,14 +804,24 @@ struct DpEmbedAuthor
|
|||||||
DpEmbedAuthor & operator = (DpEmbedAuthor && o) noexcept
|
DpEmbedAuthor & operator = (DpEmbedAuthor && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -671,11 +884,7 @@ struct DpEmbedField
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpEmbedField() noexcept
|
~DpEmbedField() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -686,14 +895,24 @@ struct DpEmbedField
|
|||||||
DpEmbedField & operator = (DpEmbedField && o) noexcept
|
DpEmbedField & operator = (DpEmbedField && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -756,11 +975,7 @@ struct DpEmbed
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpEmbed() noexcept
|
~DpEmbed() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -771,14 +986,24 @@ struct DpEmbed
|
|||||||
DpEmbed & operator = (DpEmbed && o) noexcept
|
DpEmbed & operator = (DpEmbed && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -841,11 +1066,7 @@ struct DpReaction
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpReaction() noexcept
|
~DpReaction() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -856,14 +1077,24 @@ struct DpReaction
|
|||||||
DpReaction & operator = (DpReaction && o) noexcept
|
DpReaction & operator = (DpReaction && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -926,11 +1157,7 @@ struct DpAttachment
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpAttachment() noexcept
|
~DpAttachment() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -941,14 +1168,24 @@ struct DpAttachment
|
|||||||
DpAttachment & operator = (DpAttachment && o) noexcept
|
DpAttachment & operator = (DpAttachment && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -1011,11 +1248,7 @@ struct DpSticker
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpSticker() noexcept
|
~DpSticker() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -1026,14 +1259,24 @@ struct DpSticker
|
|||||||
DpSticker & operator = (DpSticker && o) noexcept
|
DpSticker & operator = (DpSticker && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -1096,11 +1339,7 @@ struct DpStickerPack
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpStickerPack() noexcept
|
~DpStickerPack() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -1111,14 +1350,24 @@ struct DpStickerPack
|
|||||||
DpStickerPack & operator = (DpStickerPack && o) noexcept
|
DpStickerPack & operator = (DpStickerPack && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -1181,11 +1430,7 @@ struct DpMessage
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpMessage() noexcept
|
~DpMessage() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -1196,14 +1441,24 @@ struct DpMessage
|
|||||||
DpMessage & operator = (DpMessage && o) noexcept
|
DpMessage & operator = (DpMessage && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
|
@ -134,7 +134,7 @@ void Register_DPP_Other(HSQUIRRELVM vm, Table & ns)
|
|||||||
.Prop(_SC("IsSelfDeaf"), &DpVoiceState::IsSelfDeaf)
|
.Prop(_SC("IsSelfDeaf"), &DpVoiceState::IsSelfDeaf)
|
||||||
.Prop(_SC("SelfStream"), &DpVoiceState::SelfStream)
|
.Prop(_SC("SelfStream"), &DpVoiceState::SelfStream)
|
||||||
.Prop(_SC("SelfVideo"), &DpVoiceState::SelfVideo)
|
.Prop(_SC("SelfVideo"), &DpVoiceState::SelfVideo)
|
||||||
.Prop(_SC("IsSupressed"), &DpVoiceState::IsSupressed)
|
.Prop(_SC("IsSuppressed"), &DpVoiceState::IsSuppressed)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,11 +114,7 @@ struct DpActivity
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpActivity() noexcept
|
~DpActivity() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -129,14 +125,24 @@ struct DpActivity
|
|||||||
DpActivity & operator = (DpActivity && o) noexcept
|
DpActivity & operator = (DpActivity && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -302,11 +308,7 @@ struct DpPresence
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpPresence() noexcept
|
~DpPresence() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -317,14 +319,24 @@ struct DpPresence
|
|||||||
DpPresence & operator = (DpPresence && o) noexcept
|
DpPresence & operator = (DpPresence && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -489,11 +501,7 @@ struct DpVoiceState
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpVoiceState() noexcept
|
~DpVoiceState() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -504,14 +512,24 @@ struct DpVoiceState
|
|||||||
DpVoiceState & operator = (DpVoiceState && o) noexcept
|
DpVoiceState & operator = (DpVoiceState && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
@ -579,7 +597,7 @@ struct DpVoiceState
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Check if user is surpressed.
|
* Check if user is surpressed.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD bool IsSupressed() const { return Valid().is_supressed(); }
|
SQMOD_NODISCARD bool IsSuppressed() const { return Valid().is_suppressed(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
@ -59,11 +59,7 @@ struct DpRole
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpRole() noexcept
|
~DpRole() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -74,14 +70,24 @@ struct DpRole
|
|||||||
DpRole & operator = (DpRole && o) noexcept
|
DpRole & operator = (DpRole && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
|
@ -56,11 +56,7 @@ struct DpUser
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~DpUser() noexcept
|
~DpUser() noexcept { Cleanup(); }
|
||||||
{
|
|
||||||
// Do we own this to try delete it?
|
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
}
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
* Copy assignment operator (disabled).
|
||||||
*/
|
*/
|
||||||
@ -71,14 +67,24 @@ struct DpUser
|
|||||||
DpUser & operator = (DpUser && o) noexcept
|
DpUser & operator = (DpUser && o) noexcept
|
||||||
{
|
{
|
||||||
if (this != &o) {
|
if (this != &o) {
|
||||||
// Do we own this to try delete it?
|
Cleanup();
|
||||||
if (!mOwned && mPtr) [[maybe_unused]] auto p = mPtr.release();
|
|
||||||
// Transfer members values
|
// Transfer members values
|
||||||
mPtr = std::move(o.mPtr);
|
mPtr = std::move(o.mPtr);
|
||||||
mOwned = o.mOwned;
|
mOwned = o.mOwned;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed handle.
|
* Validate the managed handle.
|
||||||
*/
|
*/
|
||||||
|
12
module/Library/DPP/Utilities.cpp
Normal file
12
module/Library/DPP/Utilities.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Utilities.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
415
module/Library/DPP/Utilities.hpp
Normal file
415
module/Library/DPP/Utilities.hpp
Normal file
@ -0,0 +1,415 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Wrapper around a std::vector of DPP values.
|
||||||
|
*/
|
||||||
|
template < class T, class W > struct DpVectorProxy
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< std::vector< T > >;
|
||||||
|
using Vec = std::vector< std::pair< LightObj, W * > >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced vector instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Cached script objects vector.
|
||||||
|
*/
|
||||||
|
Vec mVec{};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpVectorProxy() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVectorProxy(typename Ptr::pointer ptr, bool owned = false)
|
||||||
|
: mPtr(ptr), mVec(), mOwned(owned)
|
||||||
|
{ if (mPtr) mVec.resize(mPtr->size()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVectorProxy(const typename Ptr::element_type & o) noexcept
|
||||||
|
: DpVectorProxy(new typename Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVectorProxy(typename Ptr::element_type && o) noexcept
|
||||||
|
: DpVectorProxy(new typename Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpVectorProxy(const DpVectorProxy & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpVectorProxy(DpVectorProxy && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpVectorProxy() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpVectorProxy & operator = (const DpVectorProxy & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpVectorProxy & operator = (DpVectorProxy && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mVec = std::move(o.mVec);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Invalidate cached instances
|
||||||
|
ClearCache();
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord vector handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD typename Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure an index is within range and return the container. Container must exist.
|
||||||
|
*/
|
||||||
|
void ValidIdx_(SQInteger i)
|
||||||
|
{
|
||||||
|
if (static_cast< size_t >(i) >= Valid().size())
|
||||||
|
{
|
||||||
|
STHROWF("Invalid vector container index({})", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typename Ptr::element_type & ValidIdx(SQInteger i) { ValidIdx_(i); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure an index is within range and return the container. Container must exist.
|
||||||
|
*/
|
||||||
|
void ValidIdx_(SQInteger i) const
|
||||||
|
{
|
||||||
|
if (static_cast< size_t >(i) >= Valid().size())
|
||||||
|
{
|
||||||
|
STHROWF("Invalid vector container index({})", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const typename Ptr::element_type & ValidIdx(SQInteger i) const { ValidIdx_(i); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure a container instance is referenced and is populated, then return it.
|
||||||
|
*/
|
||||||
|
void ValidPop_()
|
||||||
|
{
|
||||||
|
if (Valid().empty())
|
||||||
|
{
|
||||||
|
STHROWF("Vector container is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typename Ptr::element_type & ValidPop() { ValidPop_(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure a container instance is referenced and is populated, then return it.
|
||||||
|
*/
|
||||||
|
void ValidPop_() const
|
||||||
|
{
|
||||||
|
if (Valid().empty())
|
||||||
|
{
|
||||||
|
STHROWF("Vector container is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const typename Ptr::element_type & ValidPop() const { ValidPop_(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if a container instance is referenced.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsNull() const { return !mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a value from the container.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & Get_(SQInteger i)
|
||||||
|
{
|
||||||
|
// Is the element cached?
|
||||||
|
if (mVec[static_cast< size_t >(i)].first.IsNull())
|
||||||
|
{
|
||||||
|
mVec[static_cast< size_t >(i)] = Obj(&mPtr->at(static_cast< size_t >(i)));
|
||||||
|
}
|
||||||
|
// Return the object from the cache
|
||||||
|
return mVec[static_cast< size_t >(i)].first;
|
||||||
|
}
|
||||||
|
SQMOD_NODISCARD LightObj & Get(SQInteger i) { ValidIdx_(i); return Get_(i); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify a value from the container.
|
||||||
|
*/
|
||||||
|
void Set(SQInteger i, const W & v) { ValidIdx(i)[static_cast< size_t >(i)] = v.Valid(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the container has no elements.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool Empty() const { return Valid().empty(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of elements in the container.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger Size() const { return static_cast< SQInteger >(Valid().size()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of elements that the container has currently allocated space for.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger Capacity() const { return static_cast< SQInteger >(Valid().capacity()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Synchronize cache container instances.
|
||||||
|
*/
|
||||||
|
void CacheSync()
|
||||||
|
{
|
||||||
|
// Invalidate cached instances, if any
|
||||||
|
for (size_t i = 0; i < mVec.size(); ++i)
|
||||||
|
{
|
||||||
|
// Is this element cached?
|
||||||
|
if (mVec[i].second != nullptr)
|
||||||
|
{
|
||||||
|
// Discard previous instance, if any
|
||||||
|
[[maybe_unused]] auto _ = mVec[i].second->mPtr.release();
|
||||||
|
// Sync to new instance
|
||||||
|
mVec[i].second->mPtr.reset(&mPtr->at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Increase the capacity of the container to a value that's greater or equal to the one specified.
|
||||||
|
*/
|
||||||
|
DpVectorProxy & Reserve(SQInteger n)
|
||||||
|
{
|
||||||
|
Valid().reserve(ClampL< SQInteger, size_t >(n));
|
||||||
|
mVec.reserve(mPtr->size());
|
||||||
|
CacheSync();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Request the removal of unused capacity.
|
||||||
|
*/
|
||||||
|
void Compact() { Valid().shrink_to_fit(); CacheSync(); mVec.shrink_to_fit(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Erase all elements from the cache container.
|
||||||
|
*/
|
||||||
|
void ClearCache()
|
||||||
|
{
|
||||||
|
// Invalidate cached instances, if any
|
||||||
|
for (auto & e : mVec)
|
||||||
|
{
|
||||||
|
// Is this element cached?
|
||||||
|
if (e.second != nullptr)
|
||||||
|
{
|
||||||
|
// Invalidate the instance
|
||||||
|
e.second->Cleanup();
|
||||||
|
// Forget about it
|
||||||
|
e.second = nullptr;
|
||||||
|
// Release script object
|
||||||
|
e.first.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear the cache vector
|
||||||
|
mVec.clear();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Erase all elements from the container.
|
||||||
|
*/
|
||||||
|
void Clear() { Validate(); ClearCache(); mPtr->clear(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Push a value at the back of the container.
|
||||||
|
*/
|
||||||
|
void Push(const W & v)
|
||||||
|
{
|
||||||
|
Valid().push_back(v.Valid());
|
||||||
|
mVec.emplace_back();
|
||||||
|
CacheSync();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Extends the Container by appending all the items in the given container.
|
||||||
|
*/
|
||||||
|
void Extend(DpVectorProxy & v)
|
||||||
|
{
|
||||||
|
Valid().insert(Valid().end(), v.Valid().begin(), v.Valid().end());
|
||||||
|
mVec.resize(mPtr->size());
|
||||||
|
CacheSync();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Pop the last element in the container.
|
||||||
|
*/
|
||||||
|
void Pop()
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
// Is this element cached?
|
||||||
|
if (mVec.back().second != nullptr)
|
||||||
|
{
|
||||||
|
// Invalidate the instance
|
||||||
|
mVec.back().second->Cleanup();
|
||||||
|
mVec.back().first.Release();
|
||||||
|
}
|
||||||
|
// Safe to remove
|
||||||
|
mPtr->pop_back();
|
||||||
|
mVec.pop_back();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Erase the element at a certain position.
|
||||||
|
*/
|
||||||
|
void EraseAt(SQInteger i)
|
||||||
|
{
|
||||||
|
ValidIdx_(i);
|
||||||
|
// Is this element cached?
|
||||||
|
if (mVec[static_cast< size_t >(i)].second != nullptr)
|
||||||
|
{
|
||||||
|
// Invalidate the instance
|
||||||
|
mVec[static_cast< size_t >(i)].second->Cleanup();
|
||||||
|
mVec[static_cast< size_t >(i)].first.Release();
|
||||||
|
}
|
||||||
|
// Safe to remove
|
||||||
|
mPtr->erase(mPtr->begin() + static_cast< size_t >(i));
|
||||||
|
mVec.erase(mVec.begin() + static_cast< size_t >(i));
|
||||||
|
// Synchronize cache
|
||||||
|
CacheSync();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate all values through a functor.
|
||||||
|
*/
|
||||||
|
void Each(Function & fn)
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
// Iterate referenced vector elements
|
||||||
|
for (size_t i = 0; i < mVec.size(); ++i)
|
||||||
|
{
|
||||||
|
fn.Execute(Get(static_cast< SQInteger >(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate values in range through a functor.
|
||||||
|
*/
|
||||||
|
void EachRange(SQInteger p, SQInteger n, Function & fn)
|
||||||
|
{
|
||||||
|
ValidIdx_(p);
|
||||||
|
ValidIdx_(p + n);
|
||||||
|
// Iterate specified range
|
||||||
|
for (n += p; p < n; ++p)
|
||||||
|
{
|
||||||
|
fn.Execute(Get(static_cast< SQInteger >(p)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate all values through a functor until stopped (i.e false is returned).
|
||||||
|
*/
|
||||||
|
void While(Function & fn)
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
// Iterate referenced vector elements
|
||||||
|
for (size_t i = 0; i < mVec.size(); ++i)
|
||||||
|
{
|
||||||
|
auto ret = fn.Eval(Get(static_cast< SQInteger >(i)));
|
||||||
|
// (null || true) == continue & false == break
|
||||||
|
if (!ret.IsNull() || !ret.template Cast< bool >())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate values in range through a functor until stopped (i.e false is returned).
|
||||||
|
*/
|
||||||
|
void WhileRange(SQInteger p, SQInteger n, Function & fn)
|
||||||
|
{
|
||||||
|
ValidIdx_(p);
|
||||||
|
ValidIdx_(p + n);
|
||||||
|
// Iterate specified range
|
||||||
|
for (n += p; p < n; ++p)
|
||||||
|
{
|
||||||
|
auto ret = fn.Eval(Get(static_cast< SQInteger >(p)));
|
||||||
|
// (null || true) == continue & false == break
|
||||||
|
if (!ret.IsNull() || !ret.template Cast< bool >())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a wrapped instance as a script object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD static std::pair< LightObj, W * > Obj(T * ptr, bool owned = false)
|
||||||
|
{
|
||||||
|
// Create the wrapper instance for given pointer
|
||||||
|
auto wp = std::make_unique< W >(ptr, false);
|
||||||
|
// Create script object for wrapper instance
|
||||||
|
std::pair< LightObj, W * > p{LightObj{wp.get()}, wp.get()};
|
||||||
|
// Release ownership of the wrapper instance
|
||||||
|
[[maybe_unused]] auto _ = wp.release();
|
||||||
|
// Return the script object and wrapper instance
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a wrapped instance as a script object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD static std::pair< LightObj, W * > Obj(const T * ptr, bool owned = false)
|
||||||
|
{
|
||||||
|
return Obj(const_cast< T * >(ptr), owned);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < class T, class W, class U > inline void Register_DPP_VectorProxy(HSQUIRRELVM vm, Table & ns, const SQChar * name)
|
||||||
|
{
|
||||||
|
using Container = DpVectorProxy< T, W >;
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(name,
|
||||||
|
Class< Container, NoConstructor< Container > >(vm, U::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &U::Fn)
|
||||||
|
// Properties
|
||||||
|
.Prop(_SC("Null"), &Container::IsNull)
|
||||||
|
.Prop(_SC("Empty"), &Container::Empty)
|
||||||
|
.Prop(_SC("Size"), &Container::Size)
|
||||||
|
.Prop(_SC("Capacity"), &Container::Capacity, &Container::Reserve)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Get"), &Container::Get)
|
||||||
|
.Func(_SC("Set"), &Container::Set)
|
||||||
|
.Func(_SC("Reserve"), &Container::Reserve)
|
||||||
|
.Func(_SC("Compact"), &Container::Compact)
|
||||||
|
.Func(_SC("Clear"), &Container::Clear)
|
||||||
|
.Func(_SC("Push"), &Container::Push)
|
||||||
|
.Func(_SC("Append"), &Container::Push)
|
||||||
|
.Func(_SC("Extend"), &Container::Extend)
|
||||||
|
.Func(_SC("Pop"), &Container::Pop)
|
||||||
|
.Func(_SC("EraseAt"), &Container::EraseAt)
|
||||||
|
.Func(_SC("Each"), &Container::Each)
|
||||||
|
.Func(_SC("EachRange"), &Container::EachRange)
|
||||||
|
.Func(_SC("While"), &Container::While)
|
||||||
|
.Func(_SC("WhileRange"), &Container::WhileRange)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
2
vendor/DPP/include/dpp/cache.h
vendored
2
vendor/DPP/include/dpp/cache.h
vendored
@ -88,7 +88,7 @@ namespace dpp {
|
|||||||
* @brief Get the container map
|
* @brief Get the container map
|
||||||
* @warning Be sure to use cache::get_mutex() correctly if you
|
* @warning Be sure to use cache::get_mutex() correctly if you
|
||||||
* manipulate or iterate the map returned by this method! If you do
|
* manipulate or iterate the map returned by this method! If you do
|
||||||
* not, this is not thread safe and will casue crashes!
|
* not, this is not thread safe and will cause crashes!
|
||||||
* @see cache::get_mutex
|
* @see cache::get_mutex
|
||||||
*
|
*
|
||||||
* @return cache_container& A reference to the cache's container map
|
* @return cache_container& A reference to the cache's container map
|
||||||
|
6
vendor/DPP/include/dpp/cluster.h
vendored
6
vendor/DPP/include/dpp/cluster.h
vendored
@ -290,8 +290,8 @@ public:
|
|||||||
* @param shards The total number of shards on this bot. If there are multiple clusters, then (shards / clusters) actual shards will run on this cluster.
|
* @param shards The total number of shards on this bot. If there are multiple clusters, then (shards / clusters) actual shards will run on this cluster.
|
||||||
* If you omit this value, the library will attempt to query the Discord API for the correct number of shards to start.
|
* If you omit this value, the library will attempt to query the Discord API for the correct number of shards to start.
|
||||||
* @param cluster_id The ID of this cluster, should be between 0 and MAXCLUSTERS-1
|
* @param cluster_id The ID of this cluster, should be between 0 and MAXCLUSTERS-1
|
||||||
* @param maxclusters The total number of clusters that are active, which may be on seperate processes or even separate machines.
|
* @param maxclusters The total number of clusters that are active, which may be on separate processes or even separate machines.
|
||||||
* @param compressed Wether or not to use compression for shards on this cluster. Saves a ton of bandwidth at the cost of some CPU
|
* @param compressed Whether or not to use compression for shards on this cluster. Saves a ton of bandwidth at the cost of some CPU
|
||||||
* @param policy Set the user caching policy for the cluster, either lazy (only cache users/members when they message the bot) or aggressive (request whole member lists on seeing new guilds too)
|
* @param policy Set the user caching policy for the cluster, either lazy (only cache users/members when they message the bot) or aggressive (request whole member lists on seeing new guilds too)
|
||||||
*/
|
*/
|
||||||
cluster(const std::string &token, uint32_t intents = i_default_intents, uint32_t shards = 0, uint32_t cluster_id = 0, uint32_t maxclusters = 1, bool compressed = true, cache_policy_t policy = {cp_aggressive, cp_aggressive, cp_aggressive});
|
cluster(const std::string &token, uint32_t intents = i_default_intents, uint32_t shards = 0, uint32_t cluster_id = 0, uint32_t maxclusters = 1, bool compressed = true, cache_policy_t policy = {cp_aggressive, cp_aggressive, cp_aggressive});
|
||||||
@ -1968,7 +1968,7 @@ public:
|
|||||||
void thread_create(const std::string& thread_name, snowflake channel_id, uint16_t auto_archive_duration, channel_type thread_type, command_completion_event_t callback = {});
|
void thread_create(const std::string& thread_name, snowflake channel_id, uint16_t auto_archive_duration, channel_type thread_type, command_completion_event_t callback = {});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a thread with a message (Discord: ID of a thread is same as mesage ID)
|
* @brief Create a thread with a message (Discord: ID of a thread is same as message ID)
|
||||||
*
|
*
|
||||||
* @param thread_name Name of the thread
|
* @param thread_name Name of the thread
|
||||||
* @param channel_id Channel in which thread to create
|
* @param channel_id Channel in which thread to create
|
||||||
|
40
vendor/DPP/include/dpp/commandhandler.h
vendored
40
vendor/DPP/include/dpp/commandhandler.h
vendored
@ -30,11 +30,29 @@
|
|||||||
|
|
||||||
namespace dpp {
|
namespace dpp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief dpp::resolved_user contains both a dpp::guild_member and a dpp::user.
|
||||||
|
* The user can be used to obtain in-depth user details such as if they are nitro,
|
||||||
|
* and the guild member information to check their roles on a guild etc.
|
||||||
|
* The Discord API provides both if a parameter is a user ping,
|
||||||
|
* so we offer both in a combined structure.
|
||||||
|
*/
|
||||||
|
struct CoreExport resolved_user {
|
||||||
|
/**
|
||||||
|
* @brief Holds user information
|
||||||
|
*/
|
||||||
|
dpp::user user;
|
||||||
|
/**
|
||||||
|
* @brief Holds member information
|
||||||
|
*/
|
||||||
|
dpp::guild_member member;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Represents a received parameter.
|
* @brief Represents a received parameter.
|
||||||
* We use variant so that multiple non-related types can be contained within.
|
* We use variant so that multiple non-related types can be contained within.
|
||||||
*/
|
*/
|
||||||
typedef std::variant<std::string, dpp::role, dpp::channel, dpp::user, int32_t, bool> command_parameter;
|
typedef std::variant<std::monostate, std::string, dpp::role, dpp::channel, dpp::resolved_user, int32_t, bool> command_parameter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parameter types when registering a command.
|
* @brief Parameter types when registering a command.
|
||||||
@ -102,7 +120,7 @@ typedef std::vector<std::pair<std::string, param_info>> parameter_registration_t
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parameter list for a called command.
|
* @brief Parameter list for a called command.
|
||||||
* See dpp::parameter_registration_t for an explaination as to why vector is used.
|
* See dpp::parameter_registration_t for an explanation as to why vector is used.
|
||||||
*/
|
*/
|
||||||
typedef std::vector<std::pair<std::string, command_parameter>> parameter_list_t;
|
typedef std::vector<std::pair<std::string, command_parameter>> parameter_list_t;
|
||||||
|
|
||||||
@ -277,9 +295,25 @@ public:
|
|||||||
* to the user if you do not emit some form of reply within 3 seconds.
|
* to the user if you do not emit some form of reply within 3 seconds.
|
||||||
*
|
*
|
||||||
* @param m message to reply with.
|
* @param m message to reply with.
|
||||||
* @param interaction true if the reply is generated by an interaction
|
* @param source source of the command
|
||||||
*/
|
*/
|
||||||
void reply(const dpp::message &m, command_source source);
|
void reply(const dpp::message &m, command_source source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reply to a command without a message, causing the discord client
|
||||||
|
* to display "Bot name is thinking...".
|
||||||
|
* The "thinking" message will persist for a maximum of 15 minutes.
|
||||||
|
* This counts as a reply for a slash command. Slash commands will emit an
|
||||||
|
* ugly error to the user if you do not emit some form of reply within 3
|
||||||
|
* seconds.
|
||||||
|
*
|
||||||
|
* @param source source of the command
|
||||||
|
*/
|
||||||
|
void thinking(command_source source);
|
||||||
|
|
||||||
|
/* Easter egg */
|
||||||
|
void thonk(command_source source);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
4
vendor/DPP/include/dpp/discord.h
vendored
4
vendor/DPP/include/dpp/discord.h
vendored
@ -186,7 +186,7 @@ namespace dpp {
|
|||||||
* @brief Convert a byte count to display value
|
* @brief Convert a byte count to display value
|
||||||
*
|
*
|
||||||
* @param c number of bytes
|
* @param c number of bytes
|
||||||
* @return std::string display value suffixed with M, G, T where neccessary
|
* @return std::string display value suffixed with M, G, T where necessary
|
||||||
*/
|
*/
|
||||||
std::string CoreExport bytes(uint64_t c);
|
std::string CoreExport bytes(uint64_t c);
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ namespace dpp {
|
|||||||
* @param str string to return substring from
|
* @param str string to return substring from
|
||||||
* @param start start codepoint offset
|
* @param start start codepoint offset
|
||||||
* @param length length in codepoints
|
* @param length length in codepoints
|
||||||
* @return std::string Substring in UTF-8 or emtpy string if invalid UTF-8 passed in
|
* @return std::string Substring in UTF-8 or empty string if invalid UTF-8 passed in
|
||||||
*/
|
*/
|
||||||
std::string CoreExport utf8substr(const std::string& str, std::string::size_type start, std::string::size_type length);
|
std::string CoreExport utf8substr(const std::string& str, std::string::size_type start, std::string::size_type length);
|
||||||
};
|
};
|
||||||
|
2
vendor/DPP/include/dpp/discordvoiceclient.h
vendored
2
vendor/DPP/include/dpp/discordvoiceclient.h
vendored
@ -201,7 +201,7 @@ class CoreExport discord_voice_client : public websocket_client
|
|||||||
int UDPSend(const char* data, size_t length);
|
int UDPSend(const char* data, size_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Receieve data from UDP socket immediately.
|
* @brief Receive data from UDP socket immediately.
|
||||||
*
|
*
|
||||||
* @param data data to receive
|
* @param data data to receive
|
||||||
* @param max_length size of data receiving buffer
|
* @param max_length size of data receiving buffer
|
||||||
|
2
vendor/DPP/include/dpp/dispatcher.h
vendored
2
vendor/DPP/include/dpp/dispatcher.h
vendored
@ -1095,7 +1095,7 @@ public:
|
|||||||
* @param event Event parameters
|
* @param event Event parameters
|
||||||
*/
|
*/
|
||||||
std::function<void(const voice_ready_t& event)> voice_ready;
|
std::function<void(const voice_ready_t& event)> voice_ready;
|
||||||
/** @brief Event handler function pointer for voice receieve event
|
/** @brief Event handler function pointer for voice receive event
|
||||||
* @param event Event parameters
|
* @param event Event parameters
|
||||||
*/
|
*/
|
||||||
std::function<void(const voice_receive_t& event)> voice_receive;
|
std::function<void(const voice_receive_t& event)> voice_receive;
|
||||||
|
2
vendor/DPP/include/dpp/guild.h
vendored
2
vendor/DPP/include/dpp/guild.h
vendored
@ -207,7 +207,7 @@ public:
|
|||||||
/** Setting for how notifications are to be delivered to users */
|
/** Setting for how notifications are to be delivered to users */
|
||||||
uint8_t default_message_notifications;
|
uint8_t default_message_notifications;
|
||||||
|
|
||||||
/** Wether or not explicit content filtering is enable and what setting it is */
|
/** Whether or not explicit content filtering is enable and what setting it is */
|
||||||
uint8_t explicit_content_filter;
|
uint8_t explicit_content_filter;
|
||||||
|
|
||||||
/** If multi factor authentication is required for moderators or not */
|
/** If multi factor authentication is required for moderators or not */
|
||||||
|
18
vendor/DPP/include/dpp/message.h
vendored
18
vendor/DPP/include/dpp/message.h
vendored
@ -474,7 +474,7 @@ struct CoreExport embed {
|
|||||||
/** Add an embed field. Returns the embed itself so these method calls may be "chained"
|
/** Add an embed field. Returns the embed itself so these method calls may be "chained"
|
||||||
* @param name The name of the field
|
* @param name The name of the field
|
||||||
* @param value The value of the field (max length 1000)
|
* @param value The value of the field (max length 1000)
|
||||||
* @param is_inline Wether or not to display the field 'inline' or on its own line
|
* @param is_inline Whether or not to display the field 'inline' or on its own line
|
||||||
* @return A reference to self
|
* @return A reference to self
|
||||||
*/
|
*/
|
||||||
embed& add_field(const std::string& name, const std::string &value, bool is_inline = false);
|
embed& add_field(const std::string& name, const std::string &value, bool is_inline = false);
|
||||||
@ -569,6 +569,8 @@ struct CoreExport attachment {
|
|||||||
uint32_t height;
|
uint32_t height;
|
||||||
/** MIME type of the attachment, if applicable */
|
/** MIME type of the attachment, if applicable */
|
||||||
std::string content_type;
|
std::string content_type;
|
||||||
|
/** Whether this attachment is ephemeral, if applicable */
|
||||||
|
bool ephemeral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructs a new attachment object.
|
* @brief Constructs a new attachment object.
|
||||||
@ -724,7 +726,7 @@ enum message_flags {
|
|||||||
/// this message originated from a message in another channel (via Channel Following)
|
/// this message originated from a message in another channel (via Channel Following)
|
||||||
m_is_crosspost = 1 << 1,
|
m_is_crosspost = 1 << 1,
|
||||||
/// do not include any embeds when serializing this message
|
/// do not include any embeds when serializing this message
|
||||||
m_supress_embeds = 1 << 2,
|
m_suppress_embeds = 1 << 2,
|
||||||
/// the source message for this crosspost has been deleted (via Channel Following)
|
/// the source message for this crosspost has been deleted (via Channel Following)
|
||||||
m_source_message_deleted = 1 << 3,
|
m_source_message_deleted = 1 << 3,
|
||||||
/// this message came from the urgent message system
|
/// this message came from the urgent message system
|
||||||
@ -736,7 +738,7 @@ enum message_flags {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Mesage types for dpp::message::type
|
* @brief Message types for dpp::message::type
|
||||||
*/
|
*/
|
||||||
enum message_type {
|
enum message_type {
|
||||||
/// Default
|
/// Default
|
||||||
@ -970,9 +972,9 @@ struct CoreExport message {
|
|||||||
/**
|
/**
|
||||||
* @brief Set the allowed mentions object for pings on the message
|
* @brief Set the allowed mentions object for pings on the message
|
||||||
*
|
*
|
||||||
* @param _parse_users wether or not to parse users in the message content or embeds
|
* @param _parse_users whether or not to parse users in the message content or embeds
|
||||||
* @param _parse_roles wether or not to parse roles in the message content or embeds
|
* @param _parse_roles whether or not to parse roles in the message content or embeds
|
||||||
* @param _parse_everyone wether or not to parse everyone/here in the message content or embeds
|
* @param _parse_everyone whether or not to parse everyone/here in the message content or embeds
|
||||||
* @param _replied_user if set to true and this is a reply, then ping the user we reply to
|
* @param _replied_user if set to true and this is a reply, then ping the user we reply to
|
||||||
* @param users list of user ids to allow pings for
|
* @param users list of user ids to allow pings for
|
||||||
* @param roles list of role ids to allow pings for
|
* @param roles list of role ids to allow pings for
|
||||||
@ -982,7 +984,7 @@ struct CoreExport message {
|
|||||||
|
|
||||||
/** Fill this object from json.
|
/** Fill this object from json.
|
||||||
* @param j JSON object to fill from
|
* @param j JSON object to fill from
|
||||||
* @param cp Cache policy for user records, wether or not we cache users when a message is received
|
* @param cp Cache policy for user records, whether or not we cache users when a message is received
|
||||||
* @return A reference to self
|
* @return A reference to self
|
||||||
*/
|
*/
|
||||||
message& fill_from_json(nlohmann::json* j, cache_policy_t cp = {cp_aggressive, cp_aggressive, cp_aggressive});
|
message& fill_from_json(nlohmann::json* j, cache_policy_t cp = {cp_aggressive, cp_aggressive, cp_aggressive});
|
||||||
@ -1012,7 +1014,7 @@ struct CoreExport message {
|
|||||||
*
|
*
|
||||||
* @return true if embeds removed
|
* @return true if embeds removed
|
||||||
*/
|
*/
|
||||||
bool supress_embeds() const;
|
bool suppress_embeds() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief True if source message was deleted
|
* @brief True if source message was deleted
|
||||||
|
30
vendor/DPP/include/dpp/slashcommand.h
vendored
30
vendor/DPP/include/dpp/slashcommand.h
vendored
@ -54,8 +54,10 @@ enum command_option_type : uint8_t {
|
|||||||
* @brief This type is a variant that can hold any of the potential
|
* @brief This type is a variant that can hold any of the potential
|
||||||
* native data types represented by the enum above.
|
* native data types represented by the enum above.
|
||||||
* It is used in interactions.
|
* It is used in interactions.
|
||||||
|
*
|
||||||
|
* std::monostate indicates an invalid parameter value, e.g. an unfilled optional parameter.
|
||||||
*/
|
*/
|
||||||
typedef std::variant<std::string, int32_t, bool, snowflake> command_value;
|
typedef std::variant<std::monostate, std::string, int32_t, bool, snowflake> command_value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This struct represents choices in a multiple choice option
|
* @brief This struct represents choices in a multiple choice option
|
||||||
@ -157,8 +159,6 @@ void to_json(nlohmann::json& j, const command_option& opt);
|
|||||||
*/
|
*/
|
||||||
enum interaction_response_type {
|
enum interaction_response_type {
|
||||||
ir_pong = 1, //!< ACK a Ping
|
ir_pong = 1, //!< ACK a Ping
|
||||||
ir_acknowledge = 2, //!< DEPRECATED ACK a command without sending a message, eating the user's input
|
|
||||||
ir_channel_message = 3, //!< DEPRECATED respond with a message, eating the user's input
|
|
||||||
ir_channel_message_with_source = 4, //!< respond to an interaction with a message
|
ir_channel_message_with_source = 4, //!< respond to an interaction with a message
|
||||||
ir_deferred_channel_message_with_source = 5, //!< ACK an interaction and edit a response later, the user sees a loading state
|
ir_deferred_channel_message_with_source = 5, //!< ACK an interaction and edit a response later, the user sees a loading state
|
||||||
ir_deferred_update_message = 6, //!< for components, ACK an interaction and edit the original message later; the user does not see a loading state
|
ir_deferred_update_message = 6, //!< for components, ACK an interaction and edit the original message later; the user does not see a loading state
|
||||||
@ -226,11 +226,25 @@ struct CoreExport interaction_response {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resolved snowflake ids to usernames.
|
* @brief Resolved snowflake ids to users, guild members, roles and channels.
|
||||||
* TODO: Needs implementation. Not needed something that
|
|
||||||
* functions as we have cache.
|
|
||||||
*/
|
*/
|
||||||
struct CoreExport command_resolved {
|
struct CoreExport command_resolved {
|
||||||
|
/**
|
||||||
|
* @brief Resolved users
|
||||||
|
*/
|
||||||
|
std::map<dpp::snowflake, dpp::user> users;
|
||||||
|
/**
|
||||||
|
* @brief Resolved guild members
|
||||||
|
*/
|
||||||
|
std::map<dpp::snowflake, dpp::guild_member> members;
|
||||||
|
/**
|
||||||
|
* @brief Resolved roles
|
||||||
|
*/
|
||||||
|
std::map<dpp::snowflake, dpp::role> roles;
|
||||||
|
/**
|
||||||
|
* @brief Resolved channels
|
||||||
|
*/
|
||||||
|
std::map<dpp::snowflake, dpp::channel> channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -272,7 +286,6 @@ enum interaction_type {
|
|||||||
struct CoreExport command_interaction {
|
struct CoreExport command_interaction {
|
||||||
snowflake id; //!< the ID of the invoked command
|
snowflake id; //!< the ID of the invoked command
|
||||||
std::string name; //!< the name of the invoked command
|
std::string name; //!< the name of the invoked command
|
||||||
command_resolved resolved; //!< Optional: converted users + roles + channels
|
|
||||||
std::vector<command_data_option> options; //!< Optional: the params + values from the user
|
std::vector<command_data_option> options; //!< Optional: the params + values from the user
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -326,6 +339,7 @@ public:
|
|||||||
user usr; //!< Optional: user object for the invoking user, if invoked in a DM
|
user usr; //!< Optional: user object for the invoking user, if invoked in a DM
|
||||||
std::string token; //!< a continuation token for responding to the interaction
|
std::string token; //!< a continuation token for responding to the interaction
|
||||||
uint8_t version; //!< read-only property, always 1
|
uint8_t version; //!< read-only property, always 1
|
||||||
|
command_resolved resolved; //!< Resolved user/role etc
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fill object properties from JSON
|
* @brief Fill object properties from JSON
|
||||||
@ -513,7 +527,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable default permissions, command will be unusable unless
|
* @brief Disable default permissions, command will be unusable unless
|
||||||
* permissions are overriden with add_permission and
|
* permissions are overridden with add_permission and
|
||||||
* dpp::guild_command_edit_permissions
|
* dpp::guild_command_edit_permissions
|
||||||
*
|
*
|
||||||
* @return slashcommand& reference to self for chaining of calls
|
* @return slashcommand& reference to self for chaining of calls
|
||||||
|
6
vendor/DPP/include/dpp/version.h
vendored
6
vendor/DPP/include/dpp/version.h
vendored
@ -21,9 +21,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if !defined(DPP_VERSION_LONG)
|
#if !defined(DPP_VERSION_LONG)
|
||||||
#define DPP_VERSION_LONG 0x00090003
|
#define DPP_VERSION_LONG 0x00090004
|
||||||
#define DPP_VERSION_SHORT 090003
|
#define DPP_VERSION_SHORT 090004
|
||||||
#define DPP_VERSION_TEXT "D++ 9.0.3 (05-Sep-2021)"
|
#define DPP_VERSION_TEXT "D++ 9.0.5 (14-Sep-2021)"
|
||||||
|
|
||||||
#define DPP_VERSION_MAJOR ((DPP_VERSION_LONG & 0x00ff0000) >> 16)
|
#define DPP_VERSION_MAJOR ((DPP_VERSION_LONG & 0x00ff0000) >> 16)
|
||||||
#define DPP_VERSION_MINOR ((DPP_VERSION_LONG & 0x0000ff00) >> 8)
|
#define DPP_VERSION_MINOR ((DPP_VERSION_LONG & 0x0000ff00) >> 8)
|
||||||
|
8
vendor/DPP/include/dpp/voicestate.h
vendored
8
vendor/DPP/include/dpp/voicestate.h
vendored
@ -34,7 +34,7 @@ enum voicestate_flags {
|
|||||||
vs_self_deaf = 0b00001000, //!< Self Deafened
|
vs_self_deaf = 0b00001000, //!< Self Deafened
|
||||||
vs_self_stream = 0b00010000, //!< Self Streaming
|
vs_self_stream = 0b00010000, //!< Self Streaming
|
||||||
vs_self_video = 0b00100000, //!< Self Video
|
vs_self_video = 0b00100000, //!< Self Video
|
||||||
vs_supress = 0b01000000 //!< Supression
|
vs_suppress = 0b01000000 //!< Suppression
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,9 +94,9 @@ public:
|
|||||||
/// Return true if the user is in video
|
/// Return true if the user is in video
|
||||||
bool self_video() const;
|
bool self_video() const;
|
||||||
|
|
||||||
/// Return true if user is surpressed.
|
/// Return true if user is suppressed.
|
||||||
/// "HELP HELP I'M BEING SUPRESSED!"
|
/// "HELP HELP I'M BEING SUPPRESSED!"
|
||||||
bool is_supressed() const;
|
bool is_suppressed() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A container of voicestates */
|
/** A container of voicestates */
|
||||||
|
30
vendor/DPP/src/dpp/cluster.cpp
vendored
30
vendor/DPP/src/dpp/cluster.cpp
vendored
@ -327,7 +327,7 @@ void cluster::interaction_response_edit(const std::string &token, const message
|
|||||||
|
|
||||||
|
|
||||||
void cluster::global_command_create(slashcommand &s, command_completion_event_t callback) {
|
void cluster::global_command_create(slashcommand &s, command_completion_event_t callback) {
|
||||||
this->post_rest(API_PATH "/applications", std::to_string(me.id), "commands", m_post, s.build_json(false), [s, callback] (json &j, const http_request_completion_t& http) mutable {
|
this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "commands", m_post, s.build_json(false), [s, callback] (json &j, const http_request_completion_t& http) mutable {
|
||||||
if (j.contains("id")) {
|
if (j.contains("id")) {
|
||||||
s.id = SnowflakeNotNull(&j, "id");
|
s.id = SnowflakeNotNull(&j, "id");
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ void cluster::global_command_create(slashcommand &s, command_completion_event_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cluster::guild_command_create(slashcommand &s, snowflake guild_id, command_completion_event_t callback) {
|
void cluster::guild_command_create(slashcommand &s, snowflake guild_id, command_completion_event_t callback) {
|
||||||
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_post, s.build_json(false), [s, this, guild_id, callback] (json &j, const http_request_completion_t& http) mutable {
|
this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_post, s.build_json(false), [s, this, guild_id, callback] (json &j, const http_request_completion_t& http) mutable {
|
||||||
if (j.contains("id")) {
|
if (j.contains("id")) {
|
||||||
s.id = SnowflakeNotNull(&j, "id");
|
s.id = SnowflakeNotNull(&j, "id");
|
||||||
}
|
}
|
||||||
@ -355,11 +355,14 @@ void cluster::guild_command_create(slashcommand &s, snowflake guild_id, command_
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cluster::guild_bulk_command_create(const std::vector<slashcommand> &commands, snowflake guild_id, command_completion_event_t callback) {
|
void cluster::guild_bulk_command_create(const std::vector<slashcommand> &commands, snowflake guild_id, command_completion_event_t callback) {
|
||||||
|
if (commands.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
json j = json::array();
|
json j = json::array();
|
||||||
for (auto & s : commands) {
|
for (auto & s : commands) {
|
||||||
j.push_back(json::parse(s.build_json(false)));
|
j.push_back(json::parse(s.build_json(false)));
|
||||||
}
|
}
|
||||||
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable {
|
this->post_rest(API_PATH "/applications", std::to_string(commands[0].application_id ? commands[0].application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable {
|
||||||
slashcommand_map slashcommands;
|
slashcommand_map slashcommands;
|
||||||
for (auto & curr_slashcommand : j) {
|
for (auto & curr_slashcommand : j) {
|
||||||
slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand);
|
slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand);
|
||||||
@ -371,11 +374,14 @@ void cluster::guild_bulk_command_create(const std::vector<slashcommand> &command
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cluster::global_bulk_command_create(const std::vector<slashcommand> &commands, command_completion_event_t callback) {
|
void cluster::global_bulk_command_create(const std::vector<slashcommand> &commands, command_completion_event_t callback) {
|
||||||
|
if (commands.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
json j = json::array();
|
json j = json::array();
|
||||||
for (auto & s : commands) {
|
for (auto & s : commands) {
|
||||||
j.push_back(json::parse(s.build_json(false)));
|
j.push_back(json::parse(s.build_json(false)));
|
||||||
}
|
}
|
||||||
this->post_rest(API_PATH "/applications", std::to_string(me.id), "commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable {
|
this->post_rest(API_PATH "/applications", std::to_string(commands[0].application_id ? commands[0].application_id : me.id), "commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable {
|
||||||
slashcommand_map slashcommands;
|
slashcommand_map slashcommands;
|
||||||
for (auto & curr_slashcommand : j) {
|
for (auto & curr_slashcommand : j) {
|
||||||
slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand);
|
slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand);
|
||||||
@ -387,7 +393,7 @@ void cluster::global_bulk_command_create(const std::vector<slashcommand> &comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cluster::global_command_edit(const slashcommand &s, command_completion_event_t callback) {
|
void cluster::global_command_edit(const slashcommand &s, command_completion_event_t callback) {
|
||||||
this->post_rest(API_PATH "/applications", std::to_string(me.id), "commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) {
|
this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
||||||
}
|
}
|
||||||
@ -395,7 +401,7 @@ void cluster::global_command_edit(const slashcommand &s, command_completion_even
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cluster::guild_command_edit(const slashcommand &s, snowflake guild_id, command_completion_event_t callback) {
|
void cluster::guild_command_edit(const slashcommand &s, snowflake guild_id, command_completion_event_t callback) {
|
||||||
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) {
|
this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
||||||
}
|
}
|
||||||
@ -414,7 +420,7 @@ void cluster::guild_command_edit_permissions(const slashcommand &s, snowflake gu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id) + "/permissions", m_put, j.dump(), [callback](json &j, const http_request_completion_t& http) {
|
this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id) + "/permissions", m_put, j.dump(), [callback](json &j, const http_request_completion_t& http) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
||||||
}
|
}
|
||||||
@ -1040,7 +1046,7 @@ void cluster::guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t dele
|
|||||||
j["reason"] = reason;
|
j["reason"] = reason;
|
||||||
if (delete_message_days)
|
if (delete_message_days)
|
||||||
j["delete_message_days"] = delete_message_days;
|
j["delete_message_days"] = delete_message_days;
|
||||||
this->post_rest(API_PATH "/guilds", std::to_string(guild_id), "bans/" + std::to_string(user_id), m_put, "", [callback](json &j, const http_request_completion_t& http) {
|
this->post_rest(API_PATH "/guilds", std::to_string(guild_id), "bans/" + std::to_string(user_id), m_put, j.dump(), [callback](json &j, const http_request_completion_t& http) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
||||||
}
|
}
|
||||||
@ -1656,7 +1662,7 @@ void cluster::execute_webhook(const class webhook &wh, const struct message& m,
|
|||||||
if (thread_id) {
|
if (thread_id) {
|
||||||
parameters.append("&thread_id=" + std::to_string(thread_id));
|
parameters.append("&thread_id=" + std::to_string(thread_id));
|
||||||
}
|
}
|
||||||
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token), m_post, m.build_json(false), [callback](json &j, const http_request_completion_t& http) {
|
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token), m_post, m.build_json(false), [callback](json &j, const http_request_completion_t& http) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
|
callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
|
||||||
}
|
}
|
||||||
@ -1665,7 +1671,7 @@ void cluster::execute_webhook(const class webhook &wh, const struct message& m,
|
|||||||
|
|
||||||
void cluster::get_webhook_message(const class webhook &wh, command_completion_event_t callback)
|
void cluster::get_webhook_message(const class webhook &wh, command_completion_event_t callback)
|
||||||
{
|
{
|
||||||
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token) + "/messages/@original", m_get, "", [callback](json &j, const http_request_completion_t &http){
|
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token) + "/messages/@original", m_get, "", [callback](json &j, const http_request_completion_t &http){
|
||||||
if (callback){
|
if (callback){
|
||||||
callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
|
callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
|
||||||
}
|
}
|
||||||
@ -1673,7 +1679,7 @@ void cluster::get_webhook_message(const class webhook &wh, command_completion_ev
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cluster::edit_webhook_message(const class webhook &wh, const struct message& m, command_completion_event_t callback) {
|
void cluster::edit_webhook_message(const class webhook &wh, const struct message& m, command_completion_event_t callback) {
|
||||||
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token) + "/messages/" + std::to_string(m.id), m_patch, m.build_json(false), [callback](json &j, const http_request_completion_t& http) {
|
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token) + "/messages/" + std::to_string(m.id), m_patch, m.build_json(false), [callback](json &j, const http_request_completion_t& http) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
|
callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
|
||||||
}
|
}
|
||||||
@ -1681,7 +1687,7 @@ void cluster::edit_webhook_message(const class webhook &wh, const struct message
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cluster::delete_webhook_message(const class webhook &wh, snowflake message_id, command_completion_event_t callback) {
|
void cluster::delete_webhook_message(const class webhook &wh, snowflake message_id, command_completion_event_t callback) {
|
||||||
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token) + "/messages/" + std::to_string(message_id), m_delete, "", [callback](json &j, const http_request_completion_t& http) {
|
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token) + "/messages/" + std::to_string(message_id), m_delete, "", [callback](json &j, const http_request_completion_t& http) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
callback(confirmation_callback_t("confirmation", confirmation(), http));
|
||||||
}
|
}
|
||||||
|
75
vendor/DPP/src/dpp/commandhandler.cpp
vendored
75
vendor/DPP/src/dpp/commandhandler.cpp
vendored
@ -155,6 +155,10 @@ bool commandhandler::string_has_prefix(std::string &str)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note that message based command routing relies on cache to resolve ping types (e.g. user, channel ping).
|
||||||
|
* There isn't really a way around this for many things because there is no 'resolved' member for it.
|
||||||
|
* We only get resolved information for the user issuing the command.
|
||||||
|
*/
|
||||||
void commandhandler::route(const dpp::message& msg)
|
void commandhandler::route(const dpp::message& msg)
|
||||||
{
|
{
|
||||||
std::string msg_content = msg.content;
|
std::string msg_content = msg.content;
|
||||||
@ -226,8 +230,15 @@ void commandhandler::route(const dpp::message& msg)
|
|||||||
snowflake uid = from_string<uint64_t>(x.substr(2, x.length() - 1), std::dec);
|
snowflake uid = from_string<uint64_t>(x.substr(2, x.length() - 1), std::dec);
|
||||||
user* u = dpp::find_user(uid);
|
user* u = dpp::find_user(uid);
|
||||||
if (u) {
|
if (u) {
|
||||||
param = *u;
|
dpp::resolved_user m;
|
||||||
|
m.user = *u;
|
||||||
|
dpp::guild* g = dpp::find_guild(msg.guild_id);
|
||||||
|
if (g->members.find(uid) != g->members.end()) {
|
||||||
|
m.member = g->members[uid];
|
||||||
}
|
}
|
||||||
|
param = m;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -270,6 +281,7 @@ void commandhandler::route(const interaction_create_t & event)
|
|||||||
* dont have prefixes at all.
|
* dont have prefixes at all.
|
||||||
*/
|
*/
|
||||||
command_interaction cmd = std::get<command_interaction>(event.command.data);
|
command_interaction cmd = std::get<command_interaction>(event.command.data);
|
||||||
|
|
||||||
auto found_cmd = commands.find(lowercase(cmd.name));
|
auto found_cmd = commands.find(lowercase(cmd.name));
|
||||||
if (found_cmd != commands.end()) {
|
if (found_cmd != commands.end()) {
|
||||||
/* Command found; parse parameters */
|
/* Command found; parse parameters */
|
||||||
@ -277,13 +289,13 @@ void commandhandler::route(const interaction_create_t & event)
|
|||||||
for (auto& p : found_cmd->second.parameters) {
|
for (auto& p : found_cmd->second.parameters) {
|
||||||
command_parameter param;
|
command_parameter param;
|
||||||
const command_value& slash_parameter = event.get_parameter(p.first);
|
const command_value& slash_parameter = event.get_parameter(p.first);
|
||||||
|
dpp::command_resolved res = event.command.resolved;
|
||||||
|
|
||||||
if (p.second.optional && slash_parameter.valueless_by_exception()) {
|
if (p.second.optional && slash_parameter.index() == 0 /* std::monostate */) {
|
||||||
/* Missing optional parameter, skip this */
|
/* Missing optional parameter, skip this */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
switch (p.second.type) {
|
switch (p.second.type) {
|
||||||
case pt_string: {
|
case pt_string: {
|
||||||
std::string s = std::get<std::string>(slash_parameter);
|
std::string s = std::get<std::string>(slash_parameter);
|
||||||
@ -294,7 +306,13 @@ void commandhandler::route(const interaction_create_t & event)
|
|||||||
snowflake rid = std::get<snowflake>(slash_parameter);
|
snowflake rid = std::get<snowflake>(slash_parameter);
|
||||||
role* r = dpp::find_role(rid);
|
role* r = dpp::find_role(rid);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
/* Use cache if the role is in the cache */
|
||||||
param = *r;
|
param = *r;
|
||||||
|
} else {
|
||||||
|
/* Otherwise use interaction resolved fields */
|
||||||
|
if (res.roles.find(rid) != res.roles.end()) {
|
||||||
|
param = res.roles[rid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -302,15 +320,42 @@ void commandhandler::route(const interaction_create_t & event)
|
|||||||
snowflake cid = std::get<snowflake>(slash_parameter);
|
snowflake cid = std::get<snowflake>(slash_parameter);
|
||||||
channel* c = dpp::find_channel(cid);
|
channel* c = dpp::find_channel(cid);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
/* Use cache if the channel is in the cache */
|
||||||
param = *c;
|
param = *c;
|
||||||
|
} else {
|
||||||
|
/* Otherwise use interaction resolved fields */
|
||||||
|
if (res.channels.find(cid) != res.channels.end()) {
|
||||||
|
param = res.channels[cid];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case pt_user: {
|
case pt_user: {
|
||||||
snowflake uid = std::get<snowflake>(slash_parameter);
|
snowflake uid = std::get<snowflake>(slash_parameter);
|
||||||
|
/* TODO: Make this used resolved, not cache */
|
||||||
user* u = dpp::find_user(uid);
|
user* u = dpp::find_user(uid);
|
||||||
if (u) {
|
if (u) {
|
||||||
param = *u;
|
/* Use the cache if the user is in the cache */
|
||||||
|
dpp::resolved_user m;
|
||||||
|
m.user = *u;
|
||||||
|
dpp::guild* g = dpp::find_guild(event.command.guild_id);
|
||||||
|
if (g->members.find(uid) != g->members.end()) {
|
||||||
|
m.member = g->members[uid];
|
||||||
|
}
|
||||||
|
param = m;
|
||||||
|
} else {
|
||||||
|
/* Otherwise use interaction resolved fields */
|
||||||
|
if (
|
||||||
|
event.command.resolved.users.find(uid) != event.command.resolved.users.end()
|
||||||
|
&&
|
||||||
|
event.command.resolved.members.find(uid) != event.command.resolved.members.end()
|
||||||
|
) {
|
||||||
|
/* Fill in both member and user info */
|
||||||
|
dpp::resolved_user m;
|
||||||
|
m.member = res.members[uid];
|
||||||
|
m.user = res.users[uid];
|
||||||
|
param = m;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -318,17 +363,13 @@ void commandhandler::route(const interaction_create_t & event)
|
|||||||
int32_t i = std::get<int32_t>(slash_parameter);
|
int32_t i = std::get<int32_t>(slash_parameter);
|
||||||
param = i;
|
param = i;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case pt_boolean: {
|
case pt_boolean: {
|
||||||
bool b = std::get<bool>(slash_parameter);
|
bool b = std::get<bool>(slash_parameter);
|
||||||
param = b;
|
param = b;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (const std::bad_variant_access& e) {
|
|
||||||
/* Missing optional parameter, skip this */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add parameter to the list */
|
/* Add parameter to the list */
|
||||||
call_params.push_back(std::make_pair(p.first, param));
|
call_params.push_back(std::make_pair(p.first, param));
|
||||||
@ -357,4 +398,20 @@ void commandhandler::reply(const dpp::message &m, command_source source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void commandhandler::thinking(command_source source)
|
||||||
|
{
|
||||||
|
dpp::message msg;
|
||||||
|
msg.content = "*";
|
||||||
|
msg.guild_id = source.guild_id;
|
||||||
|
msg.channel_id = source.channel_id;
|
||||||
|
if (!source.command_token.empty() && source.command_id) {
|
||||||
|
owner->interaction_response_create(source.command_id, source.command_token, dpp::interaction_response(ir_deferred_channel_message_with_source, msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void commandhandler::thonk(command_source source)
|
||||||
|
{
|
||||||
|
thinking(source);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
2
vendor/DPP/src/dpp/discordclient.cpp
vendored
2
vendor/DPP/src/dpp/discordclient.cpp
vendored
@ -329,7 +329,7 @@ void discord_client::Error(uint32_t errorcode)
|
|||||||
{ 1003, "Endpoint received an unsupported frame" },
|
{ 1003, "Endpoint received an unsupported frame" },
|
||||||
{ 1004, "Reserved code" },
|
{ 1004, "Reserved code" },
|
||||||
{ 1005, "Expected close status, received none" },
|
{ 1005, "Expected close status, received none" },
|
||||||
{ 1006, "No close code frame has been receieved" },
|
{ 1006, "No close code frame has been received" },
|
||||||
{ 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" },
|
{ 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" },
|
||||||
{ 1008, "Generic error" },
|
{ 1008, "Generic error" },
|
||||||
{ 1009, "Endpoint won't process large frame" },
|
{ 1009, "Endpoint won't process large frame" },
|
||||||
|
6
vendor/DPP/src/dpp/discordevents.cpp
vendored
6
vendor/DPP/src/dpp/discordevents.cpp
vendored
@ -42,7 +42,7 @@ char* strptime(const char* s, const char* f, struct tm* tm) {
|
|||||||
input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
|
input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
|
||||||
input >> std::get_time(tm, f);
|
input >> std::get_time(tm, f);
|
||||||
if (input.fail()) {
|
if (input.fail()) {
|
||||||
return const_cast< char* >("");
|
return const_cast<char*>("");
|
||||||
}
|
}
|
||||||
return (char*)(s + input.tellg());
|
return (char*)(s + input.tellg());
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ std::string StringNotNull(const json* j, const char *keyname) {
|
|||||||
if (k != j->end()) {
|
if (k != j->end()) {
|
||||||
return !k->is_null() && k->is_string() ? k->get<std::string>() : "";
|
return !k->is_null() && k->is_string() ? k->get<std::string>() : "";
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return const_cast< char* >("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ void discord_client::HandleEvent(const std::string &event, json &j, const std::s
|
|||||||
auto ev_iter = eventmap.find(event);
|
auto ev_iter = eventmap.find(event);
|
||||||
if (ev_iter != eventmap.end()) {
|
if (ev_iter != eventmap.end()) {
|
||||||
/* A handler with nullptr is silently ignored. We don't plan to make a handler for it
|
/* A handler with nullptr is silently ignored. We don't plan to make a handler for it
|
||||||
* so this usually some user-only thing thats crept into the API and shown to bots
|
* so this usually some user-only thing that's crept into the API and shown to bots
|
||||||
* that we dont care about.
|
* that we dont care about.
|
||||||
*/
|
*/
|
||||||
if (ev_iter->second != nullptr) {
|
if (ev_iter->second != nullptr) {
|
||||||
|
2
vendor/DPP/src/dpp/discordvoiceclient.cpp
vendored
2
vendor/DPP/src/dpp/discordvoiceclient.cpp
vendored
@ -450,7 +450,7 @@ void discord_voice_client::Error(uint32_t errorcode)
|
|||||||
{ 1003, "Endpoint received an unsupported frame" },
|
{ 1003, "Endpoint received an unsupported frame" },
|
||||||
{ 1004, "Reserved code" },
|
{ 1004, "Reserved code" },
|
||||||
{ 1005, "Expected close status, received none" },
|
{ 1005, "Expected close status, received none" },
|
||||||
{ 1006, "No close code frame has been receieved" },
|
{ 1006, "No close code frame has been received" },
|
||||||
{ 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" },
|
{ 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" },
|
||||||
{ 1008, "Generic error" },
|
{ 1008, "Generic error" },
|
||||||
{ 1009, "Endpoint won't process large frame" },
|
{ 1009, "Endpoint won't process large frame" },
|
||||||
|
2
vendor/DPP/src/dpp/httplib.cpp
vendored
2
vendor/DPP/src/dpp/httplib.cpp
vendored
@ -386,6 +386,8 @@ int close_socket(socket_t sock) {
|
|||||||
if (sock >= 0 && sock < FD_SETSIZE) {
|
if (sock >= 0 && sock < FD_SETSIZE) {
|
||||||
return closesocket(sock);
|
return closesocket(sock);
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
|
return -1;
|
||||||
#else
|
#else
|
||||||
return close(sock);
|
return close(sock);
|
||||||
#endif
|
#endif
|
||||||
|
22
vendor/DPP/src/dpp/message.cpp
vendored
22
vendor/DPP/src/dpp/message.cpp
vendored
@ -517,11 +517,13 @@ reaction::reaction(json* j) {
|
|||||||
emoji_name = StringNotNull(&emoji, "name");
|
emoji_name = StringNotNull(&emoji, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
attachment::attachment() {
|
attachment::attachment()
|
||||||
id = 0;
|
: id(0)
|
||||||
size = 0;
|
, size(0)
|
||||||
width = 0;
|
, width(0)
|
||||||
height = 0;
|
, height(0)
|
||||||
|
, ephemeral(false)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
attachment::attachment(json *j) : attachment() {
|
attachment::attachment(json *j) : attachment() {
|
||||||
@ -533,6 +535,7 @@ attachment::attachment(json *j) : attachment() {
|
|||||||
this->width = Int32NotNull(j, "width");
|
this->width = Int32NotNull(j, "width");
|
||||||
this->height = Int32NotNull(j, "height");
|
this->height = Int32NotNull(j, "height");
|
||||||
this->content_type = StringNotNull(j, "content_type");
|
this->content_type = StringNotNull(j, "content_type");
|
||||||
|
this->ephemeral = BoolNotNull(j, "ephemeral");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string message::build_json(bool with_id, bool is_interaction_response) const {
|
std::string message::build_json(bool with_id, bool is_interaction_response) const {
|
||||||
@ -553,6 +556,11 @@ std::string message::build_json(bool with_id, bool is_interaction_response) cons
|
|||||||
j["content"] = content;
|
j["content"] = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(author != nullptr) {
|
||||||
|
/* Used for webhooks */
|
||||||
|
j["username"] = author->username;
|
||||||
|
}
|
||||||
|
|
||||||
/* Populate message reference */
|
/* Populate message reference */
|
||||||
if (message_reference.channel_id || message_reference.guild_id || message_reference.message_id) {
|
if (message_reference.channel_id || message_reference.guild_id || message_reference.message_id) {
|
||||||
j["message_reference"] = json::object();
|
j["message_reference"] = json::object();
|
||||||
@ -740,8 +748,8 @@ bool message::is_crosspost() const {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool message::supress_embeds() const {
|
bool message::suppress_embeds() const {
|
||||||
return flags & m_supress_embeds;
|
return flags & m_suppress_embeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool message::is_source_message_deleted() const {
|
bool message::is_source_message_deleted() const {
|
||||||
|
2
vendor/DPP/src/dpp/queues.cpp
vendored
2
vendor/DPP/src/dpp/queues.cpp
vendored
@ -285,7 +285,7 @@ void request_queue::in_loop()
|
|||||||
auto currbucket = buckets.find(bucket.first);
|
auto currbucket = buckets.find(bucket.first);
|
||||||
|
|
||||||
if (currbucket != buckets.end()) {
|
if (currbucket != buckets.end()) {
|
||||||
/* Theres a bucket for this request. Check its status. If the bucket says to wait,
|
/* There's a bucket for this request. Check its status. If the bucket says to wait,
|
||||||
* skip all requests in this bucket till its ok.
|
* skip all requests in this bucket till its ok.
|
||||||
*/
|
*/
|
||||||
if (currbucket->second.remaining < 1) {
|
if (currbucket->second.remaining < 1) {
|
||||||
|
43
vendor/DPP/src/dpp/slashcommand.cpp
vendored
43
vendor/DPP/src/dpp/slashcommand.cpp
vendored
@ -125,6 +125,7 @@ void to_json(json& j, const slashcommand& p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
j["default_permission"] = p.default_permission;
|
j["default_permission"] = p.default_permission;
|
||||||
|
j["application_id"] = std::to_string(p.application_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string slashcommand::build_json(bool with_id) const {
|
std::string slashcommand::build_json(bool with_id) const {
|
||||||
@ -271,7 +272,6 @@ void from_json(const nlohmann::json& j, interaction& i) {
|
|||||||
SetSnowflakeNotNull(&m, "id", i.message_id);
|
SetSnowflakeNotNull(&m, "id", i.message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
i.type = Int8NotNull(&j, "type");
|
i.type = Int8NotNull(&j, "type");
|
||||||
i.token = StringNotNull(&j, "token");
|
i.token = StringNotNull(&j, "token");
|
||||||
i.version = Int8NotNull(&j, "version");
|
i.version = Int8NotNull(&j, "version");
|
||||||
@ -284,6 +284,47 @@ void from_json(const nlohmann::json& j, interaction& i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (j.contains("data") && !j.at("data").is_null()) {
|
if (j.contains("data") && !j.at("data").is_null()) {
|
||||||
|
|
||||||
|
const json& data = j["data"];
|
||||||
|
|
||||||
|
/* Deal with 'resolved' data, e.g. users, members, roles, channels */
|
||||||
|
if (data.find("resolved") != data.end()) {
|
||||||
|
const json& d_resolved = data["resolved"];
|
||||||
|
/* Users */
|
||||||
|
if (d_resolved.find("users") != d_resolved.end()) {
|
||||||
|
for (auto v = d_resolved["users"].begin(); v != d_resolved["users"].end(); ++v) {
|
||||||
|
json f = *v;
|
||||||
|
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
|
||||||
|
i.resolved.users[id] = dpp::user().fill_from_json(&f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Roles */
|
||||||
|
if (d_resolved.find("roles") != d_resolved.end()) {
|
||||||
|
for (auto v = d_resolved["roles"].begin(); v != d_resolved["roles"].end(); ++v) {
|
||||||
|
json f = *v;
|
||||||
|
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
|
||||||
|
i.resolved.roles[id] = dpp::role().fill_from_json(i.guild_id, &f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Channels */
|
||||||
|
if (d_resolved.find("channels") != d_resolved.end()) {
|
||||||
|
for (auto v = d_resolved["channels"].begin(); v != d_resolved["channels"].end(); ++v) {
|
||||||
|
json f = *v;
|
||||||
|
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
|
||||||
|
i.resolved.channels[id] = dpp::channel().fill_from_json(&f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Members */
|
||||||
|
if (d_resolved.find("members") != d_resolved.end()) {
|
||||||
|
for (auto v = d_resolved["members"].begin(); v != d_resolved["members"].end(); ++v) {
|
||||||
|
json f = *v;
|
||||||
|
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
|
||||||
|
i.resolved.members[id] = dpp::guild_member().fill_from_json(&f, i.guild_id, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (i.type == it_application_command) {
|
if (i.type == it_application_command) {
|
||||||
command_interaction ci;
|
command_interaction ci;
|
||||||
j.at("data").get_to(ci);
|
j.at("data").get_to(ci);
|
||||||
|
4
vendor/DPP/src/dpp/user.cpp
vendored
4
vendor/DPP/src/dpp/user.cpp
vendored
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
/* A mapping of discord's flag values to our bitmap (theyre different bit positions to fit other stuff in) */
|
/* A mapping of discord's flag values to our bitmap (they're different bit positions to fit other stuff in) */
|
||||||
std::map<uint32_t, dpp::user_flags> usermap = {
|
std::map<uint32_t, dpp::user_flags> usermap = {
|
||||||
{ 1 << 0, dpp::u_discord_employee },
|
{ 1 << 0, dpp::u_discord_employee },
|
||||||
{ 1 << 1, dpp::u_partnered_owner },
|
{ 1 << 1, dpp::u_partnered_owner },
|
||||||
@ -57,7 +57,7 @@ user::~user()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string user::get_avatar_url() const {
|
std::string user::get_avatar_url() const {
|
||||||
/* XXX: Discord were supposed to change their CDN over to discord.com, they havent.
|
/* XXX: Discord were supposed to change their CDN over to discord.com, they haven't.
|
||||||
* At some point in the future this URL *will* change!
|
* At some point in the future this URL *will* change!
|
||||||
*/
|
*/
|
||||||
return fmt::format("https://cdn.discordapp.com/avatars/{}/{}{}.{}",
|
return fmt::format("https://cdn.discordapp.com/avatars/{}/{}{}.{}",
|
||||||
|
8
vendor/DPP/src/dpp/voicestate.cpp
vendored
8
vendor/DPP/src/dpp/voicestate.cpp
vendored
@ -51,8 +51,8 @@ voicestate& voicestate::fill_from_json(nlohmann::json* j) {
|
|||||||
flags |= vs_self_stream;
|
flags |= vs_self_stream;
|
||||||
if (BoolNotNull(j, "self_video"))
|
if (BoolNotNull(j, "self_video"))
|
||||||
flags |= vs_self_video;
|
flags |= vs_self_video;
|
||||||
if (BoolNotNull(j, "supress"))
|
if (BoolNotNull(j, "suppress"))
|
||||||
flags |= vs_supress;
|
flags |= vs_suppress;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +80,8 @@ bool voicestate::self_video() const {
|
|||||||
return flags & vs_self_video;
|
return flags & vs_self_video;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool voicestate::is_supressed() const {
|
bool voicestate::is_suppressed() const {
|
||||||
return flags & vs_supress;
|
return flags & vs_suppress;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string voicestate::build_json() const {
|
std::string voicestate::build_json() const {
|
||||||
|
2
vendor/DPP/src/dpp/wsclient.cpp
vendored
2
vendor/DPP/src/dpp/wsclient.cpp
vendored
@ -304,7 +304,7 @@ void websocket_client::HandlePingPong(bool ping, const std::string &payload)
|
|||||||
{
|
{
|
||||||
unsigned char out[MAXHEADERSIZE];
|
unsigned char out[MAXHEADERSIZE];
|
||||||
if (ping) {
|
if (ping) {
|
||||||
/* For receving pings we echo back their payload with the type OP_PONG */
|
/* For receiving pings we echo back their payload with the type OP_PONG */
|
||||||
size_t s = this->FillHeader(out, payload.length(), OP_PONG);
|
size_t s = this->FillHeader(out, payload.length(), OP_PONG);
|
||||||
std::string header((const char*)out, s);
|
std::string header((const char*)out, s);
|
||||||
ssl_client::write(header);
|
ssl_client::write(header);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user