mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-11 06:05:16 +08:00
moved the check to the bot
This commit is contained in:
parent
77401ebd2a
commit
7801089d91
1 changed files with 4 additions and 19 deletions
|
@ -382,25 +382,10 @@ exports.testCompleted = functions.https.onCall((request, response) => {
|
|||
userdata.discordId !== null &&
|
||||
userdata.discordId !== undefined
|
||||
) {
|
||||
let besttime60 = 0;
|
||||
try {
|
||||
userdata.personalBests.time[60].forEach((result) => {
|
||||
if (result.wpm > besttime60) besttime60 = result.wpm;
|
||||
});
|
||||
} catch (e) {
|
||||
besttime60 = 0;
|
||||
}
|
||||
|
||||
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, Math.round(obj.wpm));
|
||||
} else {
|
||||
console.log(
|
||||
`not updating role for user ${request.uid} higher pb found ${besttime60} than ${obj.wpm}`
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
`sending command to the bot to update the role for user ${request.uid} with wpm ${obj.wpm}`
|
||||
);
|
||||
updateDiscordRole(userdata.discordId, Math.round(obj.wpm));
|
||||
return;
|
||||
}
|
||||
return 2;
|
||||
|
|
Loading…
Reference in a new issue