ralseibot banner

ralseibot

8 devlogs
11h 40m 14s

Updated Project: Switched from npm/node to Bun, updated dependencies, added prometheus stats, added bluesky handler for /ralsei, new commands and more.

A Ralsei/UT/DR themed discord bot with mainly fun utilities. Built with Bun & Discord.js

This project uses AI

Claude Code used for bug finding/fixes & code review, and copilot tab completion.

Demo Repository

Loading README...

BnaJns

Shipped this project!

Updated ralseibot to be more awesome. Added bluesky source support to /ralsei, tsradio as the audio source for /radio so I don’t have to store the files in the bot folder, updated the readme banner for a cooler one, and also slight website changes, added Prometheus stats to use with grafana, switched from node to bun because its better, added some tests using bun:test, bumped all dependencies and got rid of unnecessary ones, added more compliments to /compliment, updated /coin icons, darkworld + spoiler options for /textbox, and added /prophecy to generate a prophecy tile GIF, /deltawiki and /undertalewiki to fetch wiki information via the mediawiki api + parsing html stuff and also updating /randomwiki meanwhile, and more, maybe. Coolest addition is probably the prometheus stats, since I can see that the bot went from 71 servers to 102 servers somehow, didn’t know people were using my bot, and also the most used command in the last 2 weeks is /ralsei at 145 usages. /prophecy could be better but canvas is a pain to use sometimes but I guess it’s close enough. Tests are also cool since I don’t write tests for 99% of stuff but Bun makes it pretty easy to implement. Overall very awesomesauce changes

BnaJns

Prrrrrrrrrroooooooophecy

  • Added /prophecy which lets you generate a prophecy tile GIF, not perfect but whatever
  • Added a darkworld border option + spoiler image option to /textbox
  • I forgor to add updatecount for member count as a loop so i fixed that
    Pretty awesome
Attachment
Attachment
0
BnaJns

Added a few things all around

  • Got rid of dotenv, Bun loads .env automatically anyways
  • Fixed CI, I was stupid and forgot to add bluesky to sources.yaml.example
  • More prometheus stats for analyzing stuff
  • Refactored randomwiki by adding a randomwikiUrl function to the wiki lib, and standardized it to use the exact same embed as the other wiki commands
  • Updated commands.md (shoutout claude)
  • I was gonna replace the compliments in compliments.ts with an external api, but cancelled that idea and instead replaced some ofthe current compliments which weren’t really even that good, with better fitting up-to-date cringy compliments.
  • Redesigned the coinflip emoji icons to be a consistent shape instead of one being a square and the other being a rectangle
  • Decided to keep express for now cause I cba to switch over to Bun and tbf it’s probably unnecessary it’s not like express takes 500mb

Stuff still left to do:

  • Fix the twitter source by using Nitter instead, and that’s it I think
Attachment
Attachment
Attachment
0
BnaJns

5 big booms, boom, boom, boom, boom, BOOM
Added /deltawiki and /undertalewiki using deltarune.wiki and undertale.wiki mediawiki apis and the Bun HTMLRewriter constructor. Fortunately, these both run on mediawiki, with the same stuff, so it only needed one file for both commands to work properly and parse stuff. Pretty basic stuff, gets the title, link, thumbnail, description, and some fields if they exist, throws those in a embed, and boom. Also wrote a test for it, both undertale/deltarune.wikis are tested, cause testing is awesomecsauce, and ofc it passes.
Also upgraded all dependencies, again, to latest major version this time.

Stuff to do:

  • Remove dotenv, in favor of Bun.env, cause dotenv is not necessary cause Bun exists, and also I don’t like the advertising on startup.
  • Remove express in favor of Bun’s HTTP server, the less dependencies, the better.
  • Maybe get rid of ffmpeg-static and instruct users to just install ffmpeg systemwide?
  • Turn more commands into a embed rather than raw text cause embeds are beautiful and cooler
  • Add prometheus statistics for website visits
  • That’s all I got in mind right now
Attachment
Attachment
0
BnaJns

There’s this really annoying bug that I might’ve spent too long diagnosing. Basically, if the bot is in a VC with another person, and someone disconnects the bot via the discord menu, the bot leaves fine. BUT, if the bot is alone in the VC, and someone disconnects the bot, the bot does not leave, it instantly rejoins, BUT, /radio stop still works fine. What kind of dark magic is this? I don’t know. But I pretty much fixed it by never letting the bot be alone in the VC, by instead doing event-driven checks, rather than when the current song ended, so whenever someone joins/leaves VC, it checks the VC member count, if the bot is alone, adios. Also added tsradio support, because it gives me a reason to use my other projects, and also, so that I don’t have to upload mp3’s to different services, let alone git, which would be bad for the git size. Summarizing, vc bug, fixed bug with member count checks on join/leave, added tsradio support, while keeping file support, that’s it. Also fixed a disconnect race condition where the message would be sent multiple times. Awesomesauce.

Attachment
0
BnaJns

Finished adding prom-client, and cooked up a grafana dashboard which is tuff. I did not not know that my bot is in a whopping 71 server so thats kinda crazy. Was this necessary? No. Is it very cool? Totally. Next up I could probably add sharding, even though the bot doesn’t need it yet, still 2429 servers away, but still, futureproofing fr. There was also this annoying bug, which was my fault, but I blame it on the IDE, which was me using import path from “path/win32”, not “node:path”, so when I deployed it on my Fedora server, you can guess what happened, the /ralsei bluesky handler kept failing. I thought it was a Bun fault, it was indeed not. For the next stuff I have in mind, I could probably add a /wiki command to fetch info from deltarune.wiki, and then display it in a short way in an embed, cause rn there’s only /random-wiki, but I’ll take a look around on what other unnecessary but very badass features I can add. Actually, I was just testing the radio, for some reason when the bot gets manually disconnected, it refuses to leave, which is rude, so I gotta fix that, no idea why that’s happening

Attachment
0
BnaJns

Small changes before I work on something big

  • Replaced the hero/banner with a new and cooler one
  • Moved statuses.json into statutes.ts, added git hash status
  • Fixed /random-wiki hopefully
  • Planning to add Prometheus for command/latency/etc analytics tracking via Grafana so that my dashboard doesn’t look empty
Attachment
Attachment
0
BnaJns

The sky is blue

  • Added a BlueSky handler/source to yaml
  • Migrated existing twitter test to a Bun test with proper expects, and wrote a very cool test for Bsky as well
  • The twitter (aka X) test fails 100% of the time because X is evil and they charge a lot of money for the API and playwright doesnt seem to be working
  • TODO: switch from playwright using x.com to nitter.net i think that might work
  • Uses @atproto/api because I cba to handle with curl and auth errors
  • Got rid of the YAML package and just used Bun.YAML.Parse instead
Attachment
Attachment
0
BnaJns

Out of nowhere, I remembered I made this project a while ago, and apparently according to logs random people are actually using it, so this deserves a good refactor and cleanup.
What I did so far was switching from npm/node to Bun, cause Bun is very awesome and faster and better overall. Also setup dependabot monthly alerts so that the dependencies dont gather dust, and after that, which was kind of a pain was refactoring motivational-quote.ts which took me way too long. I started by changing the drawn image from stretching to the square constraints, rather to just fit and the remainders get clipped, and then I changed out the font for deltarune.ttf, which was the pain point. I spent a good few minutes debugging this until a github issue at https://github.com/Automattic/node-canvas/issues/2285 figured out the issue was not having the font installed on the system, which is kinda stupid, why use the .ttf if it needs the font installed. Anyways that’s all for now, next up I’m probably gonna refactor the entire /ralsei command to use better sources, deprecate reddit as a source, maybe add bluesky or whatever, and etc. I’m also probably gonna remake the banner cause the current one just uses art I found on twitter, and it could be better.

Attachment
0