Skip to content

Commit

Permalink
making basic instance methods to get urls
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-ilesik committed Sep 14, 2023
1 parent fd3f875 commit ab8b035
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/dpp/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,13 @@ class DPP_EXPORT channel : public managed, public json_interface<channel> {
*/
std::string get_icon_url(uint16_t size = 0, const image_type format = i_png) const;

/**
* @brief Returns string of URL to channel
*
* @return string of URL to channel
*/
std::string get_url() const;

/**
* @brief Returns true if the channel is NSFW gated
*
Expand Down
7 changes: 7 additions & 0 deletions include/dpp/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,13 @@ struct DPP_EXPORT message : public managed {
* @return true if message has remixed attachment
*/
bool has_remix_attachment() const;

/**
* @brief Returns URL to message
*
* @return string of URL to message
*/
std::string get_url() const;
};

/** A group of messages */
Expand Down
7 changes: 7 additions & 0 deletions include/dpp/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ class DPP_EXPORT user : public managed, public json_interface<user> {
*/
std::string get_mention() const;

/**
* @brief Returns URL to user
*
* @return string of URL to user
*/
std::string get_url() const;

/**
* @brief Return true if user has the active Developer badge
*
Expand Down
4 changes: 4 additions & 0 deletions src/dpp/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ std::string channel::get_icon_url(uint16_t size, const image_type format) const
}
}

std::string channel::get_url() const{
return "https://discord.com/channels/" + std::to_string(guild_id) + "/" + std::to_string(id);
}

channel_type channel::get_type() const {
return static_cast<channel_type>(flags & CHANNEL_TYPE_MASK);
}
Expand Down
4 changes: 4 additions & 0 deletions src/dpp/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,10 @@ bool message::has_remix_attachment() const {
});
}

std::string message::get_url() const {
return "https://discord.com/channels/" + std::to_string(guild_id) + "/" + std::to_string(channel_id) + "/" + std::to_string(id);
}

sticker::sticker() : managed(0), pack_id(0), type(st_standard), format_type(sf_png), available(true), guild_id(0), sort_value(0) {
}

Expand Down
4 changes: 4 additions & 0 deletions src/dpp/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ std::string user::get_mention() const {
return utility::user_mention(id);
}

std::string user::get_url() const{
return "https://discord.com/users/" + std::to_string(id);
}

bool user::is_active_developer() const {
return this->flags & u_active_developer;
}
Expand Down

0 comments on commit ab8b035

Please sign in to comment.