ottobotv2/src/main/kotlin/nl/voidcorp/discord/commands/fun/CatCommand.kt

19 lines
752 B
Kotlin

package nl.voidcorp.discord.commands.`fun`
import nl.voidcorp.discord.command.Command
import nl.voidcorp.discord.command.CommandGroup
import nl.voidcorp.discord.command.CommandMessage
import nl.voidcorp.discord.command.CommandResult
import org.springframework.stereotype.Service
import java.net.URI
@Service
class 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
}
}