Minecraft wiki entry for Target_selectors, associated text: In Java Edition:
[gamemode=<gamemodeName>] — Include only players in the given game mode.
[gamemode=!<gamemodeName>] — Exclude any players in the given game mode.