Skip to content

Commit

Permalink
fix: commands should no longer crash when no context is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 committed Oct 30, 2024
1 parent 1cace42 commit 82ac230
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 82ac230

Please sign in to comment.