Add dog and cat command, aka the most important ones

merge-requests/1/head
Julius de Jeu 2019-06-09 19:29:26 +02:00
parent f3b309e2fc
commit e8d1a978a2
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,19 @@
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
}
}

View File

@ -0,0 +1,18 @@
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 DogCommand : Command("dog", group = CommandGroup.FUN, allowAnywhere = true) {
override fun handle(event: CommandMessage): CommandResult {
val image = URI.create("https://random.dog/woof").toURL().readText()
val url = URI("https://random.dog/$image").toURL().openStream()
event.message.channel.sendFile(url, image).content("i is dog").queue()
return CommandResult.SUCCESS
}
}