OttoBot/src/main/kotlin/nl/voidcorp/dbot/commands/AdminCommands.kt

36 lines
1.1 KiB
Kotlin

package nl.voidcorp.dbot.commands
import nl.voidcorp.dbot.commands
import nl.voidcorp.dbot.storage.settings
fun initAdmin() {
commands += SetPrefix
commands += ListPrefixes
commands += RemovePrefix
}
object SetPrefix : UnityCommand(
"setprefix",
"Sets the prefix for this command",
AdminCategory,
howTo = "!setprefix prefix",
exec = { ce ->
ce.guild.settings().prefixes += ce.args
ce.reply("This servers prefix is now set to ${ce.args}, but you can still use ${ce.selfMember.asMention} to reset it!")
})
object ListPrefixes : UnityCommand("listprefixes", "Lists all server prefixes", AdminCategory, exec = { ce ->
ce.reply("This servers prefixes are: ${ce.guild.settings().prefixes.ifEmpty { listOf("!") }.joinToString { "`$it`" }}")
})
object RemovePrefix : UnityCommand("removeprefix", "Removes a prefix", AdminCategory, exec = { ce ->
val res = ce.guild.settings().prefixes.removeIf { it == ce.args }
if (res) {
ce.reply("Remove the prefix `${ce.args}`")
} else {
ce.reply("`${ce.args}` is not a known prefix?")
}
})
object UnknownCommandError : Exception("yeet!")