mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-28 17:56:09 +08:00
fix for a bug where the role would get overwritten
This commit is contained in:
parent
bc4ea7baf4
commit
4925224b0f
2 changed files with 21 additions and 11 deletions
|
|
@ -367,16 +367,27 @@ exports.testCompleted = functions.https.onCall((request, response) => {
|
|||
request.obj
|
||||
)}`
|
||||
);
|
||||
if (
|
||||
obj.mode === "time" &&
|
||||
String(obj.mode2) === "60" &&
|
||||
obj.discordId !== null &&
|
||||
obj.discordId !== undefined
|
||||
) {
|
||||
console.log(
|
||||
`sending command to the bot to update the role for user ${request.uid} with wpm ${obj.wpm}`
|
||||
);
|
||||
updateDiscordRole(obj.discordId, obj.wpm);
|
||||
if (obj.mode === "time" && String(obj.mode2) === "60") {
|
||||
db.collection("users")
|
||||
.doc(request.uid)
|
||||
.get()
|
||||
.then((ret) => {
|
||||
let userdata = ret.data();
|
||||
|
||||
let besttime60 = 0;
|
||||
try {
|
||||
dbSnapshot.personalBests.time[60].forEach((result) => {
|
||||
if (result.wpm > besttime60) besttime60 = result.wpm;
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
if (obj.wpm > besttime60) {
|
||||
console.log(
|
||||
`sending command to the bot to update the role for user ${request.uid} with wpm ${obj.wpm}`
|
||||
);
|
||||
updateDiscordRole(userdata.discordId, obj.wpm);
|
||||
}
|
||||
});
|
||||
}
|
||||
return 2;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1008,7 +1008,6 @@ function showResult(difficultyFailed = false) {
|
|||
blindMode: config.blindMode,
|
||||
theme: config.theme,
|
||||
tags: activeTags,
|
||||
discordId: dbSnapshot !== null ? dbSnapshot.discordId : null,
|
||||
};
|
||||
if (
|
||||
config.difficulty == "normal" ||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue