Skip to content

Commit

Permalink
fix: allow slash commands in dm, fixes #418
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Jun 29, 2022
1 parent 372fb2f commit 345e240
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dpp/slashcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ void from_json(const nlohmann::json& j, interaction& i) {
i.token = string_not_null(&j, "token");
i.version = int8_not_null(&j, "version");
if (j.contains("member") && !j.at("member").is_null()) {
/* Command invoked from a guild */
if (j.at("member").contains("user") && !j.at("member").at("user").is_null()) {
j.at("member").at("user").get_to(i.usr);
/* Caching is on; store user if needed */
Expand All @@ -584,6 +585,11 @@ void from_json(const nlohmann::json& j, interaction& i) {
g->members[i.member.user_id] = i.member;
}
}
} else if (j.at("user") && !j.at("user").is_null()) {
/* Command invoked from a DM */
j.at("user").get_to(i.usr);
i.member.user_id = i.usr.id;
i.member.guild_id = 0;
}

if (j.contains("data") && !j.at("data").is_null()) {
Expand Down

0 comments on commit 345e240

Please sign in to comment.