Add dog and cat command, aka the most important ones
This commit is contained in:
parent
f3b309e2fc
commit
e8d1a978a2
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue