OttoBot/src/main/kotlin/nl/voidcorp/dbot/Util.kt

13 lines
324 B
Kotlin
Raw Normal View History

2018-10-10 23:54:01 +02:00
package nl.voidcorp.dbot
2018-10-15 22:25:51 +02:00
import com.google.gson.Gson
2018-10-10 23:54:01 +02:00
import com.google.gson.GsonBuilder
import java.util.*
2018-10-15 22:25:51 +02:00
val gson: Gson = GsonBuilder().setPrettyPrinting().create()
2018-10-10 23:54:01 +02:00
2018-10-15 22:25:51 +02:00
val random = Random()
fun <E> MutableList<E>.addAll(vararg e: E) = this.addAll(listOf(*e))
fun <E> List<E>.random(): E = this[random.nextInt(this.size)]