Skip to content

Commit

Permalink
fix: thread safety for event objects (10.1 only) (#1350)
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Dec 16, 2024
1 parent 27d9c79 commit d821e72
Show file tree
Hide file tree
Showing 33 changed files with 293 additions and 141 deletions.
2 changes: 1 addition & 1 deletion docpages/example_code/collect_reactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class react_collector : public dpp::reaction_collector {
/* Override the "completed" event and then output the number of collected reactions as a message. */
virtual void completed(const std::vector<dpp::collected_reaction>& list) override {
if (list.size()) {
owner->message_create(dpp::message(list[0].react_channel->id, "I collected " + std::to_string(list.size()) + " reactions!"));
owner->message_create(dpp::message(list[0].react_channel.id, "I collected " + std::to_string(list.size()) + " reactions!"));
} else {
owner->message_create(dpp::message("... I got nothin'."));
}
Expand Down
14 changes: 7 additions & 7 deletions include/dpp/collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,27 @@ class collected_reaction : public managed {
/**
* @brief Reacting user.
*/
user react_user;
user react_user{};

/**
* @brief Reacting guild.
*/
guild* react_guild{};
guild react_guild{};

/**
* @brief Reacting guild member.
*/
guild_member react_member;
guild_member react_member{};

/**
* @brief Reacting channel.
*/
channel* react_channel{};
channel react_channel{};

/**
* @brief Reacted emoji.
*/
emoji react_emoji;
emoji react_emoji{};

/**
* @brief Optional: ID of the user who authored the message which was reacted to.
Expand Down Expand Up @@ -351,7 +351,7 @@ class channel_collector : public channel_collector_t {
* @param element element to filter
* @return Returned item to add to the list, or nullptr to skip adding this element
*/
virtual const dpp::channel* filter(const dpp::channel_create_t& element) { return element.created; }
virtual const dpp::channel* filter(const dpp::channel_create_t& element) { return &element.created; }

/**
* @brief Destroy the channel collector object
Expand Down Expand Up @@ -425,7 +425,7 @@ class role_collector : public role_collector_t {
* @param element element to filter
* @return Returned item to add to the list, or nullptr to skip adding this element
*/
virtual const dpp::role* filter(const dpp::guild_role_create_t& element) { return element.created; }
virtual const dpp::role* filter(const dpp::guild_role_create_t& element) { return &element.created; }

/**
* @brief Destroy the role collector object
Expand Down
Loading

0 comments on commit d821e72

Please sign in to comment.