Skip to content

Commit

Permalink
[Update]: nullptr check
Browse files Browse the repository at this point in the history
  • Loading branch information
harshfeudal committed Nov 21, 2022
1 parent c81c23f commit 9238c25
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/information/userInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
void userInfo(dpp::cluster& client, const dpp::slashcommand_t& event)
{
dpp::embed embed;

const auto errorTitle = "<:failed:1036206712916553748> Error";
const auto warnTitle = "Warning message";

const auto cmdUser = event.command.usr;
auto usrId = cmdUser.id;
Expand Down Expand Up @@ -67,6 +70,17 @@ void userInfo(dpp::cluster& client, const dpp::slashcommand_t& event)

const auto tgtId = dpp::find_user(usrId);

// If cannot find the user
if (tgtId == nullptr)
{
EmbedBuild(embed, 0xFF7578, errorTitle, warnTitle, "User not found!", event.command.usr);
event.reply(
dpp::message(event.command.channel_id, embed).set_flags(dpp::m_ephemeral)
);

return;
}

if (tgtId->is_discord_employee() == true)
hasStaffBadge = StaffBadge;

Expand Down

0 comments on commit 9238c25

Please sign in to comment.