mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Update DPP.
This commit is contained in:
parent
0f235ff6af
commit
b978bc5046
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));
|
||||||
}
|
}
|
||||||
|
149
vendor/DPP/src/dpp/commandhandler.cpp
vendored
149
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,57 +289,86 @@ 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);
|
param = s;
|
||||||
param = s;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case pt_role: {
|
|
||||||
snowflake rid = std::get<snowflake>(slash_parameter);
|
|
||||||
role* r = dpp::find_role(rid);
|
|
||||||
if (r) {
|
|
||||||
param = *r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case pt_channel: {
|
|
||||||
snowflake cid = std::get<snowflake>(slash_parameter);
|
|
||||||
channel* c = dpp::find_channel(cid);
|
|
||||||
if (c) {
|
|
||||||
param = *c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case pt_user: {
|
|
||||||
snowflake uid = std::get<snowflake>(slash_parameter);
|
|
||||||
user* u = dpp::find_user(uid);
|
|
||||||
if (u) {
|
|
||||||
param = *u;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case pt_integer: {
|
|
||||||
int32_t i = std::get<int32_t>(slash_parameter);
|
|
||||||
param = i;
|
|
||||||
}
|
|
||||||
case pt_boolean: {
|
|
||||||
bool b = std::get<bool>(slash_parameter);
|
|
||||||
param = b;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
catch (const std::bad_variant_access& e) {
|
case pt_role: {
|
||||||
/* Missing optional parameter, skip this */
|
snowflake rid = std::get<snowflake>(slash_parameter);
|
||||||
continue;
|
role* r = dpp::find_role(rid);
|
||||||
|
if (r) {
|
||||||
|
/* Use cache if the role is in the cache */
|
||||||
|
param = *r;
|
||||||
|
} else {
|
||||||
|
/* Otherwise use interaction resolved fields */
|
||||||
|
if (res.roles.find(rid) != res.roles.end()) {
|
||||||
|
param = res.roles[rid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case pt_channel: {
|
||||||
|
snowflake cid = std::get<snowflake>(slash_parameter);
|
||||||
|
channel* c = dpp::find_channel(cid);
|
||||||
|
if (c) {
|
||||||
|
/* Use cache if the channel is in the cache */
|
||||||
|
param = *c;
|
||||||
|
} else {
|
||||||
|
/* Otherwise use interaction resolved fields */
|
||||||
|
if (res.channels.find(cid) != res.channels.end()) {
|
||||||
|
param = res.channels[cid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case pt_user: {
|
||||||
|
snowflake uid = std::get<snowflake>(slash_parameter);
|
||||||
|
/* TODO: Make this used resolved, not cache */
|
||||||
|
user* u = dpp::find_user(uid);
|
||||||
|
if (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;
|
||||||
|
case pt_integer: {
|
||||||
|
int32_t i = std::get<int32_t>(slash_parameter);
|
||||||
|
param = i;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case pt_boolean: {
|
||||||
|
bool b = std::get<bool>(slash_parameter);
|
||||||
|
param = b;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add parameter to the list */
|
/* Add parameter to the list */
|
||||||
@ -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 "";
|
||||||
}
|
}
|
||||||
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" },
|
||||||
|
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…
Reference in New Issue
Block a user