diff --git a/backend/src/utils.ts b/backend/src/utils.ts index f29d990c..af3b5ad8 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -1221,26 +1221,12 @@ export function resolveUserId(bot: Client, value: string) { return mentionMatch[1]; } - // A non-mention, full username? - 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(/^@?([^#]+)$/); + // a username + const usernameMatch = value.match(/^@?(\S{3,})$/); if (usernameMatch) { const profiler = getProfiler(); 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); if (user) { return user.id;