mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 05:45:02 +00:00
debug+++++
This commit is contained in:
parent
7f4195eb02
commit
9b4c00915f
3 changed files with 35 additions and 8 deletions
|
@ -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`);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue