mirror of
				https://github.com/monkeytypegame/monkeytype.git
				synced 2025-11-04 17:30:34 +08:00 
			
		
		
		
	sending a command to the bot if the user got a pb
This commit is contained in:
		
							parent
							
								
									f6fc41b8ed
								
							
						
					
					
						commit
						5e83f01e25
					
				
					 1 changed files with 15 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue