You will get an error code. I don’t remember error number. 1st offense is 15 day ban. 2nd is 30 day ban. 3rd is perm ban. Using a flashcart such as a sky 3ds plus without a private header will get you ban (not instantly but somewhere later down the road).
You get ban buy breaking nintendo term of services. Such as modding your 3ds like using cfw. Pirating games and using devices such as flashcarts. The trick is not to get caught. To stay away from getting ban is to not break their term of service.
The bans that were going around were for playing pokemon Sun/Moon online before the official launch of the game. Those bans as far as we know are permanent. If you are using a flashcard however, if you dont use a private header for the ROM you are using, you will get banned (in other words, if you put a .3DS game on your sky3ds/R4 and go online without injecting a header into it, you will get banned most likely. .CIA files dont have that problem as they don’t use headers and can go online without worry of a ban).