Closed Froidland closed 12 months ago
Hey, thanks for the PR.
Bancho supports two kinds of timers, but only one can be active at a time: general-purpose timer, and start timer (set using !mp start <seconds>
). Shouldn't we be looking to support both?
Totally forgot about the !mp start
timers 😅, latest commit adds them, tho I feel like the name startTimerStarted
sounds a bit weird.
Manually tested:
import BanchoJs from "bancho.js";
(async () => {
const bancho = new BanchoJs.BanchoClient({
username: "Pancho",
password: "",
apiKey: "",
});
await bancho.connect();
const channel = await bancho.createLobby("Timer test");
bancho.on("CM", (msg) => {
console.log(
`[${msg.channel.name}] ${msg.user.ircUsername}: ${msg.message}`
);
});
channel.lobby.on("startTimerStarted", (seconds) => {
console.log(`[TEST] Start timer started: ${seconds}`);
});
channel.lobby.on("startTimerAborted", () => {
console.log("[TEST] Start timer aborted");
});
channel.lobby.on("startTimerTick", (seconds) => {
console.log(`[TEST] Start timer tick: ${seconds}`);
});
await channel.lobby.startMatch(121);
const timeout = setTimeout(async () => {
await channel.lobby.abortTimer();
}, 110 * 1000);
process.on("SIGINT", async () => {
console.log("Closing lobby and disconnecting...");
clearTimeout(timeout);
await channel.lobby.closeLobby();
bancho.disconnect();
});
})();
/*
[#mp_111377983] Pancho: !mp start 121 3zghs9lby1u
[TEST] Start timer tick: 121
[#mp_111377983] BanchoBot: Match starts in 2 minutes and 1 second
[TEST] Start timer started: 121
[#mp_111377983] BanchoBot: Queued the match to start in 2 minutes and 1 second
[TEST] Start timer tick: 120
[#mp_111377983] BanchoBot: Match starts in 2 minutes
[TEST] Start timer tick: 60
[#mp_111377983] BanchoBot: Match starts in 1 minute
[TEST] Start timer tick: 30
[#mp_111377983] BanchoBot: Match starts in 30 seconds
[#mp_111377983] Pancho: !mp aborttimer e7gpz1fwv58
[TEST] Start timer aborted
[#mp_111377983] BanchoBot: Aborted the match start timer
[#mp_111377983] BanchoBot: Countdown aborted
*/
Please let me know if I'm missing something.
LGTM, can't think of anything missing.
Emit corresponding events related to the
!mp timer
command for theBanchoLobby
class.timerEnd
:timerAborted
:timerTick
:Tests were done manually: