redo username check, yeet discrims entirely
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
43076b3db6
commit
f1791fac44
1 changed files with 3 additions and 17 deletions
|
@ -1221,26 +1221,12 @@ export function resolveUserId(bot: Client, value: string) {
|
||||||
return mentionMatch[1];
|
return mentionMatch[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// A non-mention, full username?
|
// a username
|
||||||
const oldUsernameMatch = value.match(/^@?([^#]+)#(\d{4})$/);
|
const usernameMatch = value.match(/^@?(\S{3,})$/);
|
||||||
if (oldUsernameMatch) {
|
|
||||||
const profiler = getProfiler();
|
|
||||||
const start = performance.now();
|
|
||||||
const user = bot.users.cache.find(
|
|
||||||
(u) => u.username === oldUsernameMatch[1] && u.discriminator === oldUsernameMatch[2],
|
|
||||||
);
|
|
||||||
profiler?.addDataPoint("utils:resolveUserId:usernameMatch", performance.now() - start);
|
|
||||||
if (user) {
|
|
||||||
return user.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// new usernames system
|
|
||||||
const usernameMatch = value.match(/^@?([^#]+)$/);
|
|
||||||
if (usernameMatch) {
|
if (usernameMatch) {
|
||||||
const profiler = getProfiler();
|
const profiler = getProfiler();
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
const user = bot.users.cache.find((u) => u.username === usernameMatch[1]);
|
const user = bot.users.cache.find((u) => u.tag === usernameMatch[1]);
|
||||||
profiler?.addDataPoint("utils:resolveUserId:usernameMatch", performance.now() - start);
|
profiler?.addDataPoint("utils:resolveUserId:usernameMatch", performance.now() - start);
|
||||||
if (user) {
|
if (user) {
|
||||||
return user.id;
|
return user.id;
|
||||||
|
|
Loading…
Add table
Reference in a new issue