On both web/desktop and mobile, right-click or tap and hold on the server name, channel name, or message, respectively, and select ‘Copy ID'.