def block(user, expiry = '2 weeks', reason = nil, nocreate = true)
      params = {
        action: 'block',
        user: user,
        expiry: expiry
      }

      token = get_token
      params[:reason] = reason if reason
      params[:nocreate] = '1' if nocreate
      params[:token] = token

      response = post(params)

      if response.key?('error')
        raise MediaWiki::Butt::BlockError.new(response.dig('error', 'code') || 'Unknown error code')
      end

      response['id'].to_i
    end
def block(user, expiry = '2 weeks', reason = nil, nocreate = true)
      params = {
        action: 'block',
        user: user,
        expiry: expiry
      }

      token = get_token
      params[:reason] = reason if reason
      params[:nocreate] = '1' if nocreate
      params[:token] = token

      response = post(params)

      if response.key?('error')
        raise MediaWiki::Butt::BlockError.new(response.dig('error', 'code') || 'Unknown error code')
      end

      response['id'].to_i
    end
Blocks the user.
 @param (see #unblock)
 @param expiry [String] The expiry timestamp using a relative expiry time.
 @param nocreate [Boolean] Whether to allow them to create an account.
 @see https://www.mediawiki.org/wiki/API:Block MediaWiki Block API Docs
 @since 0.5.0
 @raise [BlockError]
 @return (see #unblock)