package nl.voidcorp.dbot import com.google.gson.Gson import com.google.gson.GsonBuilder import com.jagrosh.jdautilities.command.Command import java.util.* val gson: Gson = GsonBuilder().setPrettyPrinting().create() val random = Random() fun MutableList.addAll(vararg e: E) = this.addAll(listOf(*e)) fun List.random(): E = this[random.nextInt(this.size)] fun List.catMap(): Map> { val m = mutableMapOf>() for (c in this) { val cname = if (c.category == null) "Unknown" else c.category.name if (!m.containsKey(cname)) { m[cname] = mutableListOf() } m[cname]!! += c } return m } fun String.emptyOr(other: String): String = if (this.isEmpty()) other else this