hackatime was down so this is pretty long
Election
I couldn’t think of a good name for this devlog, but it includes a pretty important feature. The groundwork for leader elections is now here, and contains a lot of features.
Start
There is no actual way to start an election right now, the demo video just creates a fake save state that the bot assumes is correct. However, when there is a way to start an election, the start function allows a reason to be passed in. When the channel is made, it is locked to everyone until all the messages are set up, then it is unlocked and an @everyone is sent.
Save state
The bot can be turned off or terminated (except during tallying), and pick up from where it left off when turned back on. I set a challenge for myself to not store any data on disk, so the current election state is stored within invisible characters in the channel topic. I have a function that takes a decimal input, and converts it into binary, then converts the binary into a string of invisible characters that can be put in the channel topic, and is invisible. The characters can only be seen by opening the channel topic, then highlighting all text.
Exceptions
If no votes are cast the leader and vice-leader stay the same.
Election end
All messages should be deleted, the demo video shows one getting past because it was recorded before the fix. There is a little “animation” that plays when the election finishes that shows the top 3 placements. If there is a tie for first, the leader is randomly chosen. The channel is deleted an hour after the vote concludes, but a simple <user> is the new leader! message is sent in the public channel, and a log of the top 3 places are sent in the log channel. The send message permission is also locked to leader and vice leader after the vote is over.
Lock
A few features can be locked during elections, like kick, votekick, and promote.
Hopefully hackatime works today so I can post shorter devlogs.