resolveUser: return null if the passed value is not a valid id
This commit is contained in:
parent
5215dd0738
commit
a641312853
6 changed files with 21 additions and 4 deletions
|
@ -972,8 +972,7 @@ export function resolveUserId(bot: Client, value: string) {
|
|||
}
|
||||
|
||||
// Just a user ID?
|
||||
const idMatch = value.match(/^\d+$/);
|
||||
if (idMatch) {
|
||||
if (isValidSnowflake(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -1000,12 +999,12 @@ export async function resolveUser<T>(bot, value) {
|
|||
return new UnknownUser();
|
||||
}
|
||||
|
||||
// If we have the user cached, return that directly
|
||||
const userId = resolveUserId(bot, value);
|
||||
if (!userId) {
|
||||
return new UnknownUser({ id: userId });
|
||||
return null;
|
||||
}
|
||||
|
||||
// If we have the user cached, return that directly
|
||||
if (bot.users.has(userId)) {
|
||||
return bot.users.get(userId);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue