Skip to content

Commit

Permalink
fix: commands should no longer crash when no context is defined (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 authored Oct 30, 2024
1 parent 1cace42 commit d45f87e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/dpp/slashcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ slashcommand& slashcommand::fill_from_json_impl(nlohmann::json* j) {

type = (slashcommand_contextmenu_type)int8_not_null(j, "type");
set_object_array_not_null<command_option>(j, "options", options); // command_option fills recursive

if (auto it = j->find("integration_types"); it != j->end()) {
it->get_to(this->integration_types);

if(j->contains("integration_types")) {
if (auto it = j->find("integration_types"); it != j->end() && !it->is_null()) {
it->get_to(this->integration_types);
}
}

if (auto it = j->find("contexts"); it != j->end()) {
it->get_to(this->contexts);
if(j->contains("contexts")) {
if (auto it = j->find("contexts"); it != j->end() && !it->is_null()) {
it->get_to(this->contexts);
}
}

return *this;
}

Expand Down

0 comments on commit d45f87e

Please sign in to comment.