alex.lgbt

Pylon.bot: Should You Use It?

4:46pm on 21st June 2020 correct a mistake

Relatively recently, Pylon was introduced; it’s a serverless platform with its own SDK for developing Discord bots. At first, I really didn’t pay it any attention due to the amount of terrible services like it that I’d seen, but that was definitely a mistake. It’s primarily run by Discord staff and ex-staff, so it’s obviously trusted, and its speed yet ease-of-use genuinely shocked me.

It also uses TypeScript and has open-source type definitions, so you’re able to use TypeScript’s improvements upon JavaScript’s, uh, relatively limited object-oriented features, and you’ll generally know about errors before deployment.

So… how does it work?

Pylon is built on top of the V8 JavaScript runtime, used by a bunch of production programs, some of which being Node.js and Chromium. It’s exceedingly fast as, well, its servers seem to be really performant, and its runtime and SDK are great.

You’ll be somewhat familiar with the SDK if you’ve used other JS API wrappers for Discord, but it’s unique in some ways; scripts are per-guild and it seems to be relatively more low-level (as of now, at least). You’ll be able to use your own bot account and have multiple guilds in the future with BYOB — bring your own bot. It’ll cost around $2.99 per month; the standard tier, however, will always be free!

Database

You’ll end up needing a DB at some point in time, so Pylon provides a KV store with a default limit of 256 keys free-of-charge. It has a super easy API that you can work with.

Deployment

To deploy your scripts, you can either use the really neat online editor or send a POST request to Pylon’s API. Pylon handles all of this for you; you can expect deployments to take around 2 seconds. This also means that downtime is uncommon enough that it’s almost implausible.

Limits

Pylon really isn’t limited a lot. For each event, you’re limited to 50ms CPU time (which is quite a lot), 20s total time, and 25 fetch requests. In the case that you exceed the maximum CPU time, you can request a CPU burst; this temporarily loosens the restrictions.

Online Editor

Pylon actually has an easy online editor built on top of monaco. Scripts are automatically deployed when you save them and there’s tooling to help you, like TypeScript IntelliSense.

Pylon Editor

Downsides

While I think Pylon’s great, it’s not the best in all cases. Sometimes you just, well, don’t want to use TS, or want to have full control over how your bot is being hosted. I’d say the only real issues I have with it include the following:

  • no support for WebAssembly yet;
  • limits that can affect larger bots (note that these are able to be loosened); and
  • fees to use your own bot user.

Pretty much all of these are understandable, though.


So to answer the question — yes. While it’s perfect if you’re making a bot for a single community, it’ll also be able to be used in multiple once BYOB is released. It’s amazing how much you get for… free. What I’ve covered doesn’t even include all built-in features; there’s a bunch of new stuff constantly being implemented, including cron tasks, etc.


Tags: programming, discord, typescript, javascript

Written by Alex P
I'm just a Rust and Go developer from the UK. GitHub

Star me on GitHub!
Licensed under CC-BY-SA unless otherwise stated.