sending a command to the bot if the user got a pb

This commit is contained in:
Jack 2020-07-07 16:39:10 +01:00
parent f6fc41b8ed
commit 5e83f01e25

View file

@ -367,6 +367,12 @@ exports.testCompleted = functions.https.onCall((request, response) => {
request.obj
)}`
);
if (obj.mode === "time" && String(obj.mode2) === "60") {
console.log(
`sending command to the bot to update the role for user ${request.uid} with wpm ${obj.wpm}`
);
updateDiscordRole(obj.discordId, obj.wpm);
}
return 2;
} else {
console.log(
@ -388,6 +394,15 @@ exports.testCompleted = functions.https.onCall((request, response) => {
}
});
function updateDiscordRole(discordId, wpm) {
db.collection("bot-commands").add({
command: "updateRole",
arguments: [discordId, wpm],
executed: false,
requestTimestamp: Date.now(),
});
}
function isTagValid(name) {
if (name === null || name === undefined || name === "") return false;
if (name.length > 16) return false;