From 657635c987992a8b89403aad09e19ade92caf2cf Mon Sep 17 00:00:00 2001 From: ProjectSky Date: Thu, 18 Dec 2025 00:59:59 +0800 Subject: [PATCH] fix: poll vote events and add missing poll intents --- include/dpp/intents.h | 12 +++++++++++- src/dpp/events/message_poll_vote_add.cpp | 12 ++++++------ src/dpp/events/message_poll_vote_remove.cpp | 14 +++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/include/dpp/intents.h b/include/dpp/intents.h index f2e82b0c74..46933d63b2 100644 --- a/include/dpp/intents.h +++ b/include/dpp/intents.h @@ -126,6 +126,16 @@ enum intents { */ i_auto_moderation_execution = (1 << 21), + /** + * @brief Intent for receipt of guild message poll votes. + */ + i_guild_message_polls = (1 << 24), + + /** + * @brief Intent for receipt of direct message poll votes. + */ + i_direct_message_polls = (1 << 25), + /** * @brief Default D++ intents (all non-privileged intents). */ @@ -134,7 +144,7 @@ enum intents { dpp::i_guild_messages | dpp::i_guild_message_reactions | dpp::i_guild_message_typing | dpp::i_direct_messages | dpp::i_direct_message_typing | dpp::i_direct_message_reactions | dpp::i_guild_scheduled_events | dpp::i_auto_moderation_configuration | - dpp::i_auto_moderation_execution, + dpp::i_auto_moderation_execution | dpp::i_guild_message_polls | dpp::i_direct_message_polls, /** * @brief Privileged intents requiring ID. diff --git a/src/dpp/events/message_poll_vote_add.cpp b/src/dpp/events/message_poll_vote_add.cpp index 3b50d287d5..270e4855cb 100644 --- a/src/dpp/events/message_poll_vote_add.cpp +++ b/src/dpp/events/message_poll_vote_add.cpp @@ -39,13 +39,13 @@ namespace dpp::events { void message_poll_vote_add::handle(discord_client* client, json &j, const std::string &raw) { if (!client->creator->on_message_poll_vote_add.empty()) { - json d = j["d"]; + json& d = j["d"]; dpp::message_poll_vote_add_t vote(client->owner, client->shard_id, raw); - vote.user_id = snowflake_not_null(&j, "user_id"); - vote.message_id = snowflake_not_null(&j, "message_id"); - vote.channel_id = snowflake_not_null(&j, "channel_id"); - vote.guild_id = snowflake_not_null(&j, "guild_id"); - vote.answer_id = int32_not_null(&j, "answer_id"); + vote.user_id = snowflake_not_null(&d, "user_id"); + vote.message_id = snowflake_not_null(&d, "message_id"); + vote.channel_id = snowflake_not_null(&d, "channel_id"); + vote.guild_id = snowflake_not_null(&d, "guild_id"); + vote.answer_id = int32_not_null(&d, "answer_id"); client->creator->queue_work(1, [c = client->creator, vote]() { c->on_message_poll_vote_add.call(vote); }); diff --git a/src/dpp/events/message_poll_vote_remove.cpp b/src/dpp/events/message_poll_vote_remove.cpp index feccb4cc00..e34ddb27d4 100644 --- a/src/dpp/events/message_poll_vote_remove.cpp +++ b/src/dpp/events/message_poll_vote_remove.cpp @@ -38,14 +38,14 @@ namespace dpp::events { */ void message_poll_vote_remove::handle(discord_client* client, json &j, const std::string &raw) { - if (!client->creator->on_message_poll_vote_add.empty()) { - json d = j["d"]; + if (!client->creator->on_message_poll_vote_remove.empty()) { + json& d = j["d"]; dpp::message_poll_vote_remove_t vote(client->owner, client->shard_id, raw); - vote.user_id = snowflake_not_null(&j, "user_id"); - vote.message_id = snowflake_not_null(&j, "message_id"); - vote.channel_id = snowflake_not_null(&j, "channel_id"); - vote.guild_id = snowflake_not_null(&j, "guild_id"); - vote.answer_id = int32_not_null(&j, "answer_id"); + vote.user_id = snowflake_not_null(&d, "user_id"); + vote.message_id = snowflake_not_null(&d, "message_id"); + vote.channel_id = snowflake_not_null(&d, "channel_id"); + vote.guild_id = snowflake_not_null(&d, "guild_id"); + vote.answer_id = int32_not_null(&d, "answer_id"); client->creator->queue_work(1, [c = client->creator, vote]() { c->on_message_poll_vote_remove.call(vote); });