Skip to content

Commit d45f87e

Browse files
authored
fix: commands should no longer crash when no context is defined (#1312)
1 parent 1cace42 commit d45f87e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/dpp/slashcommand.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,19 @@ slashcommand& slashcommand::fill_from_json_impl(nlohmann::json* j) {
7474

7575
type = (slashcommand_contextmenu_type)int8_not_null(j, "type");
7676
set_object_array_not_null<command_option>(j, "options", options); // command_option fills recursive
77-
78-
if (auto it = j->find("integration_types"); it != j->end()) {
79-
it->get_to(this->integration_types);
77+
78+
if(j->contains("integration_types")) {
79+
if (auto it = j->find("integration_types"); it != j->end() && !it->is_null()) {
80+
it->get_to(this->integration_types);
81+
}
8082
}
8183

82-
if (auto it = j->find("contexts"); it != j->end()) {
83-
it->get_to(this->contexts);
84+
if(j->contains("contexts")) {
85+
if (auto it = j->find("contexts"); it != j->end() && !it->is_null()) {
86+
it->get_to(this->contexts);
87+
}
8488
}
89+
8590
return *this;
8691
}
8792

0 commit comments

Comments
 (0)