馃毃 Fix all ESLint warnings

parent 50584603
......@@ -70,10 +70,7 @@ class BanchoClient extends EventEmitter {
limiterPrivate: 4,
limiterPublic: 3
};
for(const key in optionsOrUsername)
if(optionsOrUsername.hasOwnProperty(key))
if(optionsOrUsername[key] != null)
options[key] = optionsOrUsername[key];
Object.assign(options, optionsOrUsername);
this.username = options.username;
this.password = options.password;
this.host = options.host;
......@@ -325,7 +322,7 @@ class BanchoClient extends EventEmitter {
* @returns {BanchoMultiplayerChannel}
*/
createLobby(name) {
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
if(this.osuApi == null)
throw new Error("bancho.js needs an API key for full multiplayer lobbies support!");
if(!name || !name.trim())
......@@ -337,19 +334,20 @@ class BanchoClient extends EventEmitter {
setTimeout(() => {
reject(new Error("Multiplayer lobby creation timeout has been reached!"));
}, 10000);
await BanchoBot.sendMessage("!mp make "+name);
const listener = (msg) => {
const m = matchCreatedRegex.exec(msg.message);
if(!m || m[2] != name)
return;
BanchoBot.removeListener("message", listener);
const channel = this.getChannel("#mp_"+Number(m[1]));
if(!channel.lobby)
return reject(new Error("Not a multiplayer channel?! This shouldn't happen..."));
resolve(channel);
};
BanchoBot.on("message", listener);
BanchoBot.sendMessage("!mp make "+name).then(() => {
const listener = (msg) => {
const m = matchCreatedRegex.exec(msg.message);
if(!m || m[2] != name)
return;
BanchoBot.removeListener("message", listener);
const channel = this.getChannel("#mp_"+Number(m[1]));
if(!channel.lobby)
return reject(new Error("Not a multiplayer channel?! This shouldn't happen..."));
resolve(channel);
};
BanchoBot.on("message", listener);
});
});
}
......
......@@ -209,7 +209,7 @@ class BanchoUser extends EventEmitter {
*/
stats() {
if(!this.statsPromise)
this.statsPromise = new Promise(async (resolve, reject) => {
this.statsPromise = new Promise((resolve, reject) => {
const statsCommand = new BanchoBotStatsCommand(this);
statsCommand.run()
.then(resolve, reject)
......
......@@ -66,9 +66,7 @@ const Enum = Object.freeze({
*/
class BanchoMods {
constructor() {
for(const key in Enum)
if(Enum.hasOwnProperty(key))
this[key] = Enum[key];
Object.assign(this, Enum);
this.enum = Enum;
}
......@@ -87,12 +85,9 @@ class BanchoMods {
return [];
const mods = [];
for(const modName in Enum)
if(Enum.hasOwnProperty(modName)) {
const mod = Enum[modName];
if(mod != Enum.None && (bits & mod.enumValue) == mod.enumValue)
mods.push(mod);
}
for(const mod of Object.values(Enum))
if(mod != Enum.None && (bits & mod.enumValue) == mod.enumValue)
mods.push(mod);
return mods;
}
......
......@@ -30,10 +30,9 @@ class TestUnit {
assertArrayEquals(expected, obj) {
if(expected.length != obj.length)
throw new Error("Invalid value: expected an array of "+expected.length+" objects, got "+obj.length+"!");
for(const index in expected)
if(expected.hasOwnProperty(index))
if(expected[index] != obj[index])
throw new Error("Invalid value at index "+index+": expected "+expected[index]+", got "+obj[index]+"!");
for(const entry in Object.entries(expected))
if(expected[entry[0]] != obj[entry[0]])
throw new Error("Invalid value at index "+entry[0]+": expected "+entry[1]+", got "+obj[entry[0]]+"!");
}
}
......
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