mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
debug: track resolveUserId username match performance
This commit is contained in:
parent
23fba8cdcf
commit
2fd5bb3d17
2 changed files with 11 additions and 1 deletions
|
@ -31,6 +31,7 @@ import { runExpiringVCAlertsLoop } from "./data/loops/expiringVCAlertsLoop";
|
||||||
import { runExpiredArchiveDeletionLoop } from "./data/loops/expiredArchiveDeletionLoop";
|
import { runExpiredArchiveDeletionLoop } from "./data/loops/expiredArchiveDeletionLoop";
|
||||||
import { runSavedMessageCleanupLoop } from "./data/loops/savedMessageCleanupLoop";
|
import { runSavedMessageCleanupLoop } from "./data/loops/savedMessageCleanupLoop";
|
||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
|
import { setProfiler } from "./profiler";
|
||||||
|
|
||||||
if (!process.env.KEY) {
|
if (!process.env.KEY) {
|
||||||
// tslint:disable-next-line:no-console
|
// tslint:disable-next-line:no-console
|
||||||
|
@ -363,6 +364,8 @@ connect().then(async () => {
|
||||||
runSavedMessageCleanupLoop();
|
runSavedMessageCleanupLoop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setProfiler(bot.profiler);
|
||||||
|
|
||||||
bot.initialize();
|
bot.initialize();
|
||||||
logger.info("Bot Initialized");
|
logger.info("Bot Initialized");
|
||||||
logger.info("Logging in...");
|
logger.info("Logging in...");
|
||||||
|
|
|
@ -45,6 +45,8 @@ import { sendDM } from "./utils/sendDM";
|
||||||
import { waitForButtonConfirm } from "./utils/waitForInteraction";
|
import { waitForButtonConfirm } from "./utils/waitForInteraction";
|
||||||
import { decodeAndValidateStrict, StrictValidationError } from "./validatorUtils";
|
import { decodeAndValidateStrict, StrictValidationError } from "./validatorUtils";
|
||||||
import { z, ZodError } from "zod";
|
import { z, ZodError } from "zod";
|
||||||
|
import { getProfiler } from "./profiler";
|
||||||
|
import { performance } from "perf_hooks";
|
||||||
|
|
||||||
const fsp = fs.promises;
|
const fsp = fs.promises;
|
||||||
|
|
||||||
|
@ -1294,8 +1296,13 @@ export function resolveUserId(bot: Client, value: string) {
|
||||||
// A non-mention, full username?
|
// A non-mention, full username?
|
||||||
const usernameMatch = value.match(/^@?([^#]+)#(\d{4})$/);
|
const usernameMatch = value.match(/^@?([^#]+)#(\d{4})$/);
|
||||||
if (usernameMatch) {
|
if (usernameMatch) {
|
||||||
|
const profiler = getProfiler();
|
||||||
|
const start = performance.now();
|
||||||
const user = bot.users.cache.find((u) => u.username === usernameMatch[1] && u.discriminator === usernameMatch[2]);
|
const user = bot.users.cache.find((u) => u.username === usernameMatch[1] && u.discriminator === usernameMatch[2]);
|
||||||
if (user) return user.id;
|
profiler?.addDataPoint("utils:resolveUserId:usernameMatch", performance.now() - start);
|
||||||
|
if (user) {
|
||||||
|
return user.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue