diff --git a/src/Channel.cpp b/src/Channel.cpp index cf525eb..de1c9ae 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -336,11 +336,10 @@ bool Channel::isUserInChannel(const std::string &nickname) const { */ void Channel::makeUserAnOper(std::string nickname) { std::vector::iterator it = findUser(nickname); - if (it != this->_users.end()) { - this->_operators.push_back(*it); - this->_users.erase(it); - } else + if (it == this->_users.end()) throw UserNotInChannelException(nickname, this->_name); + this->_operators.push_back(*it); + this->_users.erase(it); } /** @@ -352,12 +351,10 @@ void Channel::makeUserAnOper(std::string nickname) { */ void Channel::makeOperAnUser(std::string nickname) { std::vector::iterator it = findOper(nickname); - if (it != this->_operators.end()) { - it->setNickname(it->getNickname().substr(1)); - this->_users.push_back(*it); - this->_operators.erase(it); - } else + if (it == this->_operators.end()) throw UserNotInChannelException(nickname, this->_name); + this->_users.push_back(*it); + this->_operators.erase(it); } /**