I've been getting messages asking how to make a Discord Client. For the sake of not repeating myself. I'll go over the many steps. Firstly, I need to say that doing so is against the TOS if you are using a user account. I generally only use the client with a bot account. Anyway, you'll need to understand the Discord API and it's protocols. The main protocols being WebSockets, HTTPS, and JSON. These protocols also use other protocols, such as TLS and TCP. I've made a Discord library for bots, not clients, so I used what I made. Unless, you are very familiar with the APIs, I recommend using a Discord library. You'll need to modify them as they generally don't support custom clients. Discord updates their API sometimes to add features that can break your client, so you'll need update the library and client when that happens.
My library was made to be modular, so I used this as a test to see if modules can add support for strange platforms. We'll need a module for the 2 protocols that work differently on different platforms. Those being the ones that rely on the internet protocol or sockets, so WebSockets, and HTTPS. At first, I used the HTTP library that was part of the homebrew SDK but Discord would reject it a lot. I used my own, as libcurl isn't available though the homebrew SDK. Wslay is a WebSockets library that uses callbacks, this is where you give functions for wslay to use to access things like TLS and HTTPS. We write the needed functions for wslay which use the homebrew SDK's TLS, and our HTTPS library. The HTTPS library is where the TLS connection is first created, however unlike most HTTPS request, which end after getting a response, we keep it open and must poll it and wslay. This should let you connect to Discord's WebSockets server, gateways as Discord likes to call it.
Now, we need to keep the connection open. There's a number of task that need to be done to do this, the library will handle most of them without help but some (reconnects, connection health check, etc.) require a timer running in the background. So you'll need to implement a timer system that does the task at the time given. The current version does a "temporary" solution. A list of task to do and when to do them is stored. When as task needs to be done, we add them to the list. 3DS programs have, what the SDK calls, the main loop, where code runs over and over again until the user press close on the system UI. In there we check if it's time to do a task and then do that task. This was going to be temporary, as this isn't that great of a solution as it doesn't make use of threads or async. The connection should stay open after all this.
After that, you'll need the client to listen for Discord events. This is where you'll get your data, and a lot of data. Most of the data, you don't need right away but Discord isn't going to give you the same data more then once. So, you'll need to store it somewhere. As a "temporary" solution, I used the memory. At first I used hash maps because accessing data from one is quick even for lots of data. However, it would quickly ran out of ram, so I used linked lists, which is slower when accessing data when dealing with lots of data but it used less memory. Again, "temporary solution". I also did some optimizations on everything above and the data needed to be stored but it'll always run out of memory at some point. It'll happen faster if you are on more servers, big servers, very active, or worse, all the above. A more permanent solution would be some cache system that stored this data off the memory if it's not needed just yet. However, remember we are working with SD cards, which aren't known for fast random read and write speeds or much storage space. Looking back, working on getting async working would have really helped here.
Of course, finally, what good is a client where you can't see messages. I'm sure there are frontend frameworks or libraries that does this for you but I made my own and I don't feel like getting into that stuff. It drew triangles, making a rectangle, with textures and positioned them using the C3D library.
Hopefully now, you understand the amount of effort and knowledge getting a Discord client on the 3DS requires. Thanks for reading this long and technical write up.