diff --git a/resources/images/subscriber.png b/resources/images/subscriber.png
new file mode 100644
index 000000000..bfdd39b84
Binary files /dev/null and b/resources/images/subscriber.png differ
diff --git a/resources/resources.qrc b/resources/resources.qrc
index e09f97853..511243501 100644
--- a/resources/resources.qrc
+++ b/resources/resources.qrc
@@ -32,6 +32,7 @@
images/UserProfile_22x.png
images/VSO_Link_blue_16x.png
sounds/ping2.wav
+ images/subscriber.png
qt.conf
diff --git a/src/channel.hpp b/src/channel.hpp
index 5ad469b11..ceca68f28 100644
--- a/src/channel.hpp
+++ b/src/channel.hpp
@@ -19,8 +19,6 @@ namespace messages {
class Message;
}
-class IrcManager;
-
class Channel
{
public:
diff --git a/src/resources.cpp b/src/resources.cpp
index 7ac6cde99..3411bba78 100644
--- a/src/resources.cpp
+++ b/src/resources.cpp
@@ -29,6 +29,7 @@ Resources::Resources(EmoteManager &em, WindowManager &wm)
, badgeBroadcaster(lli(em, wm, ":/images/broadcaster_bg.png"))
, badgePremium(lli(em, wm, ":/images/twitchprime_bg.png"))
, badgeVerified(lli(em, wm, ":/images/verified.png", 0.25))
+ , badgeSubscriber(lli(em, wm, ":/images/subscriber.png", 0.25))
, cheerBadge100000(lli(em, wm, ":/images/cheer100000"))
, cheerBadge10000(lli(em, wm, ":/images/cheer10000"))
, cheerBadge5000(lli(em, wm, ":/images/cheer5000"))
diff --git a/src/resources.hpp b/src/resources.hpp
index 161f16c36..cf6ac0300 100644
--- a/src/resources.hpp
+++ b/src/resources.hpp
@@ -27,6 +27,7 @@ public:
messages::LazyLoadedImage *badgeBroadcaster;
messages::LazyLoadedImage *badgePremium;
messages::LazyLoadedImage *badgeVerified;
+ messages::LazyLoadedImage *badgeSubscriber;
messages::LazyLoadedImage *cheerBadge100000;
messages::LazyLoadedImage *cheerBadge10000;
diff --git a/src/twitch/twitchmessagebuilder.cpp b/src/twitch/twitchmessagebuilder.cpp
index 3966ae312..245ced8a8 100644
--- a/src/twitch/twitchmessagebuilder.cpp
+++ b/src/twitch/twitchmessagebuilder.cpp
@@ -619,25 +619,31 @@ void TwitchMessageBuilder::parseTwitchBadges()
continue;
}
- try {
- const auto &badgeSet = channelResources.badgeSets.at("subscriber");
-
- std::string versionKey = badge.mid(11).toStdString();
-
- try {
- auto &badgeVersion = badgeSet.versions.at(versionKey);
-
- appendWord(
- Word(badgeVersion.badgeImage1x, Word::Type::BadgeSubscription, QString(),
- QString("Twitch " + QString::fromStdString(badgeVersion.title))));
- } catch (const std::exception &e) {
- qDebug() << "Exception caught:" << e.what()
- << "when trying to fetch badge version " << versionKey.c_str();
- }
- } catch (const std::exception &e) {
- qDebug() << "No channel badge set with key `subscriber`. Exception: " << e.what();
+ auto badgeSetIt = channelResources.badgeSets.find("subscriber");
+ if (badgeSetIt == channelResources.badgeSets.end()) {
+ // Fall back to default badge
+ appendWord(Word(this->resources.badgeSubscriber, Word::Type::BadgeSubscription,
+ QString(), QString("Twitch Subscriber")));
+ continue;
}
+ const auto &badgeSet = badgeSetIt->second;
+
+ std::string versionKey = badge.mid(11).toStdString();
+
+ auto badgeVersionIt = badgeSet.versions.find(versionKey);
+
+ if (badgeVersionIt == badgeSet.versions.end()) {
+ // Fall back to default badge
+ appendWord(Word(this->resources.badgeSubscriber, Word::Type::BadgeSubscription,
+ QString(), QString("Twitch Subscriber")));
+ continue;
+ }
+
+ auto &badgeVersion = badgeVersionIt->second;
+
+ appendWord(Word(badgeVersion.badgeImage1x, Word::Type::BadgeSubscription, QString(),
+ QString("Twitch " + QString::fromStdString(badgeVersion.title))));
} else {
if (!this->resources.dynamicBadgesLoaded) {
// Do nothing