Repository navigation
refactor: give the bot one module for where it sits in the office - #124
Merged
Merged
Conversation
Collaborator
Author
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Closes #117. Stacked on #123; once that merges, this diff is only the last commit.
Where the bot sits in the office was decided and carried out inside
DiscordGateway, next to the discord.js client:wantedRef and arecordingRef;None of this was reachable without a real Discord client, so none of it was tested.
OfficeSeatnow owns all of that, with two members:want(presence): Program calls it when the office opens or empties.record(mode): Capture calls it with Capturing, Paused or Off.SeatAdapteris the Discord side it talks to: move to a channel or out of it (always muted and deafened), whether the bot is still in voice, rename, and a stream of reconnects. There are two adapters:DiscordGatewayfrom the guild and client;DiscordGatewaylosesmoveBotandsetRecordingand exposesseatinstead. Its test layer no longer takes arecordingsqueue.RecordingModeand the nicknames move toOfficeSeat.Behaviour doesn't change. The same voice-state messages, nicknames, logs and timeouts are sent in the same order. Going back after a reconnect now listens through a stream instead of
client.oncallbacks.Two things are left as they are:
botPresenceitself. It needs the opened and emptied events to stop a recording and to catch up at startup.VoiceCapturestill joins throughgateway.voiceAdapter. It's the audio connection's own Discord adapter, so the discord.js type is fine there.How I tested it
OfficeSeattests, through an in-memory adapter:OfficeSeatover the test gateway, with the same moves expected as before.OfficeSeatfake that records the modes.pnpm vp run cipasses. I didn't try it against a real Discord server.Checklist
vp run cipasses