diff --git a/include/dpp/dispatcher.h b/include/dpp/dispatcher.h index 364205e303..5fc92ef4fd 100644 --- a/include/dpp/dispatcher.h +++ b/include/dpp/dispatcher.h @@ -830,8 +830,17 @@ struct DPP_EXPORT guild_delete_t : public event_dispatch_t { using event_dispatch_t::event_dispatch_t; using event_dispatch_t::operator=; - /** Deleted guild */ - guild* deleted = nullptr; + /** + * @brief Deleted guild + * + */ + guild deleted; + + /** + * @brief Guild ID deleted + * + */ + snowflake guild_id{0}; }; /** @brief Update guild stickers */ @@ -875,7 +884,7 @@ struct DPP_EXPORT channel_delete_t : public event_dispatch_t { /** * @brief channel being deleted */ - channel* deleted = nullptr; + channel deleted; }; /** @brief Update channel */ @@ -918,7 +927,19 @@ struct DPP_EXPORT message_delete_t : public event_dispatch_t { /** * @brief message being deleted */ - message* deleted = nullptr; + snowflake id{0}; + + /** + * @brief Channel the message was deleted on + * + */ + snowflake channel_id{0}; + + /** + * @brief Guild the message was deleted on + */ + snowflake guild_id{0}; + }; /** @brief Guild member remove */ @@ -931,10 +952,15 @@ struct DPP_EXPORT guild_member_remove_t : public event_dispatch_t { */ guild* removing_guild = nullptr; + /** + * @brief Guild ID removed from + */ + snowflake guild_id{0}; + /** * @brief user being removed */ - user* removed = nullptr; + user removed; }; /** @brief Session resumed */ diff --git a/src/dpp/discordevents.cpp b/src/dpp/discordevents.cpp index 6b6f7e963d..353515b6c7 100644 --- a/src/dpp/discordevents.cpp +++ b/src/dpp/discordevents.cpp @@ -371,6 +371,7 @@ const std::map eventmap = { { "EMBEDDED_ACTIVITY_UPDATE", nullptr }, { "GUILD_APPLICATION_COMMAND_INDEX_UPDATE", nullptr }, { "CHANNEL_TOPIC_UPDATE", nullptr }, + { "VOICE_CHANNEL_STATUS_UPDATE", nullptr }, { "GUILD_SCHEDULED_EVENT_CREATE", new dpp::events::guild_scheduled_event_create() }, { "GUILD_SCHEDULED_EVENT_UPDATE", new dpp::events::guild_scheduled_event_update() }, { "GUILD_SCHEDULED_EVENT_DELETE", new dpp::events::guild_scheduled_event_delete() }, diff --git a/src/dpp/events/automod_rule_create.cpp b/src/dpp/events/automod_rule_create.cpp index 31ec851a54..b31d5b9f5d 100644 --- a/src/dpp/events/automod_rule_create.cpp +++ b/src/dpp/events/automod_rule_create.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/automod_rule_delete.cpp b/src/dpp/events/automod_rule_delete.cpp index d1fa9d68c5..d8a0702390 100644 --- a/src/dpp/events/automod_rule_delete.cpp +++ b/src/dpp/events/automod_rule_delete.cpp @@ -27,10 +27,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/automod_rule_execute.cpp b/src/dpp/events/automod_rule_execute.cpp index 5fa2fc3bc8..4b4d6e4a16 100644 --- a/src/dpp/events/automod_rule_execute.cpp +++ b/src/dpp/events/automod_rule_execute.cpp @@ -26,8 +26,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/automod_rule_update.cpp b/src/dpp/events/automod_rule_update.cpp index ccdcfa6829..1e78541473 100644 --- a/src/dpp/events/automod_rule_update.cpp +++ b/src/dpp/events/automod_rule_update.cpp @@ -26,8 +26,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/channel_create.cpp b/src/dpp/events/channel_create.cpp index 46ea4794d6..b252432c71 100644 --- a/src/dpp/events/channel_create.cpp +++ b/src/dpp/events/channel_create.cpp @@ -26,8 +26,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/channel_delete.cpp b/src/dpp/events/channel_delete.cpp index 1c55ecf543..3009ff3f4a 100644 --- a/src/dpp/events/channel_delete.cpp +++ b/src/dpp/events/channel_delete.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event @@ -40,20 +38,17 @@ using namespace dpp; */ void channel_delete::handle(discord_client* client, json &j, const std::string &raw) { json& d = j["d"]; - dpp::guild* g = nullptr; - dpp::channel* c = dpp::find_channel(snowflake_not_null(&d, "id")); - if (c) { - g = dpp::find_guild(c->guild_id); - if (g) { - auto gc = std::find(g->channels.begin(), g->channels.end(), c->id); - if (gc != g->channels.end()) { - g->channels.erase(gc); - } - } - dpp::get_channel_cache()->remove(c); + const channel c = channel().fill_from_json(&d); + guild* g = find_guild(c.guild_id); + if (g) { + g->channels.erase(std::remove(g->channels.begin(), g->channels.end(), c.id), g->channels.end()); + } + if (client->creator->cache_policy.channel_policy != cp_none) { + /* We must only pass pointers found by find_channel into here, any other ptr is an invalid non-op */ + get_channel_cache()->remove(find_channel(c.id)); } if (!client->creator->on_channel_delete.empty()) { - dpp::channel_delete_t cd(client, raw); + channel_delete_t cd(client, raw); cd.deleted = c; cd.deleting_guild = g; client->creator->on_channel_delete.call(cd); diff --git a/src/dpp/events/channel_pins_update.cpp b/src/dpp/events/channel_pins_update.cpp index 1d701b74c2..29ec7c2595 100644 --- a/src/dpp/events/channel_pins_update.cpp +++ b/src/dpp/events/channel_pins_update.cpp @@ -28,10 +28,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/channel_update.cpp b/src/dpp/events/channel_update.cpp index 634671fff8..33ecd580c0 100644 --- a/src/dpp/events/channel_update.cpp +++ b/src/dpp/events/channel_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/guild_audit_log_entry_create.cpp b/src/dpp/events/guild_audit_log_entry_create.cpp index 69a8d423ea..131f5e4b9e 100644 --- a/src/dpp/events/guild_audit_log_entry_create.cpp +++ b/src/dpp/events/guild_audit_log_entry_create.cpp @@ -23,8 +23,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_ban_add.cpp b/src/dpp/events/guild_ban_add.cpp index 0e9aa32445..646656c996 100644 --- a/src/dpp/events/guild_ban_add.cpp +++ b/src/dpp/events/guild_ban_add.cpp @@ -29,8 +29,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_ban_remove.cpp b/src/dpp/events/guild_ban_remove.cpp index 1265d592de..9d0d54d05b 100644 --- a/src/dpp/events/guild_ban_remove.cpp +++ b/src/dpp/events/guild_ban_remove.cpp @@ -29,8 +29,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_create.cpp b/src/dpp/events/guild_create.cpp index f6d75da142..8e4ac63b18 100644 --- a/src/dpp/events/guild_create.cpp +++ b/src/dpp/events/guild_create.cpp @@ -29,10 +29,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/guild_delete.cpp b/src/dpp/events/guild_delete.cpp index 3e013d6bfc..d8e01119ed 100644 --- a/src/dpp/events/guild_delete.cpp +++ b/src/dpp/events/guild_delete.cpp @@ -29,10 +29,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * @@ -43,7 +39,11 @@ using namespace dpp; void guild_delete::handle(discord_client* client, json &j, const std::string &raw) { json& d = j["d"]; dpp::guild* g = dpp::find_guild(snowflake_not_null(&d, "id")); - if (g) { + dpp::guild guild_del; + if (!g) { + guild_del.fill_from_json(&d); + } else { + guild_del = *g; if (!bool_not_null(&d, "unavailable")) { dpp::get_guild_cache()->remove(g); if (client->creator->cache_policy.emoji_policy != dpp::cp_none) { @@ -88,7 +88,8 @@ void guild_delete::handle(discord_client* client, json &j, const std::string &ra if (!client->creator->on_guild_delete.empty()) { dpp::guild_delete_t gd(client, raw); - gd.deleted = g; + gd.deleted = guild_del; + gd.guild_id = guild_del.id; client->creator->on_guild_delete.call(gd); } } diff --git a/src/dpp/events/guild_emojis_update.cpp b/src/dpp/events/guild_emojis_update.cpp index df99001134..9d4a6676bc 100644 --- a/src/dpp/events/guild_emojis_update.cpp +++ b/src/dpp/events/guild_emojis_update.cpp @@ -30,8 +30,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_integrations_update.cpp b/src/dpp/events/guild_integrations_update.cpp index fe5f3f1cde..72346c2ee6 100644 --- a/src/dpp/events/guild_integrations_update.cpp +++ b/src/dpp/events/guild_integrations_update.cpp @@ -29,10 +29,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/guild_join_request_delete.cpp b/src/dpp/events/guild_join_request_delete.cpp index 7951670cd6..f349a5756a 100644 --- a/src/dpp/events/guild_join_request_delete.cpp +++ b/src/dpp/events/guild_join_request_delete.cpp @@ -27,8 +27,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/guild_member_add.cpp b/src/dpp/events/guild_member_add.cpp index a064352007..d253174f42 100644 --- a/src/dpp/events/guild_member_add.cpp +++ b/src/dpp/events/guild_member_add.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/guild_member_remove.cpp b/src/dpp/events/guild_member_remove.cpp index 7e6b383988..9ac3e5c8bc 100644 --- a/src/dpp/events/guild_member_remove.cpp +++ b/src/dpp/events/guild_member_remove.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event @@ -42,37 +40,25 @@ void guild_member_remove::handle(discord_client* client, json &j, const std::str json d = j["d"]; dpp::guild_member_remove_t gmr(client, raw); + gmr.removed.fill_from_json(&(d["user"])); + gmr.guild_id = snowflake_not_null(&d, "guild_id"); + gmr.removing_guild = dpp::find_guild(gmr.guild_id); - gmr.removing_guild = dpp::find_guild(snowflake_not_null(&d, "guild_id")); - - if (client->creator->cache_policy.user_policy == dpp::cp_none) { - dpp::user u; - u.fill_from_json(&(d["user"])); - gmr.removed = &u; - if (!client->creator->on_guild_member_remove.empty()) { - client->creator->on_guild_member_remove.call(gmr); - } - } else { - - gmr.removed = dpp::find_user(snowflake_not_null(&(d["user"]), "id")); - - if (!client->creator->on_guild_member_remove.empty()) { - client->creator->on_guild_member_remove.call(gmr); - } + if (!client->creator->on_guild_member_remove.empty()) { + client->creator->on_guild_member_remove.call(gmr); + } - if (gmr.removing_guild && gmr.removed) { - auto i = gmr.removing_guild->members.find(gmr.removed->id); - if (i != gmr.removing_guild->members.end()) { - dpp::user* u = dpp::find_user(gmr.removed->id); - if (u) { - u->refcount--; - if (u->refcount < 1) { - dpp::get_user_cache()->remove(u); - } + if (client->creator->cache_policy.user_policy != dpp::cp_none && gmr.removing_guild) { + auto i = gmr.removing_guild->members.find(gmr.removed.id); + if (i != gmr.removing_guild->members.end()) { + dpp::user* u = dpp::find_user(gmr.removed.id); + if (u) { + u->refcount--; + if (u->refcount < 1) { + dpp::get_user_cache()->remove(u); } - gmr.removing_guild->members.erase(i); } - + gmr.removing_guild->members.erase(i); } } } diff --git a/src/dpp/events/guild_member_update.cpp b/src/dpp/events/guild_member_update.cpp index 291fb51ea8..cca7422f3a 100644 --- a/src/dpp/events/guild_member_update.cpp +++ b/src/dpp/events/guild_member_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/guild_members_chunk.cpp b/src/dpp/events/guild_members_chunk.cpp index b9c34d7eee..a5c4be9f8b 100644 --- a/src/dpp/events/guild_members_chunk.cpp +++ b/src/dpp/events/guild_members_chunk.cpp @@ -29,8 +29,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/guild_role_create.cpp b/src/dpp/events/guild_role_create.cpp index 1196c05915..a3780da3ea 100644 --- a/src/dpp/events/guild_role_create.cpp +++ b/src/dpp/events/guild_role_create.cpp @@ -29,8 +29,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/guild_role_delete.cpp b/src/dpp/events/guild_role_delete.cpp index c39b12e7dd..a32628ead0 100644 --- a/src/dpp/events/guild_role_delete.cpp +++ b/src/dpp/events/guild_role_delete.cpp @@ -40,25 +40,23 @@ using json = nlohmann::json; void guild_role_delete::handle(discord_client* client, json &j, const std::string &raw) { json &d = j["d"]; dpp::snowflake guild_id = snowflake_not_null(&d, "guild_id"); + dpp::snowflake role_id = snowflake_not_null(&d, "role_id"); dpp::guild* g = dpp::find_guild(guild_id); if (client->creator->cache_policy.role_policy == dpp::cp_none) { - dpp::role r; - r.fill_from_json(guild_id, &d); if (!client->creator->on_guild_role_delete.empty()) { dpp::guild_role_delete_t grd(client, raw); grd.deleting_guild = g; - grd.deleted = &r; + grd.role_id = role_id; + grd.deleted = nullptr; client->creator->on_guild_role_delete.call(grd); } } else { - json& role = d["role"]; - dpp::snowflake id = snowflake_not_null(&role, "id"); - dpp::role *r = dpp::find_role(id); + dpp::role *r = dpp::find_role(role_id); if (!client->creator->on_guild_role_delete.empty()) { dpp::guild_role_delete_t grd(client, raw); grd.deleting_guild = g; - grd.deleted = r ? r : nullptr; - grd.role_id = id; + grd.deleted = r; + grd.role_id = role_id; client->creator->on_guild_role_delete.call(grd); } if (r) { diff --git a/src/dpp/events/guild_role_update.cpp b/src/dpp/events/guild_role_update.cpp index 80bd66344b..83a348e271 100644 --- a/src/dpp/events/guild_role_update.cpp +++ b/src/dpp/events/guild_role_update.cpp @@ -29,10 +29,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/guild_scheduled_event_create.cpp b/src/dpp/events/guild_scheduled_event_create.cpp index e6f542102c..15414756a9 100644 --- a/src/dpp/events/guild_scheduled_event_create.cpp +++ b/src/dpp/events/guild_scheduled_event_create.cpp @@ -27,8 +27,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_scheduled_event_delete.cpp b/src/dpp/events/guild_scheduled_event_delete.cpp index b6f79c56d8..4552743d86 100644 --- a/src/dpp/events/guild_scheduled_event_delete.cpp +++ b/src/dpp/events/guild_scheduled_event_delete.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_scheduled_event_update.cpp b/src/dpp/events/guild_scheduled_event_update.cpp index 8f6c9557ed..7f297879a7 100644 --- a/src/dpp/events/guild_scheduled_event_update.cpp +++ b/src/dpp/events/guild_scheduled_event_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_scheduled_event_user_add.cpp b/src/dpp/events/guild_scheduled_event_user_add.cpp index 882cdea650..deecd3ff3f 100644 --- a/src/dpp/events/guild_scheduled_event_user_add.cpp +++ b/src/dpp/events/guild_scheduled_event_user_add.cpp @@ -27,8 +27,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_scheduled_event_user_remove.cpp b/src/dpp/events/guild_scheduled_event_user_remove.cpp index f6a38d2e75..64e4d31106 100644 --- a/src/dpp/events/guild_scheduled_event_user_remove.cpp +++ b/src/dpp/events/guild_scheduled_event_user_remove.cpp @@ -27,8 +27,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_stickers_update.cpp b/src/dpp/events/guild_stickers_update.cpp index 359d5f4e93..d6b4e16237 100644 --- a/src/dpp/events/guild_stickers_update.cpp +++ b/src/dpp/events/guild_stickers_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/guild_update.cpp b/src/dpp/events/guild_update.cpp index dc96a9e2c8..4f96fa698e 100644 --- a/src/dpp/events/guild_update.cpp +++ b/src/dpp/events/guild_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/integration_create.cpp b/src/dpp/events/integration_create.cpp index 38efb60ab4..13b475ab9d 100644 --- a/src/dpp/events/integration_create.cpp +++ b/src/dpp/events/integration_create.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** diff --git a/src/dpp/events/integration_delete.cpp b/src/dpp/events/integration_delete.cpp index 63c1b737eb..8dce94a072 100644 --- a/src/dpp/events/integration_delete.cpp +++ b/src/dpp/events/integration_delete.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/integration_update.cpp b/src/dpp/events/integration_update.cpp index 3318e31e2b..aad1ab66c8 100644 --- a/src/dpp/events/integration_update.cpp +++ b/src/dpp/events/integration_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/interaction_create.cpp b/src/dpp/events/interaction_create.cpp index bace354b35..e7a0297473 100644 --- a/src/dpp/events/interaction_create.cpp +++ b/src/dpp/events/interaction_create.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/invite_create.cpp b/src/dpp/events/invite_create.cpp index 119d978d50..626ac857e8 100644 --- a/src/dpp/events/invite_create.cpp +++ b/src/dpp/events/invite_create.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/invite_delete.cpp b/src/dpp/events/invite_delete.cpp index a72d257a3a..bd121f6105 100644 --- a/src/dpp/events/invite_delete.cpp +++ b/src/dpp/events/invite_delete.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/logger.cpp b/src/dpp/events/logger.cpp index e04827b726..5a9dcf5dd5 100644 --- a/src/dpp/events/logger.cpp +++ b/src/dpp/events/logger.cpp @@ -27,8 +27,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/message_create.cpp b/src/dpp/events/message_create.cpp index 317c302b3b..a1ce729b7b 100644 --- a/src/dpp/events/message_create.cpp +++ b/src/dpp/events/message_create.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/message_delete.cpp b/src/dpp/events/message_delete.cpp index 0ba9b754cb..60f0e97d81 100644 --- a/src/dpp/events/message_delete.cpp +++ b/src/dpp/events/message_delete.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event @@ -42,9 +40,9 @@ void message_delete::handle(discord_client* client, json &j, const std::string & if (!client->creator->on_message_delete.empty()) { json d = j["d"]; dpp::message_delete_t msg(client, raw); - dpp::message m(client->creator); - m.fill_from_json(&d); - msg.deleted = &m; + msg.id = snowflake_not_null(&d, "id"); + msg.guild_id = snowflake_not_null(&d, "guild_id"); + msg.channel_id = snowflake_not_null(&d, "channel_id"); client->creator->on_message_delete.call(msg); } diff --git a/src/dpp/events/message_delete_bulk.cpp b/src/dpp/events/message_delete_bulk.cpp index ce428695fa..394d408fb2 100644 --- a/src/dpp/events/message_delete_bulk.cpp +++ b/src/dpp/events/message_delete_bulk.cpp @@ -27,10 +27,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/message_reaction_add.cpp b/src/dpp/events/message_reaction_add.cpp index 9a1781c4c1..88a2d05608 100644 --- a/src/dpp/events/message_reaction_add.cpp +++ b/src/dpp/events/message_reaction_add.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/message_reaction_remove.cpp b/src/dpp/events/message_reaction_remove.cpp index a6045d052f..36b367c9cb 100644 --- a/src/dpp/events/message_reaction_remove.cpp +++ b/src/dpp/events/message_reaction_remove.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/message_reaction_remove_all.cpp b/src/dpp/events/message_reaction_remove_all.cpp index dc2ca20654..71fa31b873 100644 --- a/src/dpp/events/message_reaction_remove_all.cpp +++ b/src/dpp/events/message_reaction_remove_all.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/message_reaction_remove_emoji.cpp b/src/dpp/events/message_reaction_remove_emoji.cpp index 935b294a68..97002b4992 100644 --- a/src/dpp/events/message_reaction_remove_emoji.cpp +++ b/src/dpp/events/message_reaction_remove_emoji.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/message_update.cpp b/src/dpp/events/message_update.cpp index d4d42b6506..4b6490a1f2 100644 --- a/src/dpp/events/message_update.cpp +++ b/src/dpp/events/message_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/presence_update.cpp b/src/dpp/events/presence_update.cpp index ddf1601cf4..4238efb378 100644 --- a/src/dpp/events/presence_update.cpp +++ b/src/dpp/events/presence_update.cpp @@ -27,8 +27,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/ready.cpp b/src/dpp/events/ready.cpp index 38966fd4ce..7f68359392 100644 --- a/src/dpp/events/ready.cpp +++ b/src/dpp/events/ready.cpp @@ -28,9 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; - #ifndef _DOXYGEN_ std::mutex protect_the_loot; #endif diff --git a/src/dpp/events/resumed.cpp b/src/dpp/events/resumed.cpp index 7654e7bdd6..b70db335ef 100644 --- a/src/dpp/events/resumed.cpp +++ b/src/dpp/events/resumed.cpp @@ -27,8 +27,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/stage_instance_create.cpp b/src/dpp/events/stage_instance_create.cpp index 8c6fe00722..fbbc3099e5 100644 --- a/src/dpp/events/stage_instance_create.cpp +++ b/src/dpp/events/stage_instance_create.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/stage_instance_delete.cpp b/src/dpp/events/stage_instance_delete.cpp index 6a646108a3..54d8459dd5 100644 --- a/src/dpp/events/stage_instance_delete.cpp +++ b/src/dpp/events/stage_instance_delete.cpp @@ -27,10 +27,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/stage_instance_update.cpp b/src/dpp/events/stage_instance_update.cpp index 272a86acb0..8b2188f998 100644 --- a/src/dpp/events/stage_instance_update.cpp +++ b/src/dpp/events/stage_instance_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; /** * @brief Handle event diff --git a/src/dpp/events/thread_create.cpp b/src/dpp/events/thread_create.cpp index f2af207c1a..7e1993a6ee 100644 --- a/src/dpp/events/thread_create.cpp +++ b/src/dpp/events/thread_create.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; void thread_create::handle(discord_client* client, json& j, const std::string& raw) { json& d = j["d"]; diff --git a/src/dpp/events/thread_delete.cpp b/src/dpp/events/thread_delete.cpp index 0af8999a6f..b4bfc45710 100644 --- a/src/dpp/events/thread_delete.cpp +++ b/src/dpp/events/thread_delete.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; void thread_delete::handle(discord_client* client, json& j, const std::string& raw) { json& d = j["d"]; @@ -38,10 +36,7 @@ void thread_delete::handle(discord_client* client, json& j, const std::string& r t.fill_from_json(&d); dpp::guild* g = dpp::find_guild(t.guild_id); if (g) { - auto gt = std::find(g->threads.begin(), g->threads.end(), t.id); - if (gt != g->threads.end()) { - g->threads.erase(gt); - } + g->threads.erase(std::remove(g->threads.begin(), g->threads.end(), t.id), g->threads.end()); } if (!client->creator->on_thread_delete.empty()) { dpp::thread_delete_t td(client, raw); diff --git a/src/dpp/events/thread_list_sync.cpp b/src/dpp/events/thread_list_sync.cpp index 42777db458..3f850f7950 100644 --- a/src/dpp/events/thread_list_sync.cpp +++ b/src/dpp/events/thread_list_sync.cpp @@ -28,10 +28,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - void thread_list_sync::handle(discord_client* client, json& j, const std::string& raw) { json& d = j["d"]; diff --git a/src/dpp/events/thread_member_update.cpp b/src/dpp/events/thread_member_update.cpp index 726c118b07..e4407b425b 100644 --- a/src/dpp/events/thread_member_update.cpp +++ b/src/dpp/events/thread_member_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; void thread_member_update::handle(discord_client* client, json& j, const std::string& raw) { if (!client->creator->on_thread_member_update.empty()) { diff --git a/src/dpp/events/thread_members_update.cpp b/src/dpp/events/thread_members_update.cpp index 0b34737eaf..90d2fa5cb1 100644 --- a/src/dpp/events/thread_members_update.cpp +++ b/src/dpp/events/thread_members_update.cpp @@ -28,8 +28,6 @@ namespace dpp::events { -using json = nlohmann::json; -using namespace dpp; void thread_members_update::handle(discord_client* client, json& j, const std::string& raw) { json& d = j["d"]; diff --git a/src/dpp/events/thread_update.cpp b/src/dpp/events/thread_update.cpp index 83348d33c9..7d92c9fd4e 100644 --- a/src/dpp/events/thread_update.cpp +++ b/src/dpp/events/thread_update.cpp @@ -28,10 +28,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - void thread_update::handle(discord_client* client, json& j, const std::string& raw) { json& d = j["d"]; diff --git a/src/dpp/events/typing_start.cpp b/src/dpp/events/typing_start.cpp index 1677bf110b..b5334c9f54 100644 --- a/src/dpp/events/typing_start.cpp +++ b/src/dpp/events/typing_start.cpp @@ -27,10 +27,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/user_update.cpp b/src/dpp/events/user_update.cpp index 36051d3d69..b954b55c27 100644 --- a/src/dpp/events/user_update.cpp +++ b/src/dpp/events/user_update.cpp @@ -29,10 +29,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/voice_server_update.cpp b/src/dpp/events/voice_server_update.cpp index c85a347d4a..14cf9f77b8 100644 --- a/src/dpp/events/voice_server_update.cpp +++ b/src/dpp/events/voice_server_update.cpp @@ -29,10 +29,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/voice_state_update.cpp b/src/dpp/events/voice_state_update.cpp index 6cf73b4b79..7be7b18515 100644 --- a/src/dpp/events/voice_state_update.cpp +++ b/src/dpp/events/voice_state_update.cpp @@ -30,10 +30,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/dpp/events/webhooks_update.cpp b/src/dpp/events/webhooks_update.cpp index 4642a99fd3..4f676eeade 100644 --- a/src/dpp/events/webhooks_update.cpp +++ b/src/dpp/events/webhooks_update.cpp @@ -28,10 +28,6 @@ namespace dpp::events { - -using json = nlohmann::json; -using namespace dpp; - /** * @brief Handle event * diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index 84442f5e77..c703ff3c69 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -1541,7 +1541,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b }); bot.on_message_delete([&](const dpp::message_delete_t & event) { - if (event.deleted->channel_id == thread_helper.thread_id) { + if (event.channel_id == thread_helper.thread_id) { set_test(THREAD_MESSAGE_DELETE_EVENT, true); thread_helper.notify_event_tested(thread_test_helper::MESSAGE_DELETE); }