Skip to content

Commit de13f34

Browse files
authored
fix: poll vote events and add missing poll intents (#1525)
1 parent 56d87ca commit de13f34

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

include/dpp/intents.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ enum intents {
126126
*/
127127
i_auto_moderation_execution = (1 << 21),
128128

129+
/**
130+
* @brief Intent for receipt of guild message poll votes.
131+
*/
132+
i_guild_message_polls = (1 << 24),
133+
134+
/**
135+
* @brief Intent for receipt of direct message poll votes.
136+
*/
137+
i_direct_message_polls = (1 << 25),
138+
129139
/**
130140
* @brief Default D++ intents (all non-privileged intents).
131141
*/
@@ -134,7 +144,7 @@ enum intents {
134144
dpp::i_guild_messages | dpp::i_guild_message_reactions | dpp::i_guild_message_typing |
135145
dpp::i_direct_messages | dpp::i_direct_message_typing | dpp::i_direct_message_reactions |
136146
dpp::i_guild_scheduled_events | dpp::i_auto_moderation_configuration |
137-
dpp::i_auto_moderation_execution,
147+
dpp::i_auto_moderation_execution | dpp::i_guild_message_polls | dpp::i_direct_message_polls,
138148

139149
/**
140150
* @brief Privileged intents requiring ID.

src/dpp/events/message_poll_vote_add.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ namespace dpp::events {
3939
void message_poll_vote_add::handle(discord_client* client, json &j, const std::string &raw) {
4040

4141
if (!client->creator->on_message_poll_vote_add.empty()) {
42-
json d = j["d"];
42+
json& d = j["d"];
4343
dpp::message_poll_vote_add_t vote(client->owner, client->shard_id, raw);
44-
vote.user_id = snowflake_not_null(&j, "user_id");
45-
vote.message_id = snowflake_not_null(&j, "message_id");
46-
vote.channel_id = snowflake_not_null(&j, "channel_id");
47-
vote.guild_id = snowflake_not_null(&j, "guild_id");
48-
vote.answer_id = int32_not_null(&j, "answer_id");
44+
vote.user_id = snowflake_not_null(&d, "user_id");
45+
vote.message_id = snowflake_not_null(&d, "message_id");
46+
vote.channel_id = snowflake_not_null(&d, "channel_id");
47+
vote.guild_id = snowflake_not_null(&d, "guild_id");
48+
vote.answer_id = int32_not_null(&d, "answer_id");
4949
client->creator->queue_work(1, [c = client->creator, vote]() {
5050
c->on_message_poll_vote_add.call(vote);
5151
});

src/dpp/events/message_poll_vote_remove.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ namespace dpp::events {
3838
*/
3939
void message_poll_vote_remove::handle(discord_client* client, json &j, const std::string &raw) {
4040

41-
if (!client->creator->on_message_poll_vote_add.empty()) {
42-
json d = j["d"];
41+
if (!client->creator->on_message_poll_vote_remove.empty()) {
42+
json& d = j["d"];
4343
dpp::message_poll_vote_remove_t vote(client->owner, client->shard_id, raw);
44-
vote.user_id = snowflake_not_null(&j, "user_id");
45-
vote.message_id = snowflake_not_null(&j, "message_id");
46-
vote.channel_id = snowflake_not_null(&j, "channel_id");
47-
vote.guild_id = snowflake_not_null(&j, "guild_id");
48-
vote.answer_id = int32_not_null(&j, "answer_id");
44+
vote.user_id = snowflake_not_null(&d, "user_id");
45+
vote.message_id = snowflake_not_null(&d, "message_id");
46+
vote.channel_id = snowflake_not_null(&d, "channel_id");
47+
vote.guild_id = snowflake_not_null(&d, "guild_id");
48+
vote.answer_id = int32_not_null(&d, "answer_id");
4949
client->creator->queue_work(1, [c = client->creator, vote]() {
5050
c->on_message_poll_vote_remove.call(vote);
5151
});

0 commit comments

Comments
 (0)