Browse Source

Add random reaction timing

horse 5 years ago
parent
commit
c17a5ac337
1 changed files with 5 additions and 1 deletions
  1. 5 1
      bot/src/commands/random_react.ts

+ 5 - 1
bot/src/commands/random_react.ts

@@ -4,6 +4,8 @@ import { getRepository } from "typeorm";
 import { RandomMessageReaction } from "@shared/db/entity/RandomMesssageReaction";
 import { client } from "src/client";
 
+const timeout = (ms: number) => new Promise(r => setTimeout(r, ms));
+
 @CommandSet
 export class RandomReact {
     @Action(ActionType.MESSAGE)
@@ -23,8 +25,10 @@ export class RandomReact {
         if(!emote)
             return false;
 
-        if(Math.random() < reactInfo.reactProbability)
+        if(Math.random() < reactInfo.reactProbability) {
+            await timeout(Math.random() * 10000);
             await msg.react(emote);
+        }
         
         return false;
     }