Allow user parameter to be string
This commit is contained in:
parent
771a825d9f
commit
adc0443dbd
|
@ -45,7 +45,7 @@ namespace DeukBot4.MessageHandlers.CommandHandler.RequestStructure
|
||||||
case ParameterType.Remainder:
|
case ParameterType.Remainder:
|
||||||
return $" *(?<{index}>.*)";
|
return $" *(?<{index}>.*)";
|
||||||
case ParameterType.User:
|
case ParameterType.User:
|
||||||
return $" *(?:<@!*(?<{index}>\\d+)>|(?<{index}>\\d+)(?:$| |\n))";
|
return $" *(?:<@!*(?<{index}>\\d+)>|(?<{index}>\\d+)|(?<{index}>\\w+)(?:$| |\n))";
|
||||||
case ParameterType.Timespan:
|
case ParameterType.Timespan:
|
||||||
return $" *(?<{index}>\\d+\\.*\\d*[smhd])";
|
return $" *(?<{index}>\\d+\\.*\\d*[smhd])";
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -45,7 +45,15 @@ namespace DeukBot4.MessageHandlers.CommandHandler.RequestStructure
|
||||||
{
|
{
|
||||||
return await guild.GetUserAsync(i);
|
return await guild.GetUserAsync(i);
|
||||||
}
|
}
|
||||||
return null;
|
else
|
||||||
|
{
|
||||||
|
var t1 = DateTime.UtcNow;
|
||||||
|
var users = await guild.GetUsersAsync();
|
||||||
|
var user = users.FirstOrDefault(x =>
|
||||||
|
x.Username.IndexOf(_value, StringComparison.InvariantCultureIgnoreCase) != -1);
|
||||||
|
Logger.Main.LogWarning($"Finding user on server took {(DateTime.UtcNow - t1).TotalMilliseconds} ms");
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue