mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-11 22:23:32 +08:00
added code to announce lb changes
This commit is contained in:
parent
a2a8c01d95
commit
f7cd09deb4
1 changed files with 26 additions and 1 deletions
|
@ -455,6 +455,31 @@ exports.testCompleted = functions.https.onCall((request, response) => {
|
|||
let ispb = values[2];
|
||||
// console.log(values);
|
||||
|
||||
let usr =
|
||||
userdata.discordId !== undefined
|
||||
? userdata.discordId
|
||||
: userdata.name;
|
||||
|
||||
if (
|
||||
globallb !== null &&
|
||||
[1, 2, 3].includes(globallb.insertedAt + 1) &&
|
||||
globallb.newBest
|
||||
) {
|
||||
let lbstring = `${obj.mode} ${obj.mode2} global`;
|
||||
console.log(
|
||||
`sending command to the bot to announce lb update ${
|
||||
userdata.discordId
|
||||
} ${globallb + 1} ${lbstring} ${obj.wpm}`
|
||||
);
|
||||
|
||||
announceLbUpdate(
|
||||
usr,
|
||||
globallb.insertedAt + 1,
|
||||
lbstring,
|
||||
obj.wpm
|
||||
);
|
||||
}
|
||||
|
||||
let returnobj = {
|
||||
resultCode: null,
|
||||
globalLeaderboard: globallb,
|
||||
|
@ -1201,7 +1226,7 @@ exports.scheduledFunctionCrontab = functions.pubsub
|
|||
|
||||
async function announceLbUpdate(discordId, pos, lb, wpm) {
|
||||
db.collection("bot-commands").add({
|
||||
command: "updateRole",
|
||||
command: "sayLbUpdate",
|
||||
arguments: [discordId, pos, lb, wpm],
|
||||
executed: false,
|
||||
requestTimestamp: Date.now(),
|
||||
|
|
Loading…
Reference in a new issue