summaryrefslogtreecommitdiff
path: root/abaddon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'abaddon.cpp')
-rw-r--r--abaddon.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/abaddon.cpp b/abaddon.cpp
index 888d04a..74355ea 100644
--- a/abaddon.cpp
+++ b/abaddon.cpp
@@ -16,7 +16,8 @@
Abaddon::Abaddon()
: m_settings("abaddon.ini")
- , m_emojis("res/emojis.bin") {
+ , m_emojis("res/emojis.bin")
+ , m_discord(m_settings.GetSettingBool("discord", "memory_db", false)) { // stupid but easy
LoadFromSettings();
// todo: set user agent for non-client(?)
@@ -58,7 +59,6 @@ int Abaddon::StartGTK() {
m_main_window = std::make_unique<MainWindow>();
m_main_window->set_title(APP_TITLE);
- m_main_window->show();
m_main_window->UpdateComponents();
// crashes for some stupid reason if i put it somewhere else
@@ -115,6 +115,13 @@ int Abaddon::StartGTK() {
dlg.run();
}
+ if (!m_discord.IsStoreValid()) {
+ Gtk::MessageDialog dlg(*m_main_window, "The Discord cache could not be created!", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
+ dlg.run();
+ return 1;
+ }
+
+ m_main_window->show();
return m_gtk_app->run(*m_main_window);
}
@@ -358,7 +365,7 @@ void Abaddon::ActionChatDeleteMessage(Snowflake channel_id, Snowflake id) {
}
void Abaddon::ActionChatEditMessage(Snowflake channel_id, Snowflake id) {
- const auto *msg = m_discord.GetMessage(id);
+ const auto msg = m_discord.GetMessage(id);
EditMessageDialog dlg(*m_main_window);
dlg.SetContent(msg->Content);
auto response = dlg.run();
@@ -374,8 +381,8 @@ void Abaddon::ActionInsertMention(Snowflake id) {
void Abaddon::ActionLeaveGuild(Snowflake id) {
ConfirmDialog dlg(*m_main_window);
- const auto *guild = m_discord.GetGuild(id);
- if (guild != nullptr)
+ const auto guild = m_discord.GetGuild(id);
+ if (guild.has_value())
dlg.SetConfirmText("Are you sure you want to leave " + guild->Name + "?");
auto response = dlg.run();
if (response == Gtk::RESPONSE_OK)
@@ -384,8 +391,8 @@ void Abaddon::ActionLeaveGuild(Snowflake id) {
void Abaddon::ActionKickMember(Snowflake user_id, Snowflake guild_id) {
ConfirmDialog dlg(*m_main_window);
- const auto *user = m_discord.GetUser(user_id);
- if (user != nullptr)
+ const auto user = m_discord.GetUser(user_id);
+ if (user.has_value())
dlg.SetConfirmText("Are you sure you want to kick " + user->Username + "#" + user->Discriminator + "?");
auto response = dlg.run();
if (response == Gtk::RESPONSE_OK)
@@ -394,8 +401,8 @@ void Abaddon::ActionKickMember(Snowflake user_id, Snowflake guild_id) {
void Abaddon::ActionBanMember(Snowflake user_id, Snowflake guild_id) {
ConfirmDialog dlg(*m_main_window);
- const auto *user = m_discord.GetUser(user_id);
- if (user != nullptr)
+ const auto user = m_discord.GetUser(user_id);
+ if (user.has_value())
dlg.SetConfirmText("Are you sure you want to ban " + user->Username + "#" + user->Discriminator + "?");
auto response = dlg.run();
if (response == Gtk::RESPONSE_OK)