diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c262a46..baded6d4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unversioned +- Minor: Allow for built-in Chatterino commands to be used in custom commands. (#2632) - Bugfix: Fix crash that could occur when the user changed the "Custom stream player URI Scheme" setting if the user had closed down and splits in the application runtime. (#2592) ## 2.3.0 diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index e6b7a9414..baf90cea4 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -769,6 +769,25 @@ QString CommandController::execCommand(const QString &textNoEmoji, auto *twitchChannel = dynamic_cast(channel.get()); + { + // check if user command exists + const auto it = this->userCommands_.find(commandName); + if (it != this->userCommands_.end()) + { + text = getApp()->emotes->emojis.replaceShortCodes( + this->execCustomCommand(words, it.value(), dryRun)); + + words = text.split(' ', QString::SkipEmptyParts); + + if (words.length() == 0) + { + return text; + } + + commandName = words[0]; + } + } + // works only in a valid twitch channel if (!dryRun && twitchChannel != nullptr) { @@ -780,15 +799,6 @@ QString CommandController::execCommand(const QString &textNoEmoji, } } - { - // check if user command exists - const auto it = this->userCommands_.find(commandName); - if (it != this->userCommands_.end()) - { - return this->execCustomCommand(words, it.value(), dryRun); - } - } - auto maxSpaces = std::min(this->maxSpaces_, words.length() - 1); for (int i = 0; i < maxSpaces; ++i) {