diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/channels.cpp | 53 | ||||
-rw-r--r-- | components/chatmessage.cpp | 126 | ||||
-rw-r--r-- | components/chatwindow.cpp | 10 | ||||
-rw-r--r-- | components/memberlist.cpp | 36 |
4 files changed, 119 insertions, 106 deletions
diff --git a/components/channels.cpp b/components/channels.cpp index 354a6d0..a192159 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -215,7 +215,7 @@ ChannelList::ChannelList() { // maybe will regret doing it this way auto &discord = Abaddon::Get().GetDiscordClient(); discord.signal_message_create().connect(sigc::track_obj([this, &discord](Snowflake message_id) { - const auto *message = discord.GetMessage(message_id); + const auto message = discord.GetMessage(message_id); const auto *channel = discord.GetChannel(message->ChannelID); if (channel == nullptr) return; if (channel->Type == ChannelType::DM || channel->Type == ChannelType::GROUP_DM) @@ -283,11 +283,11 @@ void ChannelList::UpdateRemoveChannel(Snowflake id) { // this is total shit void ChannelList::UpdateChannelCategory(Snowflake id) { const auto *data = Abaddon::Get().GetDiscordClient().GetChannel(id); - const auto *guild = Abaddon::Get().GetDiscordClient().GetGuild(data->GuildID); + const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(data->GuildID); auto git = m_guild_id_to_row.find(data->GuildID); if (git == m_guild_id_to_row.end()) return; auto *guild_row = git->second; - if (data == nullptr || guild == nullptr) return; + if (data == nullptr || !guild.has_value()) return; auto it = m_id_to_row.find(id); if (it == m_id_to_row.end()) return; auto row = dynamic_cast<ChannelListRowCategory *>(it->second); @@ -343,7 +343,7 @@ void ChannelList::UpdateChannelCategory(Snowflake id) { // so is this void ChannelList::UpdateChannel(Snowflake id) { const auto *data = Abaddon::Get().GetDiscordClient().GetChannel(id); - const auto *guild = Abaddon::Get().GetDiscordClient().GetGuild(data->GuildID); + const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(data->GuildID); const auto *guild_row = m_guild_id_to_row.at(data->GuildID); if (data->Type == ChannelType::GUILD_CATEGORY) { UpdateChannelCategory(id); @@ -402,7 +402,7 @@ void ChannelList::UpdateCreateChannel(Snowflake id) { UpdateCreateDMChannel(id); return; } - const auto *guild = discord.GetGuild(data->GuildID); + const auto guild = discord.GetGuild(data->GuildID); auto *guild_row = m_guild_id_to_row.at(data->GuildID); int pos = guild_row->get_index() + 1; @@ -437,8 +437,8 @@ void ChannelList::UpdateCreateChannel(Snowflake id) { void ChannelList::UpdateGuild(Snowflake id) { // the only thing changed is the row containing the guild item so just recreate it - const auto *data = Abaddon::Get().GetDiscordClient().GetGuild(id); - if (data == nullptr) return; + const auto data = Abaddon::Get().GetDiscordClient().GetGuild(id); + if (!data.has_value()) return; auto it = m_guild_id_to_row.find(id); if (it == m_guild_id_to_row.end()) return; auto *row = dynamic_cast<ChannelListRowGuild *>(it->second); @@ -447,7 +447,7 @@ void ChannelList::UpdateGuild(Snowflake id) { const bool old_collapsed = row->IsUserCollapsed; const bool old_gindex = row->GuildIndex; delete row; - auto *new_row = Gtk::manage(new ChannelListRowGuild(data)); + auto *new_row = Gtk::manage(new ChannelListRowGuild(&*data)); new_row->IsUserCollapsed = old_collapsed; new_row->GuildIndex = old_gindex; m_guild_id_to_row[new_row->ID] = new_row; @@ -523,21 +523,24 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) { }; const auto &discord = Abaddon::Get().GetDiscordClient(); - const auto *guild_data = discord.GetGuild(id); - if (guild_data == nullptr) return; + const auto guild_data = discord.GetGuild(id); + if (!guild_data.has_value()) return; std::map<int, const Channel *> orphan_channels; std::unordered_map<Snowflake, std::vector<const Channel *>> cat_to_channels; - for (const auto &channel : guild_data->Channels) { - if (channel.Type != ChannelType::GUILD_TEXT && channel.Type != ChannelType::GUILD_NEWS) continue; - - if (channel.ParentID.IsValid()) - cat_to_channels[channel.ParentID].push_back(&channel); - else - orphan_channels[channel.Position] = &channel; - } + if (guild_data->Channels.has_value()) + for (const auto &dc : *guild_data->Channels) { + const auto channel = discord.GetChannel(dc.ID); + if (channel == nullptr) continue; + if (channel->Type != ChannelType::GUILD_TEXT && channel->Type != ChannelType::GUILD_NEWS) continue; + + if (channel->ParentID.IsValid()) + cat_to_channels[channel->ParentID].push_back(&*channel); + else + orphan_channels[channel->Position] = &*channel; + } - auto *guild_row = Gtk::manage(new ChannelListRowGuild(guild_data)); + auto *guild_row = Gtk::manage(new ChannelListRowGuild(&*guild_data)); guild_row->show_all(); guild_row->IsUserCollapsed = true; guild_row->GuildIndex = m_guild_count++; @@ -558,9 +561,13 @@ void ChannelList::InsertGuildAt(Snowflake id, int pos) { // categories std::map<int, std::vector<const Channel *>> sorted_categories; - for (const auto &channel : guild_data->Channels) - if (channel.Type == ChannelType::GUILD_CATEGORY) - sorted_categories[channel.Position].push_back(&channel); + if (guild_data->Channels.has_value()) + for (const auto &dc : *guild_data->Channels) { + const auto channel = discord.GetChannel(dc.ID); + if (channel == nullptr) continue; + if (channel->Type == ChannelType::GUILD_CATEGORY) + sorted_categories[channel->Position].push_back(&*channel); + } for (auto &[pos, catvec] : sorted_categories) { std::sort(catvec.begin(), catvec.end(), [](const Channel *a, const Channel *b) { return a->ID < b->ID; }); @@ -619,7 +626,7 @@ void ChannelList::AddPrivateChannels() { } void ChannelList::UpdateListingInternal() { - std::unordered_set<Snowflake> guilds = Abaddon::Get().GetDiscordClient().GetGuildsID(); + std::unordered_set<Snowflake> guilds = Abaddon::Get().GetDiscordClient().GetGuilds(); auto children = m_list->get_children(); auto it = children.begin(); diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index 37a8cb7..257f2c4 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -33,22 +33,22 @@ ChatMessageItemContainer::ChatMessageItemContainer() { } ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(Snowflake id) { - const auto *data = Abaddon::Get().GetDiscordClient().GetMessage(id); - if (data == nullptr) return nullptr; + const auto data = Abaddon::Get().GetDiscordClient().GetMessage(id); + if (!data.has_value()) return nullptr; auto *container = Gtk::manage(new ChatMessageItemContainer); container->ID = data->ID; container->ChannelID = data->ChannelID; if (data->Content.size() > 0 || data->Type != MessageType::DEFAULT) { - container->m_text_component = container->CreateTextComponent(data); + container->m_text_component = container->CreateTextComponent(&*data); container->AttachGuildMenuHandler(container->m_text_component); container->m_main->add(*container->m_text_component); } // there should only ever be 1 embed (i think?) if (data->Embeds.size() == 1) { - container->m_embed_component = container->CreateEmbedComponent(data); + container->m_embed_component = container->CreateEmbedComponent(&*data); container->AttachGuildMenuHandler(container->m_embed_component); container->m_main->add(*container->m_embed_component); } @@ -83,7 +83,7 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(Snowflake id) { // this doesnt rly make sense void ChatMessageItemContainer::UpdateContent() { - const auto *data = Abaddon::Get().GetDiscordClient().GetMessage(ID); + const auto data = Abaddon::Get().GetDiscordClient().GetMessage(ID); if (m_text_component != nullptr) UpdateTextComponent(m_text_component); @@ -93,7 +93,7 @@ void ChatMessageItemContainer::UpdateContent() { } if (data->Embeds.size() == 1) { - m_embed_component = CreateEmbedComponent(data); + m_embed_component = CreateEmbedComponent(&*data); if (m_embed_imgurl.size() > 0) { m_signal_image_load.emit(m_embed_imgurl); } @@ -115,15 +115,19 @@ void ChatMessageItemContainer::UpdateImage(std::string url, Glib::RefPtr<Gdk::Pi auto it = m_img_loadmap.find(url); if (it != m_img_loadmap.end()) { - int w, h; - GetImageDimensions(it->second.second.Width, it->second.second.Height, w, h); - it->second.first->property_pixbuf() = buf->scale_simple(w, h, Gdk::INTERP_BILINEAR); + const auto inw = it->second.second.Width; + const auto inh = it->second.second.Height; + if (inw.has_value() && inh.has_value()) { + int w, h; + GetImageDimensions(*inw, *inh, w, h); + it->second.first->property_pixbuf() = buf->scale_simple(w, h, Gdk::INTERP_BILINEAR); + } } } void ChatMessageItemContainer::UpdateAttributes() { - const auto *data = Abaddon::Get().GetDiscordClient().GetMessage(ID); - if (data == nullptr) return; + const auto data = Abaddon::Get().GetDiscordClient().GetMessage(ID); + if (!data.has_value()) return; const bool deleted = data->IsDeleted(); const bool edited = data->IsEdited(); @@ -176,9 +180,8 @@ Gtk::TextView *ChatMessageItemContainer::CreateTextComponent(const Message *data } void ChatMessageItemContainer::UpdateTextComponent(Gtk::TextView *tv) { - const auto *data = Abaddon::Get().GetDiscordClient().GetMessage(ID); - if (data == nullptr) - return; + const auto data = Abaddon::Get().GetDiscordClient().GetMessage(ID); + if (!data.has_value()) return; auto b = tv->get_buffer(); b->set_text(""); @@ -208,21 +211,21 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const Message *data) Gtk::Box *main = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); const auto &embed = data->Embeds[0]; - if (embed.Author.Name.length() > 0) { + if (embed.Author.has_value() && embed.Author->Name.has_value()) { auto *author_lbl = Gtk::manage(new Gtk::Label); author_lbl->set_halign(Gtk::ALIGN_START); author_lbl->set_line_wrap(true); author_lbl->set_line_wrap_mode(Pango::WRAP_WORD_CHAR); author_lbl->set_hexpand(false); - author_lbl->set_text(embed.Author.Name); + author_lbl->set_text(*embed.Author->Name); author_lbl->get_style_context()->add_class("embed-author"); main->pack_start(*author_lbl); } - if (embed.Title.length() > 0) { + if (embed.Title.has_value()) { auto *title_label = Gtk::manage(new Gtk::Label); title_label->set_use_markup(true); - title_label->set_markup("<b>" + Glib::Markup::escape_text(embed.Title) + "</b>"); + title_label->set_markup("<b>" + Glib::Markup::escape_text(*embed.Title) + "</b>"); title_label->set_halign(Gtk::ALIGN_CENTER); title_label->set_hexpand(false); title_label->get_style_context()->add_class("embed-title"); @@ -233,9 +236,9 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const Message *data) main->pack_start(*title_label); } - if (embed.Description.length() > 0) { + if (embed.Description.has_value()) { auto *desc_label = Gtk::manage(new Gtk::Label); - desc_label->set_text(embed.Description); + desc_label->set_text(*embed.Description); desc_label->set_line_wrap(true); desc_label->set_line_wrap_mode(Pango::WRAP_WORD_CHAR); desc_label->set_max_width_chars(50); @@ -246,7 +249,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const Message *data) } // todo: handle inline fields - if (embed.Fields.size() > 0) { + if (embed.Fields.has_value() && embed.Fields->size() > 0) { auto *flow = Gtk::manage(new Gtk::FlowBox); flow->set_orientation(Gtk::ORIENTATION_HORIZONTAL); flow->set_min_children_per_line(3); @@ -257,7 +260,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const Message *data) flow->set_selection_mode(Gtk::SELECTION_NONE); main->pack_start(*flow); - for (const auto &field : embed.Fields) { + for (const auto &field : *embed.Fields) { auto *field_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); auto *field_lbl = Gtk::manage(new Gtk::Label); auto *field_val = Gtk::manage(new Gtk::Label); @@ -287,42 +290,44 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const Message *data) } } - bool is_img = embed.Image.URL.size() > 0; - bool is_thumb = embed.Thumbnail.URL.size() > 0; - if (is_img || is_thumb) { - auto *img = Gtk::manage(new Gtk::Image); - img->set_halign(Gtk::ALIGN_CENTER); - int w, h; - if (is_img) - GetImageDimensions(embed.Image.Width, embed.Image.Height, w, h, 200, 150); - else - GetImageDimensions(embed.Thumbnail.Width, embed.Thumbnail.Height, w, h, 200, 150); - img->set_size_request(w, h); - main->pack_start(*img); - m_embed_img = img; - if (is_img) - m_embed_imgurl = embed.Image.ProxyURL; - else - m_embed_imgurl = embed.Thumbnail.ProxyURL; - Glib::signal_idle().connect(sigc::bind(sigc::mem_fun(*this, &ChatMessageItemContainer::EmitImageLoad), m_embed_imgurl)); + if (embed.Image.has_value()) { + bool is_img = embed.Image->URL.has_value(); + bool is_thumb = embed.Thumbnail.has_value(); + if (is_img || is_thumb) { + auto *img = Gtk::manage(new Gtk::Image); + img->set_halign(Gtk::ALIGN_CENTER); + int w = 0, h = 0; + if (is_img) + GetImageDimensions(*embed.Image->Width, *embed.Image->Height, w, h, 200, 150); + else + GetImageDimensions(*embed.Thumbnail->Width, *embed.Thumbnail->Height, w, h, 200, 150); + img->set_size_request(w, h); + main->pack_start(*img); + m_embed_img = img; + if (is_img) + m_embed_imgurl = *embed.Image->ProxyURL; + else + m_embed_imgurl = *embed.Thumbnail->ProxyURL; + Glib::signal_idle().connect(sigc::bind(sigc::mem_fun(*this, &ChatMessageItemContainer::EmitImageLoad), m_embed_imgurl)); + } } - if (embed.Footer.Text.length() > 0) { + if (embed.Footer.has_value()) { auto *footer_lbl = Gtk::manage(new Gtk::Label); footer_lbl->set_halign(Gtk::ALIGN_START); footer_lbl->set_line_wrap(true); footer_lbl->set_line_wrap_mode(Pango::WRAP_WORD_CHAR); footer_lbl->set_hexpand(false); - footer_lbl->set_text(embed.Footer.Text); + footer_lbl->set_text(embed.Footer->Text); footer_lbl->get_style_context()->add_class("embed-footer"); main->pack_start(*footer_lbl); } auto style = main->get_style_context(); - if (embed.Color != -1) { + if (embed.Color.has_value()) { auto provider = Gtk::CssProvider::create(); // this seems wrong - std::string css = ".embed { border-left: 2px solid #" + IntToCSSColor(embed.Color) + "; }"; + std::string css = ".embed { border-left: 2px solid #" + IntToCSSColor(*embed.Color) + "; }"; provider->load_from_data(css); style->add_provider(provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } @@ -343,7 +348,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const Message *data) Gtk::Widget *ChatMessageItemContainer::CreateImageComponent(const AttachmentData &data) { int w, h; - GetImageDimensions(data.Width, data.Height, w, h); + GetImageDimensions(*data.Width, *data.Height, w, h); Gtk::EventBox *ev = Gtk::manage(new Gtk::EventBox); Gtk::Image *widget = Gtk::manage(new Gtk::Image); @@ -416,9 +421,9 @@ void ChatMessageItemContainer::HandleUserMentions(Gtk::TextView *tv) { int mstart, mend; if (!match.fetch_pos(0, mstart, mend)) break; const Glib::ustring user_id = match.fetch(1); - const auto *user = discord.GetUser(user_id); + const auto user = discord.GetUser(user_id); const auto *channel = discord.GetChannel(ChannelID); - if (user == nullptr || channel == nullptr) { + if (!user.has_value() || channel == nullptr) { startpos = mend; continue; } @@ -429,8 +434,8 @@ void ChatMessageItemContainer::HandleUserMentions(Gtk::TextView *tv) { replacement = "<b>@" + Glib::Markup::escape_text(user->Username) + "#" + user->Discriminator + "</b>"; else { const auto role_id = user->GetHoistedRole(channel->GuildID, true); - const auto *role = discord.GetRole(role_id); - if (role == nullptr) + const auto role = discord.GetRole(role_id); + if (!role.has_value()) replacement = "<b>@" + Glib::Markup::escape_text(user->Username) + "#" + user->Discriminator + "</b>"; else replacement = "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">@" + Glib::Markup::escape_text(user->Username) + "#" + user->Discriminator + "</span></b>"; @@ -658,7 +663,7 @@ bool ChatMessageItemContainer::OnLinkClick(GdkEventButton *ev) { void ChatMessageItemContainer::ShowMenu(GdkEvent *event) { const auto &client = Abaddon::Get().GetDiscordClient(); - const auto *data = client.GetMessage(ID); + const auto data = client.GetMessage(ID); if (data->IsDeleted()) { m_menu_delete_message->set_sensitive(false); m_menu_edit_message->set_sensitive(false); @@ -685,8 +690,8 @@ void ChatMessageItemContainer::on_menu_edit_message() { } void ChatMessageItemContainer::on_menu_copy_content() { - const auto *msg = Abaddon::Get().GetDiscordClient().GetMessage(ID); - if (msg != nullptr) + const auto msg = Abaddon::Get().GetDiscordClient().GetMessage(ID); + if (msg.has_value()) Gtk::Clipboard::get()->set_text(msg->Content); } @@ -731,13 +736,18 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) { m_timestamp = Gtk::manage(new Gtk::Label); m_avatar_ev = Gtk::manage(new Gtk::EventBox); + const auto author = Abaddon::Get().GetDiscordClient().GetUser(UserID); auto &img = Abaddon::Get().GetImageManager(); - auto buf = img.GetFromURLIfCached(data->Author.GetAvatarURL()); + Glib::RefPtr<Gdk::Pixbuf> buf; + if (author.has_value()) + buf = img.GetFromURLIfCached(author->GetAvatarURL()); + if (buf) m_avatar = Gtk::manage(new Gtk::Image(buf)); else { m_avatar = Gtk::manage(new Gtk::Image(img.GetPlaceholder(32))); - img.LoadFromURL(data->Author.GetAvatarURL(), sigc::mem_fun(*this, &ChatMessageHeader::OnAvatarLoad)); + if (author.has_value()) + img.LoadFromURL(author->GetAvatarURL(), sigc::mem_fun(*this, &ChatMessageHeader::OnAvatarLoad)); } get_style_context()->add_class("message-container"); @@ -814,12 +824,12 @@ void ChatMessageHeader::UpdateNameColor() { const auto &discord = Abaddon::Get().GetDiscordClient(); const auto guild_id = discord.GetChannel(ChannelID)->GuildID; const auto role_id = discord.GetMemberHoistedRole(guild_id, UserID, true); - const auto *user = discord.GetUser(UserID); - if (user == nullptr) return; - const auto *role = discord.GetRole(role_id); + const auto user = discord.GetUser(UserID); + if (!user.has_value()) return; + const auto role = discord.GetRole(role_id); std::string md; - if (role != nullptr) + if (role.has_value()) md = "<span weight='bold' color='#" + IntToCSSColor(role->Color) + "'>" + Glib::Markup::escape_text(user->Username) + "</span>"; else md = "<span weight='bold' color='#eeeeee'>" + Glib::Markup::escape_text(user->Username) + "</span>"; diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp index 7a9842d..28d3fce 100644 --- a/components/chatwindow.cpp +++ b/components/chatwindow.cpp @@ -158,8 +158,8 @@ ChatMessageItemContainer *ChatWindow::CreateMessageComponent(Snowflake id) { void ChatWindow::ProcessNewMessage(Snowflake id, bool prepend) { const auto &client = Abaddon::Get().GetDiscordClient(); if (!client.IsStarted()) return; // e.g. load channel and then dc - const auto *data = client.GetMessage(id); - if (data == nullptr) return; + const auto data = client.GetMessage(id); + if (!data.has_value()) return; ChatMessageHeader *last_row = nullptr; bool should_attach = false; @@ -180,10 +180,10 @@ void ChatWindow::ProcessNewMessage(Snowflake id, bool prepend) { } else { const auto guild_id = client.GetChannel(m_active_channel)->GuildID; const auto user_id = data->Author.ID; - const auto *user = client.GetUser(user_id); - if (user == nullptr) return; + const auto user = client.GetUser(user_id); + if (!user.has_value()) return; - header = Gtk::manage(new ChatMessageHeader(data)); + header = Gtk::manage(new ChatMessageHeader(&*data)); header->signal_action_insert_mention().connect([this, user_id]() { m_signal_action_insert_mention.emit(user_id); }); diff --git a/components/memberlist.cpp b/components/memberlist.cpp index e04c188..04bdf8a 100644 --- a/components/memberlist.cpp +++ b/components/memberlist.cpp @@ -111,14 +111,14 @@ void MemberList::UpdateMemberListInternal() { } // process all the shit first so its in proper order - std::map<int, const Role *> pos_to_role; - std::map<int, std::vector<const User *>> pos_to_users; + std::map<int, Role> pos_to_role; + std::map<int, std::vector<User>> pos_to_users; std::unordered_map<Snowflake, int> user_to_color; std::vector<Snowflake> roleless_users; for (const auto &id : ids) { - auto *user = discord.GetUser(id); - if (user == nullptr) { + auto user = discord.GetUser(id); + if (!user.has_value()) { roleless_users.push_back(id); continue; } @@ -128,19 +128,15 @@ void MemberList::UpdateMemberListInternal() { auto pos_role = discord.GetRole(pos_role_id); auto col_role = discord.GetRole(col_role_id); - if (pos_role == nullptr) { + if (!pos_role.has_value()) { roleless_users.push_back(id); continue; }; - pos_to_role[pos_role->Position] = pos_role; - pos_to_users[pos_role->Position].push_back(user); - if (col_role != nullptr) { - if (ColorDistance(col_role->Color, 0xFFFFFF) < 15) - user_to_color[id] = 0x000000; - else - user_to_color[id] = col_role->Color; - } + pos_to_role[pos_role->Position] = *pos_role; + pos_to_users[pos_role->Position].push_back(std::move(*user)); + if (col_role.has_value()) + user_to_color[id] = col_role->Color; } auto add_user = [this, &user_to_color](const User *data) { @@ -191,17 +187,17 @@ void MemberList::UpdateMemberListInternal() { for (auto it = pos_to_role.crbegin(); it != pos_to_role.crend(); it++) { auto pos = it->first; - auto role = it->second; + const auto &role = it->second; - add_role(role->Name); + add_role(role.Name); if (pos_to_users.find(pos) == pos_to_users.end()) continue; auto &users = pos_to_users.at(pos); - AlphabeticalSort(users.begin(), users.end(), [](auto e) { return e->Username; }); + AlphabeticalSort(users.begin(), users.end(), [](const auto &e) { return e.Username; }); for (const auto data : users) - add_user(data); + add_user(&data); } if (chan->Type == ChannelType::DM || chan->Type == ChannelType::GROUP_DM) @@ -209,9 +205,9 @@ void MemberList::UpdateMemberListInternal() { else add_role("@everyone"); for (const auto &id : roleless_users) { - const auto *user = discord.GetUser(id); - if (user != nullptr) - add_user(user); + const auto user = discord.GetUser(id); + if (user.has_value()) + add_user(&*user); } } |