A problem in my textbook (Rosenlicht) is to prove that the diameter of a compact metric space $E$ exists, with the following hint: Start with a sequence of pairs of points $\{(p_n,q_n)\}_{n=1,2,3,\cdots}$ of $E$ such that $$\lim_{n\to\infty} d(p_n,q_n)=l.u.b \{d(p,q): p,q \in E\}$$ and pass to convergent subsequences.
I haven't explored the hint much, because I'm thinking of what seems like a simpler method.
Since $E$ compact, $E\times E$ is compact. It is simple to show that the distance function $d:E\times E \to \mathbb{R}$ is continuous. Since $E\times E$ is compact, the image of $E \times E$ is compact and thus attains a maximum on the image. Is this not the diameter? I'm just wary of using a method different to what the book recommends.
Note: The book defines the diameter as $\text{max} \{d(p,q):p,q\in E\}$.
The method the book is suggesting is based on the Bolzano-Weierstrass theorem : in a compact space, from every sequence one can extract a convergent subsequence.
Here you start by saying that if D is the diameter of the space, for all $n\ge0$, $D-\frac1n$ is not the upper bound of the distances between two points of $E$, so there must exist two points $p_n$ and $q_n$ such that $d(p_n,q_n)\ge D-\frac1n$.
The sequence $(p_n)$ is included in a compact, so you can find $\phi:\mathbb N^\ast\to\mathbb N^\ast$ strictly rising such that $(p_{\phi(n)})_n$ is convergent. Let $p$ be its limit.
Now the sequence $(q_{\phi(n)})_n$ is included in a compact, so you can find $\psi:\mathbb N^\ast\to\mathbb N^\ast$ strictly rising such that $(q_{\phi(\psi(n))})_n$ is convergent. Let $q$ be its limit.
First $(p_{\phi(\psi(n))})_n$ is subsequence of a convergent sequence, so it converges with the same limit $p$. Second, $$d(p_{\phi(\psi(n))}-q_{\phi(\psi(n))})\ge D-\frac{1}{\phi(\psi(n))}\ge D-\frac1n$$ By continuity of the distance function, $d(p,q)\ge D$, so $d(p,q)=D$, and $D$ is realized.
Your argument is correct. It just needs the additional theorem : $E$ compact $\Longrightarrow$ $E\times E$ compact.