Tomas D
Tomas D
SIASapphire - Imagine a framework
Created by Tomas D on 3/1/2024 in #sapphire-support
Testing and Sapphire/discord.js
Heya. I'm new to Sapphire and Discord, but not new to JavaScript or coding in general. I'd love some hints/guidance on how to structure a bot to be testable and/or hints about mocking discord messages etc in a maintainable manner or pointers to publicly available bot codebases which have useful unit and/or integration tests. Longer intro/problem background: I help manage a Discord where people post events that run in person - each event has 1 or more dates associated with it and a very limited number of places (3-6). We use discord events + a channel where folks running events list their events in a standard format (1 post per event so people can turn on notifications to just that channel) + each event gets a thread in another channel for folks to chat about it. Remembering and managing these 3+ things is a lot of manual nonsense for people running events I'm planning to write a bot which gradually automates all of this, my rough plan is: * Write code to scrape the existing discord events + parse the two relevant channels and dump stuff in sqlite (done) * Write code to parse a canonical version of each of the events out of the text posts, and join all the dots together and report on anything missing or inconsistent (e.g. inconsistent dates) * Write code to listen to the channels/events in real time and update the database + code to be able to 'catch up' if stuff gets posted whilst the bot is offline (this is where I feel tests would be really useful!) * Teach the bot how to post stuff itself, and have a form - so folks can fill in 1 form and have the three things managed for them * Eventually make ^^ the only method of posting stuff once it's proved itself I'm interested in anything which mocks and tests any non completely trivial interactions with discord to use as inspiration before I go shave a bunch of yaks in the wrong direction. Thanks in advance ❤️
6 replies