find redirect target by user ID

This commit is contained in:
kageru 2023-08-14 10:29:27 +02:00
parent 80111b2bbf
commit e3e0c07fa2

@ -65,7 +65,7 @@ object Util {
fun findChannel(idOrName: String): Either<String, TextChannel> {
return when {
idOrName.isEntityId() -> server.channelById(idOrName).toEither { "Channel $idOrName not found" }
idOrName.startsWith('@') -> Globals.api.getCachedUserByDiscriminatedName(idOrName.removePrefix("@")).asOption()
idOrName.startsWith('@') -> Globals.api.getUserById(idOrName.removePrefix("@")).asOption()
.toEither { "User $idOrName not found" }
.flatMap { user ->
user.openPrivateChannel().asOption().toEither { "Can’t DM user $idOrName" }