"Spy" datapack?


New member
So I'm a beginner for datapacks., but I understand how they work but I don't really know the syntax. I've tried to find something like this before, but I haven't found anything that I was looking for. So here is my question:

How do I make a command that makes the player that executed it, invisible and makes the player go away from the tablist?
Kinda like the vanish plugin, but I want to avoid that because it creates corrupted chunks on my server.

At first, how do you create a command? It's fine if it's like /function..... or /trigger..., but it would be good if it was just a command.
Then, I think that you can write like "execute as @s /effect give invisible" or something but I'm not sure if it is correct
Last but not least I have no idea how I'm gonna make the player go away from the tablist. I hope there is some way to do that.

Thank you! :D