3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 05:45:02 +00:00

debug+++++

This commit is contained in:
Dragory 2021-10-05 23:06:12 +03:00
parent 7f4195eb02
commit 9b4c00915f
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
3 changed files with 35 additions and 8 deletions

View file

@ -0,0 +1,33 @@
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { botControlCmd } from "../types";
import blockedAt from "blocked-at";
let stop;
export const ToggleBlockDetectionCmd = botControlCmd({
trigger: ["toggle_block_detection"],
permission: "can_performance",
signature: {
threshold: ct.number({ required: false }),
},
async run({ pluginData, message: msg, args }) {
if (stop) {
stop();
stop = null;
msg.channel.send("Disabled block detection");
return;
}
const threshold = args.threshold || 1000;
const result = blockedAt(
(time, stack) => {
console.error(`Blocked for ${time}ms, operation started here:`, stack);
},
{ threshold },
);
stop = result.stop;
msg.channel.send(`Block detection enabled with ${threshold}ms threshold`);
},
});