Commit 52d89e8f authored by Hugo "ThePooN" Denizart's avatar Hugo "ThePooN" Denizart
Browse files

BanchoClient: Allow creation of private lobbies

parent 7bca43f0
Pipeline #4481 passed with stage
in 1 minute and 12 seconds
......@@ -33,8 +33,9 @@ declare module "bancho.js" {
/**
* Creates a multiplayer lobby and return its channel.
* @param name Lobby name
* @param privateLobby Mark as private
*/
createLobby(name: string): Promise<BanchoMultiplayerChannel>
createLobby(name: string, private?: boolean): Promise<BanchoMultiplayerChannel>
/**
* Connects to Bancho, rejects an Error if connection fails
......
......@@ -370,9 +370,10 @@ class BanchoClient extends EventEmitter {
*
* @async
* @param {string} name Lobby name
* @param {boolean} [privateLobby] Mark as private
* @returns {BanchoMultiplayerChannel}
*/
createLobby(name) {
createLobby(name, privateLobby = false) {
return new Promise((resolve, reject) => {
if(this.osuApi == null)
throw new Error("bancho.js needs an API key for full multiplayer lobbies support!");
......@@ -381,11 +382,12 @@ class BanchoClient extends EventEmitter {
name = name.trim();
const BanchoBot = this.getUser("BanchoBot");
const matchCreatedRegex = /Created the tournament match https:\/\/osu\.ppy\.sh\/mp\/(\d+) (.+)/;
setTimeout(() => {
reject(new Error("Multiplayer lobby creation timeout has been reached!"));
}, 10000);
BanchoBot.sendMessage("!mp make "+name).then(() => {
const command = !privateLobby ? "make" : "makeprivate";
BanchoBot.sendMessage("!mp "+command+" "+name).then(() => {
setTimeout(() => {
reject(new Error("Multiplayer lobby creation timeout has been reached!"));
}, 10000);
const matchCreatedRegex = /Created the tournament match https:\/\/osu\.ppy\.sh\/mp\/(\d+) (.+)/;
const listener = (msg) => {
const m = matchCreatedRegex.exec(msg.message);
if(!m || m[2] != name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment