summaryrefslogtreecommitdiff
path: root/src/discord
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-04-14 00:11:39 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-04-14 00:11:39 -0400
commit34f8af599d76c74b719821e92d60937d9dcc01e3 (patch)
tree3feca6e98ea685d88b591e3ddc07f0fba8e59a18 /src/discord
parentd36fe4d0e9f7e537adc73827b925c429cd1f6ba8 (diff)
downloadabaddon-portaudio-34f8af599d76c74b719821e92d60937d9dcc01e3.tar.gz
abaddon-portaudio-34f8af599d76c74b719821e92d60937d9dcc01e3.zip
fix tab titles
Diffstat (limited to 'src/discord')
-rw-r--r--src/discord/channel.cpp13
-rw-r--r--src/discord/channel.hpp1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/discord/channel.cpp b/src/discord/channel.cpp
index 0770581..6277341 100644
--- a/src/discord/channel.cpp
+++ b/src/discord/channel.cpp
@@ -92,6 +92,19 @@ std::string ChannelData::GetIconURL() const {
return "https://cdn.discordapp.com/channel-icons/" + std::to_string(ID) + "/" + *Icon + ".png";
}
+std::string ChannelData::GetDisplayName() const {
+ if (Name.has_value()) {
+ return "#" + *Name;
+ } else {
+ const auto recipients = GetDMRecipients();
+ if (Type == ChannelType::DM && !recipients.empty())
+ return recipients[0].Username;
+ else if (Type == ChannelType::GROUP_DM)
+ return std::to_string(recipients.size()) + " members";
+ }
+ return "Unknown";
+}
+
std::vector<Snowflake> ChannelData::GetChildIDs() const {
return Abaddon::Get().GetDiscordClient().GetChildChannelIDs(ID);
}
diff --git a/src/discord/channel.hpp b/src/discord/channel.hpp
index 8feeb92..77cf029 100644
--- a/src/discord/channel.hpp
+++ b/src/discord/channel.hpp
@@ -102,6 +102,7 @@ struct ChannelData {
[[nodiscard]] bool IsText() const noexcept;
[[nodiscard]] bool HasIcon() const noexcept;
[[nodiscard]] std::string GetIconURL() const;
+ [[nodiscard]] std::string GetDisplayName() const;
[[nodiscard]] std::vector<Snowflake> GetChildIDs() const;
[[nodiscard]] std::optional<PermissionOverwrite> GetOverwrite(Snowflake id) const;
[[nodiscard]] std::vector<UserData> GetDMRecipients() const;