mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
resolveUserId support new usernames
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
047ab872df
commit
c4a2be5ff5
1 changed files with 16 additions and 2 deletions
|
@ -1222,11 +1222,25 @@ export function resolveUserId(bot: Client, value: string) {
|
|||
}
|
||||
|
||||
// A non-mention, full username?
|
||||
const usernameMatch = value.match(/^@?([^#]+)#(\d{4})$/);
|
||||
const oldUsernameMatch = value.match(/^@?([^#]+)#(\d{4})$/);
|
||||
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) {
|
||||
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]);
|
||||
profiler?.addDataPoint("utils:resolveUserId:usernameMatch", performance.now() - start);
|
||||
if (user) {
|
||||
return user.id;
|
||||
|
|
Loading…
Add table
Reference in a new issue