me.jakejmattson.kutils.api.arguments.UrlArg.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of KUtils Show documentation
Show all versions of KUtils Show documentation
A Discord bot framework for Kotlin.
package me.jakejmattson.kutils.api.arguments
import me.jakejmattson.kutils.api.dsl.arguments.*
import me.jakejmattson.kutils.api.dsl.command.CommandEvent
import me.jakejmattson.kutils.api.extensions.stdlib.containsURl
open class UrlArg(override val name: String = "URL") : ArgumentType() {
companion object : UrlArg()
override fun convert(arg: String, args: List, event: CommandEvent<*>): ArgumentResult {
return if (arg.containsURl())
ArgumentResult.Success(arg)
else
ArgumentResult.Error("Couldn't parse $name from $arg.")
}
override fun generateExamples(event: CommandEvent<*>) = listOf("http://www.google.com")
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy