To explain technically, the Applescript code by @noisneil is unable to get the AXFocusedUIElement (since Slack is not true native App), hence the error occurs.
tell application "System Events" to set frontApp to name of first process whose frontmost is true
tell application "System Events"
tell application process frontApp
set _selection to value of attribute "AXFocusedUIElement" # <--- _selection become Missing Value
tell _selection to perform action "AXShowMenu"