In any criminal proceeding in a magistrate court in which the applicable statutes authorize a sentence of confinement the magistrate shall at the time of the initial appearance advise a defendant of his right to counsel and his right to have counsel appointed if such defendant cannot afford to retain counsel. In the event a defendant requests that counsel be appointed and executes an affidavit that he is unable to afford counsel, the magistrate shall stay further proceedings and shall request the judge of the circuit court, or the chief judge thereof if there is more than one judge of the circuit court, to appoint counsel. Such judge shall thereupon appoint counsel. If there is no judge sitting in the county at the time of the request, then the clerk of the circuit court shall appoint counsel from a list of attorneys in accordance with the rules established by such judge of the circuit court. Counsel shall be paid for his services and expenses in accordance with the provisions of article twenty-one, chapter twenty-nine of this code.