ottobot-v3/src/main/kotlin/nl/voidcorp/ottobot/commands/fun/CatCommand.kt

19 lines
700 B
Kotlin

package nl.voidcorp.ottobot.commands.`fun`
import nl.voidcorp.ottobot.command.Command
import nl.voidcorp.ottobot.command.CommandGroup
import nl.voidcorp.ottobot.command.CommandMessage
import nl.voidcorp.ottobot.command.CommandResult
import java.net.URI
object CatCommand : Command("cat", group = CommandGroup.FUN, allowAnywhere = true) {
var isgif = true
override fun handle(event: CommandMessage): CommandResult {
val url = URI("https://cataas.com/cat" + if (isgif) "/gif" else "").toURL().openStream()
event.message.channel.sendFile(url, if (isgif) "cat.gif" else "cat.png").content("i is cat").queue()
isgif = !isgif
return CommandResult.SUCCESS
}
}