How to handle UI event in neovim?

With nvim in terminal I want to set the evergreen color, with GUI in neovim(e.g nvim-qt) try to set 'edge` theme:

here is my script but it seems just work in Gvim and vim-terminal not nvim and nvim-qt:

set termguicolors
if has('termguicolors')
    try
        colorscheme everforest
    catch
        colorscheme evening
    endtry
elseif has('gui_running')
    try
        colorscheme edge
    catch
        colorscheme evening
    endtry
endif

You can use autocmd UIEnter and check if v:event.chan is non-zero.

Can you apply it to my example? I’m new with neovim and don’t know how to write it clean