diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b5d8df..c3dde872 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,8 +68,8 @@ - Minor: Migrated /followersoff to Helix API. (#4040) - Minor: Migrated /raid command to Helix API. Chat command will continue to be used until February 11th 2023. (#4029) - Minor: Migrated /unraid command to Helix API. Chat command will continue to be used until February 11th 2023. (#4030) -- Minor: Migrated /ban to Helix API. (#4049) -- Minor: Migrated /timeout to Helix API. (#4049) +- Minor: Migrated /ban to Helix API. (#4049, #4164) +- Minor: Migrated /timeout to Helix API. (#4049, #4164) - Minor: Migrated /w to Helix API. Chat command will continue to be used until February 11th 2023. (#4052) - Minor: Migrated /vips to Helix API. Chat command will continue to be used until February 11th 2023. (#4053) - Minor: Migrated /uniquechat and /r9kbeta to Helix API. (#4057) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 8eb66df0..21cb34f5 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -2658,8 +2658,19 @@ void CommandController::initialize(Settings &, Paths &paths) case Error::TargetBanned: { // Equivalent IRC error - errorMessage = QString("%1 is already banned in this channel.") - .arg(userDisplayName); + errorMessage += QString("%1 is already banned in this channel.") + .arg(userDisplayName); + } + break; + + case Error::CannotBanUser: { + // We can't provide the identical error as in IRC, + // because we don't have enough information about the user. + // The messages from IRC are formatted like this: + // "You cannot {op} moderator {mod} unless you are the owner of this channel." + // "You cannot {op} the broadcaster." + errorMessage += QString("You cannot %1 %2.") + .arg(operation, userDisplayName); } break; diff --git a/src/providers/twitch/api/Helix.cpp b/src/providers/twitch/api/Helix.cpp index 6a7ec76f..e9dc0308 100644 --- a/src/providers/twitch/api/Helix.cpp +++ b/src/providers/twitch/api/Helix.cpp @@ -2064,6 +2064,13 @@ void Helix::banUser(QString broadcasterID, QString moderatorID, QString userID, { failureCallback(Error::TargetBanned, message); } + else if (message.startsWith( + "The user specified in the user_id field may " + "not be banned", + Qt::CaseInsensitive)) + { + failureCallback(Error::CannotBanUser, message); + } else { failureCallback(Error::Forwarded, message); diff --git a/src/providers/twitch/api/Helix.hpp b/src/providers/twitch/api/Helix.hpp index c5c0a768..a63d3fea 100644 --- a/src/providers/twitch/api/Helix.hpp +++ b/src/providers/twitch/api/Helix.hpp @@ -551,6 +551,7 @@ enum class HelixBanUserError { // /timeout, /ban Ratelimited, ConflictingOperation, TargetBanned, + CannotBanUser, // The error message is forwarded directly from the Twitch API Forwarded,