瀏覽代碼

Add random reaction timing

horse 5 年之前
父節點
當前提交
c17a5ac337
共有 1 個文件被更改,包括 5 次插入1 次删除
  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;
     }