You may set the alias by assigning a string wrapped in single quotes to latestbotlogs, as in:
alias latestbotlogs='ssh user@hostname '\''tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'\'
where the expression \' is used to protect single quotes from the shell and have them concatenated in the resulting command. You can verify that they are preserved:
$ alias latestbotlogs
alias latestbotlogs='ssh user@hostname '\''tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'\'''
While with your alias:
alias latestbotlogs="ssh user@hostname 'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'"
gives an error upon definition because the command substitution is evaluated immediately, upon definition. This happens because single quotes lose their special meaning when escaped (with \) or enclosed in double quotes ("). (Reference: Quoting in "The Open Group Base Specifications Issue 7, 2018 edition").
And this is the key: single quotes around the remote command are enough to protect it when the alias is invoked, but do not prevent the enclosed command to be substituted when the alias is created.
Indeed youYou can also use "'" as an alternative to \', as in:
alias latestbotlogs='ssh user@hostname '"'"'tail -f $(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'"'"
Or, using enclose the whole command in double quotes and add some escaping:
alias latestbotlogs="ssh user@hostname 'tail -f \$(ls -1r ~/Development/python/twitter-bot/logs/*.log | head -1)'"
WhereIn this last form, all the characters that retain a special meaning when double-quoted ($, ` and </code>) have to be escaped — (here we have only a $).
Your function, instead, should just work.